Skip to content

Commit

Permalink
fix(test): improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Xunnamius committed Jan 1, 2021
1 parent 48a4744 commit 7f4a70a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
3 changes: 3 additions & 0 deletions test/integration-browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ describe('workflow-playground [INTEGRATION-BROWSER]', () => {
expect(await page.evaluate(() => (window as any).sum(1, 2))).toBe(3);
expect(await page.evaluate(() => (window as any).diff(1, 2))).toBe(-1);
expect(await page.evaluate(() => (window as any).mult(1, 2))).toBe(2);
expect(
await page.evaluate(() => (window as any).div({ dividend: 4, divisor: 2 }))
).toBe(2);
}
});
});
Expand Down
25 changes: 17 additions & 8 deletions test/integration-node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
import { main } from '../package.json';

describe('workflow-playground [INTEGRATION-NODE]', () => {
// it('should export expected members', async () => {
// expect.hasAssertions();
it('should export expected members', async () => {
expect.hasAssertions();

// const { sum, diff, mult, ...rest } = await import(`${__dirname}/../${main}.js`);
const { sum, diff, mult, div, ...rest } = await import(`${__dirname}/../${main}.js`);

// expect(sum).toBeDefined();
// expect(diff).toBeDefined();
// expect(mult).toBeDefined();
// expect(rest).toBeEmpty();
// });
expect(sum).toBeDefined();
expect(diff).toBeDefined();
expect(mult).toBeDefined();
expect(div).toBeDefined();
expect(rest).toBeEmpty();
});

it('should sum properly', async () => {
expect.hasAssertions();
Expand All @@ -37,6 +38,14 @@ describe('workflow-playground [INTEGRATION-NODE]', () => {
expect(mult(1, 2)).toBe(2);
});

it('should divide properly', async () => {
expect.hasAssertions();

const { div } = await import(`${__dirname}/../${main}.js`);

expect(div({ dividend: 4, divisor: 2 })).toBe(2);
});

// eslint-disable-next-line jest/prefer-expect-assertions
it('fails if this test should fail', async () => {
expect(true).toBe(true);
Expand Down
13 changes: 12 additions & 1 deletion test/unit-index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sum, diff, mult } from '../src/index';
import { sum, diff, mult, div } from '../src/index';

describe('workflow-playground [UNIT]', () => {
describe('::sum', () => {
Expand Down Expand Up @@ -29,4 +29,15 @@ describe('workflow-playground [UNIT]', () => {
expect(true).toBe(true);
});
});

describe('::div', () => {
it('divides as expected', async () => {
expect.hasAssertions();
expect(div({ dividend: 4, divisor: 2 })).toBe(2);
});
// eslint-disable-next-line jest/prefer-expect-assertions
it('fails if this test should fail', async () => {
expect(true).toBe(true);
});
});
});

0 comments on commit 7f4a70a

Please sign in to comment.