Skip to content

Commit bee240c

Browse files
committed
fix unit tests in FF/IE
1 parent 80462f0 commit bee240c

File tree

8 files changed

+28
-22
lines changed

8 files changed

+28
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"lint": "eslint src build test/e2e test/unit/specs",
99
"test": "npm run lint && ./node_modules/karma/bin/karma start build/karma.config.js",
1010
"build": "webpack --config build/webpack.build.dev.config.js && webpack --config build/webpack.build.min.config.js",
11-
"serve": "webpack-dev-server --quiet --hot --config example/webpack.config.js --content-base example --history-api-fallback",
11+
"serve": "webpack-dev-server --quiet --hot --config example/webpack.config.js --content-base example --history-api-fallback --host 0.0.0.0",
1212
"watch-test": "webpack --watch test/unit/specs/index.js test/unit/test.build.js",
1313
"e2e-local": "nightwatch -c build/nightwatch.local.json -e chrome,firefox",
1414
"e2e-sauce": "nightwatch -c build/nightwatch.sauce.json -e chrome,firefox,ie10,ie11",

test/unit/specs/core.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,12 @@ describe('Core', function () {
473473
router.go('/a')
474474
nextTick(function () {
475475
window.addEventListener('popstate', function onPop () {
476-
expect(window.scrollTo).toHaveBeenCalledWith(x, y)
477-
window.removeEventListener('popstate', onPop)
478-
router.stop()
479-
done()
476+
nextTick(function () {
477+
expect(window.scrollTo).toHaveBeenCalledWith(x, y)
478+
window.removeEventListener('popstate', onPop)
479+
router.stop()
480+
done()
481+
})
480482
})
481483
history.back()
482484
})

test/unit/specs/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
window.isIE9 = navigator.userAgent.toLowerCase().indexOf('msie 9.0') > 0
2-
window.wait = 16
1+
var UA = navigator.userAgent.toLowerCase()
2+
window.isIE9 = UA.indexOf('msie 9.0') > 0
3+
window.isIE = UA.indexOf('trident') > 0
4+
5+
// IE has some shaky timer precision issues when using the Promise polyfill...
6+
window.wait = isIE ? 100 : 30
37

48
require('es6-promise').polyfill()
59

test/unit/specs/pipeline/activate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ describe('activate', function () {
9797
assertCalls(calls, ['a.activate'])
9898
expect(router.app.$el.textContent).toBe('A ')
9999
done()
100-
}, wait)
100+
}, wait * 2)
101101
})
102102
})
103103

@@ -121,7 +121,7 @@ describe('activate', function () {
121121
expect(router.app.$el.textContent).toBe('')
122122
expect(router.history.currentPath).toBe('/')
123123
done()
124-
}, wait)
124+
}, wait * 2)
125125
})
126126
})
127127
})

test/unit/specs/pipeline/can-activate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ describe('canActivate', function () {
9797
assertCalls(calls, ['a.canActivate'])
9898
expect(router.app.$el.textContent).toBe('A ')
9999
done()
100-
}, wait)
100+
}, wait * 2)
101101
})
102102
})
103103

@@ -123,7 +123,7 @@ describe('canActivate', function () {
123123
expect(router.app.$el.textContent).toBe('')
124124
expect(router.history.currentPath).toBe('/')
125125
done()
126-
}, wait)
126+
}, wait * 2)
127127
})
128128
})
129129

@@ -147,7 +147,7 @@ describe('canActivate', function () {
147147
expect(router.app.$el.textContent).toBe('')
148148
expect(router.history.currentPath).toBe('/')
149149
done()
150-
}, wait)
150+
}, wait * 2)
151151
})
152152
})
153153
})

test/unit/specs/pipeline/can-deactivate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('canDeactivate', function () {
108108
expect(router.app.$el.textContent).toBe('C ')
109109
expect(router.history.currentPath).toBe('/c')
110110
done()
111-
}, wait)
111+
}, wait * 2)
112112
})
113113
})
114114

@@ -136,7 +136,7 @@ describe('canDeactivate', function () {
136136
expect(router.app.$el.textContent).toBe('A ')
137137
expect(router.history.currentPath).toBe('/a')
138138
done()
139-
}, wait)
139+
}, wait * 2)
140140
})
141141
})
142142

@@ -162,7 +162,7 @@ describe('canDeactivate', function () {
162162
expect(router.app.$el.textContent).toBe('A ')
163163
expect(router.history.currentPath).toBe('/a')
164164
done()
165-
}, wait)
165+
}, wait * 2)
166166
})
167167
})
168168
})

test/unit/specs/pipeline/data.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('data', function () {
2222
setTimeout(function () {
2323
expect(router.app.$el.textContent).toBe('hello')
2424
done()
25-
}, wait)
25+
}, wait * 2)
2626
})
2727
})
2828

@@ -50,9 +50,9 @@ describe('data', function () {
5050
setTimeout(function () {
5151
expect(router.app.$el.textContent).toBe('reload')
5252
done()
53-
}, wait)
53+
}, wait * 2)
5454
})
55-
}, wait)
55+
}, wait * 2)
5656
})
5757
})
5858

@@ -81,9 +81,9 @@ describe('data', function () {
8181
setTimeout(function () {
8282
expect(router.app.$el.textContent).toBe('reload')
8383
done()
84-
}, wait)
84+
}, wait * 2)
8585
})
86-
}, wait)
86+
}, wait * 2)
8787
})
8888
})
8989

test/unit/specs/pipeline/deactivate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe('deactivate', function () {
107107
assertCalls(calls, ['a.deactivate'])
108108
expect(router.app.$el.textContent).toBe('')
109109
done()
110-
}, wait)
110+
}, wait * 2)
111111
})
112112
})
113113

@@ -134,7 +134,7 @@ describe('deactivate', function () {
134134
expect(router.app.$el.textContent).toBe('A ')
135135
expect(router.history.currentPath).toBe('/a')
136136
done()
137-
}, wait)
137+
}, wait * 2)
138138
})
139139
})
140140
})

0 commit comments

Comments
 (0)