Skip to content

Commit ad2b482

Browse files
add tests specific for angular 1.4
1 parent 542b42d commit ad2b482

5 files changed

+111
-12
lines changed

Gruntfile.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ module.exports = function(grunt) {
5151
dir: 'coverage/'
5252
}
5353
},
54+
unit14: {
55+
configFile: 'test/karma-angular-1.4.conf.js',
56+
singleRun: true,
57+
coverageReporter: {
58+
type: 'text',
59+
dir: 'coverage/'
60+
}
61+
},
5462
watch: {
5563
configFile: 'test/karma-angular-1.2.conf.js',
5664
singleRun: false,
@@ -87,7 +95,7 @@ module.exports = function(grunt) {
8795
grunt.loadNpmTasks('grunt-contrib-concat');
8896
grunt.loadNpmTasks('grunt-karma');
8997

90-
grunt.registerTask('default', ['jshint', 'karma:unit', 'karma:unit13', 'uglify', 'cssmin', 'concat:build']);
98+
grunt.registerTask('default', ['jshint', 'karma:unit', 'karma:unit13', 'karma:unit14', 'uglify', 'cssmin', 'concat:build']);
9199
grunt.registerTask('test', ['karma:watch']);
92100
grunt.registerTask('build', ['default']);
93101

bower.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
"devDependencies": {
1818
"angular": "~1.2.23",
1919
"angular-1.3": "angular#1.3",
20+
"angular-1.4": "angular#1.4",
2021
"angular-mocks": "~1.2.9",
2122
"angular-mocks-1.3": "angular-mocks#1.3",
23+
"angular-mocks-1.4": "angular-mocks#1.4",
2224
"angular-animate": "~1.2.9",
23-
"angular-animate-1.3": "angular-animate#1.3"
25+
"angular-animate-1.3": "angular-animate#1.3",
26+
"angular-animate-1.4": "angular-animate#1.4"
2427
},
2528
"resolutions": {
2629
"angular": "~1.2.23"

example/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<html>
33
<head>
44
<!-- angular -->
5-
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
6-
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-animate.min.js"></script>
5+
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
6+
<!-- <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-animate.min.js"></script> -->
77

88
<!-- loadingbar -->
99
<script src="../src/loading-bar.js"></script>

test/karma-angular-1.4.conf.js

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Karma configuration
2+
// Generated on Sun Sep 15 2013 20:18:09 GMT-0400 (EDT)
3+
4+
module.exports = function(config) {
5+
config.set({
6+
7+
// base path, that will be used to resolve files and exclude
8+
basePath: '',
9+
10+
11+
// frameworks to use
12+
frameworks: ['jasmine'],
13+
14+
15+
// list of files / patterns to load in the browser
16+
files: [
17+
'../bower_components/angular-1.4/angular.js',
18+
'../bower_components/angular-animate-1.4/angular-animate.js',
19+
'../bower_components/angular-mocks-1.4/angular-mocks.js',
20+
'../src/*.js',
21+
'*.coffee'
22+
],
23+
24+
25+
// list of files to exclude
26+
exclude: [
27+
28+
],
29+
30+
31+
// test results reporter to use
32+
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
33+
reporters: ['progress', 'coverage'],
34+
35+
36+
// web server port
37+
port: 9876,
38+
39+
40+
// enable / disable colors in the output (reporters and logs)
41+
colors: true,
42+
43+
44+
// level of logging
45+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
46+
logLevel: config.LOG_INFO,
47+
48+
49+
// enable / disable watching file and executing tests whenever any file changes
50+
autoWatch: true,
51+
52+
53+
// Start these browsers, currently available:
54+
// - Chrome
55+
// - ChromeCanary
56+
// - Firefox
57+
// - Opera
58+
// - Safari (only Mac)
59+
// - PhantomJS
60+
// - IE (only Windows)
61+
browsers: ['PhantomJS'],
62+
63+
coverageReporter: {
64+
type : 'html',
65+
dir : 'coverage/',
66+
},
67+
68+
preprocessors: {
69+
'../src/*.js': ['coverage'],
70+
'*.coffee': 'coffee'
71+
},
72+
73+
74+
// If browser does not capture in given timeout [ms], kill it
75+
captureTimeout: 60000,
76+
77+
78+
// Continuous Integration mode
79+
// if true, it capture browsers, run tests and exit
80+
singleRun: false
81+
});
82+
};

test/loading-bar-interceptor.coffee

+14-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ isLoadingBarInjected = (doc) ->
77
break
88
return injected
99

10+
flush = null
11+
1012
describe 'loadingBarInterceptor Service', ->
1113

1214
$http = $httpBackend = $document = $timeout = result = loadingBar = $animate = null
@@ -26,6 +28,11 @@ describe 'loadingBarInterceptor Service', ->
2628
$timeout = _$timeout_
2729
$animate = _$animate_
2830

31+
# Angular 1.4 removed triggerCalbacks(), so try them both:
32+
flush = () ->
33+
$animate.flush && $animate.flush()
34+
$animate.triggerCallbacks && $animate.triggerCallbacks()
35+
2936
beforeEach ->
3037
this.addMatchers
3138
toBeBetween: (high, low) ->
@@ -54,7 +61,7 @@ describe 'loadingBarInterceptor Service', ->
5461
expect(cfpLoadingBar.status()).toBe 1
5562
cfpLoadingBar.complete() # set as complete
5663
$timeout.flush()
57-
$animate.triggerCallbacks()
64+
flush()
5865

5966

6067
$http.get(endpoint, cache: cache).then (data) ->
@@ -77,7 +84,7 @@ describe 'loadingBarInterceptor Service', ->
7784
expect(cfpLoadingBar.status()).toBe 1
7885
cfpLoadingBar.complete() # set as complete
7986
$timeout.flush()
80-
$animate.triggerCallbacks()
87+
flush()
8188

8289

8390
$http.get(endpoint).then (data) ->
@@ -99,7 +106,7 @@ describe 'loadingBarInterceptor Service', ->
99106
expect(cfpLoadingBar.status()).toBe 1
100107
cfpLoadingBar.complete() # set as complete
101108
$timeout.flush()
102-
$animate.triggerCallbacks()
109+
flush()
103110

104111

105112
$http.get(endpoint, cache: true).then (data) ->
@@ -123,7 +130,7 @@ describe 'loadingBarInterceptor Service', ->
123130
expect(cfpLoadingBar.status()).toBe 1
124131
cfpLoadingBar.complete() # set as complete
125132
$timeout.flush()
126-
$animate.triggerCallbacks()
133+
flush()
127134

128135

129136
$http.get(endpoint).then (data) ->
@@ -144,7 +151,7 @@ describe 'loadingBarInterceptor Service', ->
144151
$httpBackend.flush(1)
145152
expect(cfpLoadingBar.status()).toBe 1
146153
$timeout.flush()
147-
$animate.triggerCallbacks()
154+
flush()
148155

149156

150157
$httpBackend.expectPOST(endpoint).respond response
@@ -383,7 +390,7 @@ describe 'loadingBarInterceptor Service', ->
383390
expect(startedEventCalled).toBe 1 # Should still be one, as complete was never called:
384391
cfpLoadingBar.complete()
385392
$timeout.flush()
386-
$animate.triggerCallbacks()
393+
flush()
387394

388395

389396
cfpLoadingBar.start()
@@ -478,13 +485,12 @@ describe 'LoadingBar only', ->
478485
cfpLoadingBar.complete()
479486
cfpLoadingBar.start()
480487
$timeout.flush()
481-
$animate.triggerCallbacks()
482488

483489
expect(isLoadingBarInjected($document.find(cfpLoadingBar.parentSelector))).toBe true
484490

485491
cfpLoadingBar.complete()
486492
$timeout.flush()
487-
$animate.triggerCallbacks()
493+
flush()
488494

489495
expect(isLoadingBarInjected($document.find(cfpLoadingBar.parentSelector))).toBe false
490496

0 commit comments

Comments
 (0)