Skip to content

Commit 73a4e2b

Browse files
committed
Add specs to test parsers
1 parent 265c5bb commit 73a4e2b

10 files changed

Lines changed: 88 additions & 3 deletions

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ before_install:
66
before_script:
77
- npm install -g grunt-cli
88
script:
9-
- grunt test
9+
- grunt ci
1010
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

Gruntfile.coffee

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,26 @@ module.exports = (grunt) ->
163163
jasmine:
164164
coverage:
165165
src: 'src/**/*.js'
166-
#src: 'build/CommentCoreLibrary.js'
167166
options:
168167
specs: 'compiled_spec/*spec.js'
169168
helpers: 'spec/*helper.js'
169+
vendor: [
170+
'node_modules/jasmine-jquery/vendor/jquery/jquery.js'
171+
'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
172+
]
173+
template: require('grunt-template-jasmine-istanbul')
174+
templateOptions:
175+
report: 'coverage'
176+
coverage: 'coverage/coverage.json'
177+
ci:
178+
src: 'build/CommentCoreLibrary.js'
179+
options:
180+
specs: 'compiled_spec/*spec.js'
181+
helpers: 'spec/*helper.js'
182+
vendor: [
183+
'node_modules/jasmine-jquery/vendor/jquery/jquery.js'
184+
'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
185+
]
170186
template: require('grunt-template-jasmine-istanbul')
171187
templateOptions:
172188
report:
@@ -188,9 +204,10 @@ module.exports = (grunt) ->
188204
grunt.registerTask 'compile-ts-core', CMP_CORE_NAME
189205

190206
# Register our tasks
191-
grunt.registerTask 'test', ['coffee', 'jasmine']
207+
grunt.registerTask 'test', ['coffee', 'jasmine:coverage']
192208
grunt.registerTask 'build-scripting', ['clean:scripting','concat:scripting_host', 'compile-ts-kagerou', 'copy:scripting_sandbox']
193209
grunt.registerTask 'build-core', ['compile-ts-core', 'concat:core_only', 'autoprefixer', 'cssmin', 'uglify:core_only']
194210
grunt.registerTask 'build', ['compile-ts-core', 'concat:all', 'autoprefixer', 'cssmin', 'uglify:all']
211+
grunt.registerTask 'ci', ['build', 'coffee', 'jasmine:ci']
195212
grunt.registerTask 'default', ['clean', 'build', 'build-scripting', 'watch']
196213

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"grunt-contrib-coffee": "~0.12.0",
2727
"grunt-contrib-jshint": "~0.10.0",
2828
"coveralls": "~2.11.0",
29+
"jasmine-jquery": "~2.0.0",
2930
"grunt-contrib-jasmine": "~0.8.0",
3031
"grunt-template-jasmine-istanbul": "~0.3.0",
3132
"load-grunt-tasks": "~0.6.0"

spec/CommentCoreLibrary_spec.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ describe 'CommentManager', ->
5050
manager.load [ c5, c2, c4, c1, c3 ]
5151
expect(manager.timeline).toEqual [c1, c2, c3, c4, c5]
5252

53+
it 'smoking test', ->
54+
jasmine.getFixtures().fixturesPath = "tests/"
55+
comments = AcfunParser(readFixtures 'ac940133.json')
56+
# TODO: Construct a json that cover all types of comments
57+
# and use it for smoking test
58+
manager.load comments
59+
expect(manager.timeline.length).toBe 1962
60+
5361
describe '.send', ->
5462
it 'sends to runline' , ->
5563
expect(manager.runline.length).toBe 0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict'
2+
3+
describe 'AnchorCommentSpaceAllocator', ->
4+
xit('TODO: add some examples to (or delete) it')
5+
6+
describe 'CommentSpaceAllocator', ->
7+
xit('TODO: add some examples to (or delete) it')

spec/core/Comment_spec.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict'
2+
3+
describe 'CoreComment', ->
4+
xit('TODO: add some examples to (or delete) it')
5+
6+
describe 'ScrollComment', ->
7+
xit('TODO: add some examples to (or delete) it')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict'
2+
describe 'SimpleFilter', ->
3+
xit('TODO: add some examples to (or delete) it')
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict'
2+
describe 'AcfunFormat', ->
3+
jasmine.getFixtures().fixturesPath = "tests/"
4+
it 'works', ->
5+
json = readFixtures 'ACFun.json'
6+
comments = AcfunParser(json)
7+
expect(comments.length).toBe 155
8+
expect(comments[0]).toEqual
9+
stime: 98200
10+
color: 16777215
11+
mode: 1
12+
size: 25
13+
hash: 'guest'
14+
date: 1315564729
15+
position: 'absolute'
16+
text: '我谢了你的爱'
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict'
2+
describe 'BilibiliFormat', ->
3+
jasmine.getFixtures().fixturesPath = "tests/"
4+
it 'parses normal comments', ->
5+
xml_text = readFixtures 'av207527.xml'
6+
comments = BilibiliParser(null, xml_text)
7+
expect(comments.length).toBe 12546
8+
expect(comments[0]).toEqual
9+
stime: 15105
10+
size: 25
11+
color: 16777215
12+
mode: 1
13+
date: 1388314569
14+
pool: 0
15+
position: 'absolute'
16+
dbid: 364586099
17+
hash: '1a87dd40'
18+
border: false
19+
text: '关了弹幕瞬间好多了'
20+
21+
it 'parses scripting comments', ->
22+
xml_text = readFixtures 'scripting/tsubasa.xml'
23+
comments = BilibiliParser(null, xml_text)
24+
expect(comments.length).toBe 654
25+
expect(comments[0].mode).toEqual 7
26+
expect(comments[653].mode).toEqual 8

spec/scripting/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)