Browse code
Merge branch 'master' into doc-example
Ed Langley authored on 17/06/2017 21:13:12
Showing 2 changed files
Showing 2 changed files
... | ... |
@@ -34,6 +34,7 @@ |
34 | 34 |
"scripts": { |
35 | 35 |
"start": "react-scripts start", |
36 | 36 |
"build": "babel src -d dist", |
37 |
+ "watch": "babel -w src -d dist", |
|
37 | 38 |
"test": "react-scripts test --env=jsdom", |
38 | 39 |
"eject": "react-scripts eject", |
39 | 40 |
"flow": "flow" |
... | ... |
@@ -52,7 +53,7 @@ |
52 | 53 |
], |
53 | 54 |
"presets": [ |
54 | 55 |
"env", |
55 |
- "stage-3" |
|
56 |
- ] |
|
56 |
+ "stage-3" |
|
57 |
+ ] |
|
57 | 58 |
} |
58 | 59 |
} |
... | ... |
@@ -73,21 +73,9 @@ it("given event handler should generate a urlchange event only when url changes" |
73 | 73 |
}); |
74 | 74 |
|
75 | 75 |
it("should only add url events 1x when addChangeUrlEvent is called on window more than 1x", () => { |
76 |
- // given |
|
77 |
- const window = { |
|
78 |
- location: { |
|
79 |
- hash: '#hash', |
|
80 |
- host: 'example.com', |
|
81 |
- hostname: 'example', |
|
82 |
- origin: '', |
|
83 |
- href: '', |
|
84 |
- pathname: '/path/to/thing', |
|
85 |
- port: 80, |
|
86 |
- protocol: 'https:' |
|
87 |
- } |
|
88 |
- }; |
|
76 |
+// given |
|
77 |
+ const window = {}; |
|
89 | 78 |
const map = {}; |
90 |
- const calls = []; |
|
91 | 79 |
|
92 | 80 |
window.addEventListener = jest.fn((event, cb) => { |
93 | 81 |
if(!map[event]) { |
... | ... |
@@ -96,15 +84,6 @@ it("should only add url events 1x when addChangeUrlEvent is called on window mor |
96 | 84 |
map[event].push(cb); |
97 | 85 |
}); |
98 | 86 |
|
99 |
- window.dispatchEvent = jest.fn(ev => { |
|
100 |
- const evName = ev.type; |
|
101 |
- calls.push(ev); |
|
102 |
- if(map[evName]) { |
|
103 |
- map[evName].handleEvent(ev); |
|
104 |
- } |
|
105 |
- |
|
106 |
- }); |
|
107 |
- |
|
108 | 87 |
// when |
109 | 88 |
addChangeUrlEvent(window); |
110 | 89 |
addChangeUrlEvent(window); |