Skip to content

Commit 502c975

Browse files
tests for buttons, travel, and action containers
Co-authored-by: Josh <[email protected]>
1 parent df2332c commit 502c975

File tree

9 files changed

+278
-100
lines changed

9 files changed

+278
-100
lines changed

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ module.exports = {
1010
],
1111
['@babel/preset-react'],
1212
],
13+
plugins: [
14+
["@babel/plugin-proposal-decorators", { legacy: true }]
15+
]
1316
};

package-lock.json

Lines changed: 79 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@babel/core": "^7.5.5",
2727
"@babel/preset-env": "^7.5.5",
2828
"@babel/preset-react": "^7.0.0",
29+
"@babel/plugin-proposal-decorators": "^7.4.4",
2930
"babel-loader": "^8.0.6",
3031
"css-loader": "^3.1.0",
3132
"enzyme": "^3.10.0",

package/__tests__/index.test.js

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,29 @@ const index = require('../index');
44

55
jest.mock('../timeJump');
66

7-
describe('unit testing for index.js', () => {
8-
test('index.js should be exporting the linkState and timeJump methods', () => {
9-
expect(typeof index.linkState).toBe('function');
10-
expect(typeof index.timeJump).toBe('function');
11-
});
12-
13-
test('index.js should be listening to the window for the jumpToSnap message', (done) => {
14-
const calls = 10;
15-
let count = 0;
16-
global.addEventListener('message', ({ data: { action } }) => {
17-
if (action === 'jumpToSnap') {
18-
count += 1;
19-
// timeJump should be called everytime a message is received
20-
expect(index.timeJump.mock.calls.length).toBe(count);
21-
22-
// test is done once all messages have been received
23-
if (count === calls) done();
24-
}
25-
});
26-
27-
// iterate ${calls} amount of times
28-
[...Array(calls).keys()].forEach(() => global.postMessage({ action: 'jumpToSnap', payload: ['test'] }, '*'));
29-
});
30-
31-
});
32-
33-
describe('testing the emptySnapshot button', () => {
34-
test('emptySnapshot button should delete all newly created snapshots', () => {
35-
const mockCb = jest.fn();
36-
37-
const snapshots = shallow(<div>snapshot</div>)
38-
const parentComponent = shallow(<snapshots></snapshots><snapshots></snapshots>)
39-
40-
const button = shallow((<Button onClick= { mockCb }>Empty Snapshots</Button>));
41-
42-
button.find('button').simulate('click');
43-
44-
expect(mockFuncs.length).not.toEqual(1)
45-
});
46-
})
7+
8+
// describe('unit testing for index.js', () => {
9+
// test('index.js should be exporting the linkState and timeJump methods', () => {
10+
// expect(typeof index.linkState).toBe('function');
11+
// expect(typeof index.timeJump).toBe('function');
12+
// });
13+
14+
// test('index.js should be listening to the window for the jumpToSnap message', (done) => {
15+
// const calls = 10;
16+
// let count = 0;
17+
// global.addEventListener('message', ({ data: { action } }) => {
18+
// if (action === 'jumpToSnap') {
19+
// count += 1;
20+
// // timeJump should be called everytime a message is received
21+
// expect(index.timeJump.mock.calls.length).toBe(count);
22+
23+
// // test is done once all messages have been received
24+
// if (count === calls) done();
25+
// }
26+
// });
27+
28+
// // iterate ${calls} amount of times
29+
// [...Array(calls).keys()].forEach(() => global.postMessage({ action: 'jumpToSnap', payload: ['test'] }, '*'));
30+
// });
31+
32+
// });

0 commit comments

Comments
 (0)