Skip to content

Commit c962c9c

Browse files
committed
Update package.json dependencies, refactor tests to use Jasmine 2.0
1 parent 96d9275 commit c962c9c

File tree

5 files changed

+43
-35
lines changed

5 files changed

+43
-35
lines changed

gruntFile.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ module.exports = function (grunt) {
77
grunt.registerTask('default', ['jshint', 'karma']);
88

99
var karmaConfig = function(configFile, customOptions) {
10-
var options = { configFile: configFile, keepalive: true };
10+
var options = { configFile: configFile, singleRun: true };
1111
var travisOptions = process.env.TRAVIS && { browsers: ['Firefox'], reporters: 'dots' };
1212
return grunt.util._.extend(options, customOptions, travisOptions);
1313
};
1414

1515
// Project configuration.
1616
grunt.initConfig({
1717
karma: {
18-
unit: {
19-
options: karmaConfig('test/test.conf.js')
20-
}
18+
unit: karmaConfig('test/karma.conf.js')
2119
},
2220
jshint:{
2321
files:['src/**/*.js', 'test/**/*.js', 'demo/**/*.js'],

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
"main": "src/tinymce.js",
99
"dependencies": {},
1010
"devDependencies": {
11-
"grunt": "~0.4.1",
12-
"grunt-karma": "~0.4.4",
13-
"grunt-contrib-jshint": "~0.2.0"
11+
"grunt": "~0.4.4",
12+
"grunt-karma": "~0.8.2",
13+
"grunt-contrib-jshint": "~0.10.0",
14+
"karma-jasmine": "~0.2.2",
15+
"karma-chrome-launcher": "~0.1.3"
1416
},
1517
"scripts": {},
1618
"repository": {

test/karma.conf.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = function (config) {
2+
config.set({
3+
basePath: '..',
4+
frameworks: ['jasmine'],
5+
files: [
6+
'bower_components/angular/angular.js',
7+
'bower_components/angular-mocks/angular-mocks.js',
8+
'bower_components/tinymce/tinymce.min.js',
9+
'src/tinymce.js',
10+
{pattern: 'bower_components/tinymce/themes/modern/theme.min.js', served: true},
11+
'test/*.spec.js'
12+
],
13+
singleRun: false,
14+
autoWatch: true,
15+
browsers: [ 'Chrome' ],
16+
});
17+
};

test/test.conf.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/tinymce.spec.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,49 +22,53 @@ describe('uiTinymce', function () {
2222
* Asynchronously runs the compilation.
2323
*/
2424
function compile() {
25-
runs(function () {
26-
element = $compile('<form><textarea id="foo" ui-tinymce="{foo: \'bar\', setup: setupFooBar() }" ng-model="foo"></textarea></form>')(scope);
27-
angular.element(document.getElementsByTagName('body')[0]).append(element);
28-
});
25+
element = $compile('<form><textarea id="foo" ui-tinymce="{foo: \'bar\', setup: setupFooBar() }" ng-model="foo"></textarea></form>')(scope);
26+
angular.element(document.getElementsByTagName('body')[0]).append(element);
2927
scope.$apply();
30-
waits(1);
3128
}
3229

3330
describe('compiling this directive', function () {
3431

35-
it('should include the passed options', function () {
32+
it('should include the passed options', function (done) {
3633
spyOn(tinymce, 'init');
3734
compile();
38-
runs(function () {
35+
setTimeout(function () {
3936
expect(tinymce.init).toHaveBeenCalled();
40-
expect(tinymce.init.mostRecentCall.args[0].foo).toEqual('bar');
37+
expect(tinymce.init.calls.mostRecent().args[0].foo).toBe('bar');
38+
done();
4139
});
4240
});
4341

44-
it('should include the default options', function () {
42+
it('should include the default options', function (done) {
4543
spyOn(tinymce, 'init');
4644
compile();
47-
runs(function () {
45+
setTimeout(function () {
4846
expect(tinymce.init).toHaveBeenCalled();
49-
expect(tinymce.init.mostRecentCall.args[0].tinymce.bar).toEqual('baz');
47+
expect(tinymce.init.calls.mostRecent().args[0].tinymce.bar).toBe('baz');
48+
done();
5049
});
5150
});
5251

53-
it('should execute the passed `setup` option', function () {
52+
it('should execute the passed `setup` option', function (done) {
5453
scope.setupFooBar = jasmine.createSpy('setupFooBar');
5554
compile();
56-
runs(function () {
55+
setTimeout(function () {
5756
expect(scope.setupFooBar).toHaveBeenCalled();
57+
done();
5858
});
5959
});
6060
});
6161

62-
it('should remove tinymce instance on $scope destruction', function () {
62+
it('should remove tinymce instance on $scope destruction', function (done) {
6363
compile();
64-
runs(function () {
64+
setTimeout(function () {
6565
expect(tinymce.get('foo')).toBeTruthy();
66+
6667
scope.$destroy();
68+
6769
expect(tinymce.get('foo')).toBeUndefined();
70+
71+
done();
6872
});
6973
});
7074
/*

0 commit comments

Comments
 (0)