Skip to content

Commit

Permalink
feat: added diff to take the difference
Browse files Browse the repository at this point in the history
BREAKING CHANGE: switch to semantic-release CI/CD pipeline
Moved away from publish-please to a fully automated build-test-deploy release cycle based on semantic-release.
  • Loading branch information
Xunnamius committed Nov 21, 2020
1 parent 57faa2c commit 5e40deb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@
export function sum(a: number, b: number) {
return a + b;
}

/**
* Returns the difference of `a` and `b`
*/
export function diff(a: number, b: number) {
return a - b;
}
2 changes: 2 additions & 0 deletions test/integration/chrome.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('workflow-playground [INTEGRATION-CHROME]', () => {
await run(`${__dirname}/../../${main}.js`);
expect(await page.evaluate(() => Object.keys(window))).toIncludeAllMembers([
'sum',
'diff',
]);
}
});
Expand All @@ -24,6 +25,7 @@ describe('workflow-playground [INTEGRATION-CHROME]', () => {
await run(`${__dirname}/../../${main}.js`);

expect(await page.evaluate(() => (window as any).sum(1, 2))).toBe(3);
expect(await page.evaluate(() => (window as any).diff(1, 2))).toBe(-1);
}
});
});
Expand Down
5 changes: 4 additions & 1 deletion test/integration/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@ describe('workflow-playground [INTEGRATION-NODE]', () => {

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

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

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

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

expect(sum(1, 2)).toBe(3);
expect(diff(1, 2)).toBe(-1);
});
});
9 changes: 8 additions & 1 deletion test/unit-index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
sum
sum,
diff,
} from '../src/index'

describe('workflow-playground [UNIT]', () => {
Expand All @@ -9,4 +10,10 @@ describe('workflow-playground [UNIT]', () => {
expect(sum(2, 2)).toBe(4);
});
});
describe('::diff', () => {
it('takes the difference as expected', async () => {
expect.hasAssertions();
expect(diff(2, 2)).toBe(0);
});
});
});

0 comments on commit 5e40deb

Please sign in to comment.