Skip to content

Commit

Permalink
feat: added mult function
Browse files Browse the repository at this point in the history
BREAKING CHANGE: simulated breaking change

This is a simulated breaking change.
  • Loading branch information
Xunnamius committed Dec 3, 2020
1 parent a4d8949 commit e537358
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ export function sum(a: number, b: number) {
export function diff(a: number, b: number) {
return a - b;
}

/**
* Returns the product of `a` and `b`
*/
export function mult(a: number, b: number) {
return a * b;
}
4 changes: 3 additions & 1 deletion test/integration-browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ describe('workflow-playground [INTEGRATION-BROWSER]', () => {
await run(`${__dirname}/../${main}.js`);
expect(await page.evaluate(() => Object.keys(window))).toIncludeAllMembers([
'sum',
'diff'
'diff',
'mult'
]);
}
});
Expand All @@ -26,6 +27,7 @@ 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);
}
});
});
Expand Down
20 changes: 18 additions & 2 deletions test/integration-node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,38 @@ describe('workflow-playground [INTEGRATION-NODE]', () => {
it('should export expected members', async () => {
expect.hasAssertions();

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

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

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

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

expect(sum(1, 2)).toBe(3);
});

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

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

expect(diff(1, 2)).toBe(-1);
});

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

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

expect(mult(1, 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
14 changes: 13 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 } from '../src/index';
import { sum, diff, mult } from '../src/index';

describe('workflow-playground [UNIT]', () => {
describe('::sum', () => {
Expand All @@ -7,6 +7,7 @@ describe('workflow-playground [UNIT]', () => {
expect(sum(2, 2)).toBe(4);
});
});

describe('::diff', () => {
it('takes the difference as expected', async () => {
expect.hasAssertions();
Expand All @@ -17,4 +18,15 @@ describe('workflow-playground [UNIT]', () => {
expect(true).toBe(true);
});
});

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

0 comments on commit e537358

Please sign in to comment.