git.fiddlerwoaroof.com
Browse code

cleaning up test

Max Summe authored on 17/06/2017 20:56:03
Showing 1 changed files
... ...
@@ -77,20 +77,8 @@ it("given event handler should generate a urlchange event only when url changes"
77 77
 
78 78
 it("should only add url events 1x when addChangeUrlEvent is called on window more than 1x", () => {
79 79
 // given
80
-  const window = {
81
-    location: {
82
-      hash: '#hash',
83
-      host: 'example.com',
84
-      hostname: 'example',
85
-      origin: '',
86
-      href: '',
87
-      pathname: '/path/to/thing',
88
-      port: 80,
89
-      protocol: 'https:'
90
-    }
91
-  };
80
+  const window = {};
92 81
   const map = {};
93
-  const calls = [];
94 82
 
95 83
   window.addEventListener = jest.fn((event, cb) => {
96 84
     if(!map[event]) {
... ...
@@ -99,15 +87,6 @@ it("should only add url events 1x when addChangeUrlEvent is called on window mor
99 87
     map[event].push(cb);
100 88
   });
101 89
 
102
-  window.dispatchEvent = jest.fn(ev => {
103
-    const evName = ev.type;
104
-    calls.push(ev);
105
-    if(map[evName]) {
106
-      map[evName].handleEvent(ev);
107
-    }
108
-
109
-  });
110
-
111 90
   // when
112 91
   addChangeUrlEvent(window);
113 92
   addChangeUrlEvent(window);
... ...
@@ -120,4 +99,4 @@ it("should only add url events 1x when addChangeUrlEvent is called on window mor
120 99
     expect(map[event].length).toEqual(1);
121 100
   }
122 101
 
123
-});
124 102
\ No newline at end of file
103
+});