Skip to content

Commit f8b1651

Browse files
committed
Fix Jasmine errors
- Resolve issue with new jasmine-jquery not including jquery - Add sinon to spy on timer and assert that timer is being tested
1 parent c62a945 commit f8b1651

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

Gruntfile.coffee

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,10 @@ module.exports = (grunt) ->
165165
specs: 'compiled_spec/*spec.js'
166166
helpers: 'spec/*helper.js'
167167
vendor: [
168-
'node_modules/jasmine-jquery/vendor/jquery/jquery.js'
168+
'node_modules/jquery/dist/jquery.js'
169169
'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
170+
'node_modules/sinon/pkg/sinon.js'
171+
'node_modules/jasmine-sinon/lib/jasmine-sinon.js'
170172
]
171173
template: require('grunt-template-jasmine-istanbul')
172174
templateOptions:
@@ -178,8 +180,10 @@ module.exports = (grunt) ->
178180
specs: 'compiled_spec/*spec.js'
179181
helpers: 'spec/*helper.js'
180182
vendor: [
181-
'node_modules/jasmine-jquery/vendor/jquery/jquery.js'
183+
'node_modules/jquery/dist/jquery.js'
182184
'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
185+
'node_modules/sinon/pkg/sinon.js'
186+
'node_modules/jasmine-sinon/lib/jasmine-sinon.js'
183187
]
184188
template: require('grunt-template-jasmine-istanbul')
185189
templateOptions:

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
"grunt-contrib-watch": "^1.0.0",
3434
"grunt-template-jasmine-istanbul": "^0.5.0",
3535
"grunt-ts": "^5.5.1",
36+
"jquery": "^3.1.1",
3637
"jasmine-jquery": "^2.0.0",
38+
"sinon": "^1.17.6",
39+
"jasmine-sinon": "^0.4.0",
3740
"load-grunt-tasks": "^3.5.2"
3841
}
3942
}

spec/CommentCoreLibrary_spec.coffee

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict'
2+
23
describe 'CommentManager', ->
34
manager = stage = cmt = c1 = c2 = c3 = c4 = c5 = null
45

@@ -66,15 +67,15 @@ describe 'CommentManager', ->
6667

6768
describe '.start', ->
6869
it 'starts the timer', ->
70+
spy = sinon.spy window, 'setInterval'
6971
manager.start()
70-
# TODO: figure out how to test the timer
71-
# maybe just add spy on window.setInterval
72+
expect(spy).toHaveBeenCalled true
7273

7374
describe '.stop', ->
7475
it 'stops the timer', ->
76+
spy = sinon.spy window, 'clearInterval'
7577
manager.stop()
76-
# TODO: figure out how to test the timer
77-
# maybe just add spy on window.clearInterval
78+
expect(spy).toHaveBeenCalled true
7879

7980
describe '.clear', ->
8081
it 'clears', ->

0 commit comments

Comments
 (0)