simplify and fix test pattern

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

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

2
.gitignore vendored

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

@ -18,12 +18,12 @@
"lib/JsonRpc.d.ts" "lib/JsonRpc.d.ts"
], ],
"scripts": { "scripts": {
"prepublishOnly": "yarn run build", "prepublishOnly": "npm run build",
"build": "yarn run build:bundle && yarn run build:types", "build": "npm run build:bundle && npm run build:types",
"build:bundle": "node ./scripts/bundle.mjs", "build:bundle": "node ./scripts/bundle.mjs",
"build:types": "tsc", "build:types": "tsc",
"test": "tap --node-arg=--require=esbuild-register '**/*.test.*'", "test": "tap --node-arg=--require=esbuild-register './src/**/*.test.*'",
"spec": "tap --node-arg=--require=esbuild-register '**/*.spec.*'" "spec": "tap --node-arg=--require=esbuild-register './src/**/*.spec.*'"
}, },
"devDependencies": { "devDependencies": {
"@types/jsdom": "^16.2.13", "@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}`, hello: (name: string) => `goodbye ${name}`,
canVote: (voter: {age: number}) => voter.age > 18, canVote: (voter: {age: number}) => voter.age > 18,
deferred: () => Promise.resolve('deferredResult'), deferred: () => Promise.resolve('deferredResult'),
spy: () => 'mock',
blowUp: () => { blowUp: () => {
throw Error('BOOM!'); throw Error('BOOM!');
}, },
@ -123,7 +122,7 @@ test('mounted', async ({beforeEach, afterEach, test}) => {
document.body.appendChild(frame2); document.body.appendChild(frame2);
rpc1 = new JsonRpc({ rpc1 = new JsonRpc({
methods: {one: () => 'one'}, methods: {},
source: frame1.contentWindow as MessageEventSource, source: frame1.contentWindow as MessageEventSource,
destination: frame2.contentWindow as MessageEventSource, destination: frame2.contentWindow as MessageEventSource,
}); });
@ -168,7 +167,7 @@ test('mounted', async ({beforeEach, afterEach, test}) => {
test('ignores unexpected responses', async t => { test('ignores unexpected responses', async t => {
const {contentWindow} = frame1; const {contentWindow} = frame1;
contentWindow?.postMessage({jsonrpc: '2.0', result: {}}, '*'); contentWindow!.postMessage({jsonrpc: '2.0', result: {}}, '*');
await defer(0); await defer(0);
}); });

Loading…
Cancel
Save