simplify and fix test pattern

master
Jason Staten 3 years ago
parent 763f9454b9
commit 4d6f301f80

@ -1,7 +1,6 @@
image: alpine/edge
packages:
- nodejs
- yarn
sources:
- https://git.sr.ht/~statianzo/pmrpc
secrets:
@ -10,10 +9,11 @@ secrets:
- 576364b7-4764-4794-a536-1a3357fb222b
environment:
CI: "true"
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true"
tasks:
- setup: |
cd pmrpc
yarn install
npm install
- validate: |
cd pmrpc
yarn test
npm test

2
.gitignore vendored

@ -4,4 +4,4 @@ node_modules
*.tgz
.nyc_output
coverage
.pnpm-lock.yaml
package-lock.json

@ -18,12 +18,12 @@
"lib/JsonRpc.d.ts"
],
"scripts": {
"prepublishOnly": "yarn run build",
"build": "yarn run build:bundle && yarn run build:types",
"prepublishOnly": "npm run build",
"build": "npm run build:bundle && npm run build:types",
"build:bundle": "node ./scripts/bundle.mjs",
"build:types": "tsc",
"test": "tap --node-arg=--require=esbuild-register '**/*.test.*'",
"spec": "tap --node-arg=--require=esbuild-register '**/*.spec.*'"
"test": "tap --node-arg=--require=esbuild-register './src/**/*.test.*'",
"spec": "tap --node-arg=--require=esbuild-register './src/**/*.spec.*'"
},
"devDependencies": {
"@types/jsdom": "^16.2.13",

File diff suppressed because it is too large Load Diff

@ -21,7 +21,6 @@ test('handling requests', async ({beforeEach, test}) => {
hello: (name: string) => `goodbye ${name}`,
canVote: (voter: {age: number}) => voter.age > 18,
deferred: () => Promise.resolve('deferredResult'),
spy: () => 'mock',
blowUp: () => {
throw Error('BOOM!');
},
@ -123,7 +122,7 @@ test('mounted', async ({beforeEach, afterEach, test}) => {
document.body.appendChild(frame2);
rpc1 = new JsonRpc({
methods: {one: () => 'one'},
methods: {},
source: frame1.contentWindow as MessageEventSource,
destination: frame2.contentWindow as MessageEventSource,
});
@ -168,7 +167,7 @@ test('mounted', async ({beforeEach, afterEach, test}) => {
test('ignores unexpected responses', async t => {
const {contentWindow} = frame1;
contentWindow?.postMessage({jsonrpc: '2.0', result: {}}, '*');
contentWindow!.postMessage({jsonrpc: '2.0', result: {}}, '*');
await defer(0);
});

Loading…
Cancel
Save