Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 0c3ed43

Browse files
committed
Merge pull request #81 from angular-ui/chore-devDep-update
Chore dev dep update
2 parents 0a061f4 + 069e47a commit 0c3ed43

File tree

3 files changed

+98
-145
lines changed

3 files changed

+98
-145
lines changed

gruntFile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = function (grunt) {
77
// Default task.
88
grunt.registerTask('default', ['jshint', 'karma:unit']);
99
grunt.registerTask('serve', ['karma:continuous', 'dist', 'build:gh-pages', 'connect:continuous', 'watch']);
10-
grunt.registerTask('dist', ['ngmin', 'uglify']);
10+
grunt.registerTask('dist', ['ngAnnotate', 'uglify']);
1111

1212

1313
// HACK TO ACCESS TO THE COMPONENT-PUBLISHER
@@ -133,7 +133,7 @@ module.exports = function (grunt) {
133133
}
134134
},
135135

136-
ngmin: {
136+
ngAnnotate: {
137137
main: {
138138
expand: true,
139139
cwd: 'src',

package.json

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
{
32
"name": "angular-ui-ace",
43
"version": "0.1.2",
@@ -10,29 +9,27 @@
109
"dependencies": {},
1110
"devDependencies": {
1211
"angular-ui-publisher": "~1.x",
13-
"grunt": "~0.4.2",
14-
"grunt-contrib-copy": "~0.4.1",
15-
"grunt-contrib-jshint": "~0.7.2",
16-
"grunt-karma": "~0.6.2",
17-
"grunt-contrib-uglify": "~0.2.7",
18-
"grunt-contrib-watch": "~0.5.3",
19-
"load-grunt-tasks": "~0.2.0",
20-
"karma-script-launcher": "~0.1.0",
21-
"karma-chrome-launcher": "~0.1.1",
22-
"karma-html2js-preprocessor": "~0.1.0",
23-
"karma-firefox-launcher": "~0.1.2",
24-
"karma-jasmine": "~0.1.4",
25-
"karma-coffee-preprocessor": "~0.1.1",
26-
"requirejs": "~2.1.9",
27-
"karma-requirejs": "~0.2.0",
28-
"karma-phantomjs-launcher": "~0.1.1",
29-
"karma": "~0.10.8",
30-
"karma-coverage": "~0.2.6",
31-
"grunt-conventional-changelog": "~1.0.0",
32-
"grunt-ngmin": "0.0.3",
33-
"grunt-contrib-connect": "~0.5.0"
12+
"grunt": "~0.4.5",
13+
"grunt-contrib-connect": "~0.9.0",
14+
"grunt-contrib-copy": "~0.7.0",
15+
"grunt-contrib-jshint": "~0.10.0",
16+
"grunt-contrib-uglify": "~0.7.0",
17+
"grunt-contrib-watch": "~0.6.1",
18+
"grunt-conventional-changelog": "~1.1.0",
19+
"grunt-karma": "~0.9.0",
20+
"grunt-ng-annotate": "^0.8.0",
21+
"jasmine-core": "^2.1.3",
22+
"karma": "~0.12.31",
23+
"karma-chrome-launcher": "~0.1.7",
24+
"karma-coverage": "~0.2.7",
25+
"karma-firefox-launcher": "~0.1.4",
26+
"karma-jasmine": "~0.3.4",
27+
"karma-phantomjs-launcher": "~0.1.4",
28+
"load-grunt-tasks": "~2.0.0"
29+
},
30+
"scripts": {
31+
"test": "grunt"
3432
},
35-
"scripts": {},
3633
"repository": {
3734
"type": "git",
3835
"url": "git://github.com/angular-ui/ui-ace.git"

test/ace.spec.js

Lines changed: 76 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,106 @@
11
describe('uiAce', function () {
22
'use strict';
33

4-
// declare these up here to be global to all tests
5-
var scope, $compile, uiConfig;
6-
7-
beforeEach(module('ui.ace'));
8-
beforeEach(inject(function (uiAceConfig) {
9-
uiConfig = uiAceConfig;
10-
uiConfig.ace = {showGutter: false};
11-
}));
12-
13-
// inject in angular constructs. Injector knows about leading/trailing underscores and does the right thing
14-
// otherwise, you would need to inject these into each test
15-
beforeEach(inject(function (_$rootScope_, _$compile_) {
16-
scope = _$rootScope_.$new();
17-
$compile = _$compile_;
18-
}));
4+
var scope, $compile,
5+
uiConfig;
6+
7+
beforeEach(function () {
8+
9+
module('ui.ace');
10+
11+
inject(function (_$rootScope_, _$compile_, uiAceConfig) {
12+
scope = _$rootScope_.$new();
13+
$compile = _$compile_;
14+
uiConfig = uiAceConfig;
15+
uiConfig.ace = { showGutter: false };
16+
});
17+
});
1918

2019
afterEach(function () {
2120
uiConfig = {};
2221
});
2322

24-
describe('behavior', function () {
25-
var _ace;
23+
describe('require', function () {
24+
var aceRequireFunction;
2625

2726
beforeEach(function () {
28-
_ace = window.ace;
29-
spyOn(window.ace, 'require');
27+
aceRequireFunction = window.ace.edit;
28+
window.ace.require = jasmine
29+
.createSpy('window.ace.require');
3030
});
31-
it('should not call ace/config if a workerPath is not defined', function () {
32-
$compile('<div ui-ace>')(scope);
33-
expect(_ace.require).not.toHaveBeenCalledWith('ace/config');
31+
32+
afterEach(function () {
33+
window.ace.require = aceRequireFunction;
3434
});
35-
});
3635

37-
describe('behavior', function () {
38-
var _ace, _config;
36+
it('should not call window.ace.require if there is no "require" option', function () {
37+
$compile('<div ui-ace>')(scope);
38+
expect(window.ace.require).not.toHaveBeenCalled();
39+
});
3940

40-
beforeEach(function () {
41-
_ace = window.ace;
42-
_config = {
43-
set: function() { return true; }
44-
};
45-
spyOn(window.ace, 'require').andReturn(_config);
41+
it('should not call ace/config if a workerPath is not defined', function () {
42+
$compile('<div ui-ace>')(scope);
43+
expect(window.ace.require).not.toHaveBeenCalledWith('ace/config');
4644
});
45+
4746
it('should call ace/config if a workerPath is defined', function () {
47+
window.ace.require
48+
.and.returnValue({
49+
set: function () {}
50+
});
51+
////
4852
$compile('<div ui-ace=\'{ workerPath: "/path/to/ace" }\'>')(scope);
49-
expect(_ace.require).toHaveBeenCalledWith('ace/config');
53+
expect(window.ace.require).toHaveBeenCalledWith('ace/config');
5054
});
51-
});
5255

53-
describe('behavior', function () {
54-
var _ace, _config;
55-
56-
beforeEach(function () {
57-
_ace = window.ace;
58-
_config = {
59-
set: function() { return true; }
60-
};
61-
spyOn(window.ace, 'require').andReturn(_config);
62-
spyOn(_config, 'set');
63-
});
6456
it('should call "set" if workerPath is defined', function () {
57+
var _config = jasmine.createSpyObj('config', ['set']);
58+
window.ace.require.and.returnValue(_config);
59+
////
6560
$compile('<div ui-ace=\'{ workerPath: "/path/to/ace" }\'>')(scope);
6661
expect(_config.set).toHaveBeenCalled();
6762
});
68-
});
69-
70-
describe('behavior', function () {
71-
var _ace;
7263

73-
beforeEach(function () {
74-
_ace = window.ace;
75-
spyOn(window.ace, 'require');
76-
});
77-
it('should not call window.ace.require if there is no "require" option', function () {
78-
$compile('<div ui-ace>')(scope);
79-
expect(_ace.require).not.toHaveBeenCalled();
80-
});
81-
});
82-
83-
describe('behavior', function () {
84-
var _ace;
85-
86-
beforeEach(function () {
87-
_ace = window.ace;
88-
spyOn(window.ace, 'require');
89-
});
9064
it('should call "window.ace.require" for each option in "require"', function () {
9165
$compile('<div ui-ace=\'{ require: ["ace/ext/language_tools", "ace/ext/static_highlight"]}\'>')(scope);
92-
expect(_ace.require).toHaveBeenCalled();
93-
expect(_ace.require.callCount).toEqual(2);
66+
expect(window.ace.require).toHaveBeenCalled();
67+
expect(window.ace.require.calls.count()).toEqual(2);
9468
});
9569
});
9670

97-
describe('behavior', function () {
98-
var _ace;
71+
describe('options', function () {
72+
var _ace, aceEditFunction;
9973

10074
beforeEach(function () {
101-
var aceEditFunction = window.ace.edit;
102-
spyOn(window.ace, 'edit').andCallFake(function () {
103-
_ace = aceEditFunction.apply(this, arguments);
104-
return _ace;
105-
});
106-
});
107-
it('should not call "setOption" if no "advanced" options are given.', function () {
108-
$compile('<div ui-ace>')(scope);
109-
var session = _ace.getSession();
110-
spyOn(session, 'setOption');
111-
expect(session.setOption).not.toHaveBeenCalled();
75+
aceEditFunction = window.ace.edit;
76+
window.ace.edit = jasmine
77+
.createSpy('window.ace.edit')
78+
.and.callFake(function () {
79+
_ace = aceEditFunction.apply(this, arguments);
80+
_ace.setOption = jasmine
81+
.createSpy('ace.setOption')
82+
.and.callThrough();
83+
return _ace;
84+
});
11285
});
113-
});
114-
115-
describe('behavior', function () {
116-
var _ace;
11786

118-
beforeEach(function () {
119-
var aceEditFunction = window.ace.edit;
120-
spyOn(window.ace, 'edit').andCallFake(function () {
121-
_ace = aceEditFunction.apply(this, arguments);
122-
return _ace;
123-
});
87+
afterEach(function () {
88+
window.ace.edit = aceEditFunction;
12489
});
90+
12591
it('Given advanced option is null if not defined.', function () {
12692
$compile('<div ui-ace>')(scope);
127-
var session = _ace.getSession();
128-
spyOn(session, 'getOption');
129-
expect(session.getOption).toBeDefined();
130-
expect(session.getOption('enableSnippets')).not.toBeDefined();
93+
expect(_ace.setOption.calls.count()).toEqual(0);
13194
});
132-
});
133-
134-
describe('behavior', function () {
135-
var _ace;
13695

137-
beforeEach(function () {
138-
var aceEditFunction = window.ace.edit;
139-
spyOn(window.ace, 'edit').andCallFake(function () {
140-
_ace = aceEditFunction.apply(this, arguments);
141-
return _ace;
142-
});
143-
});
14496
it('given advanced options are properly defined.', function () {
14597
$compile('<div ui-ace=\'{ advanced: { enableSnippets: true } }\'>')(scope);
146-
var session = _ace.getSession();
147-
spyOn(session, 'getOption');
148-
expect(session.getOption).toBeDefined();
149-
expect(session.getOption('enableSnippets')).not.toBe(null);
98+
expect(_ace.setOption.calls.count()).toEqual(1);
99+
expect(_ace.setOption).toHaveBeenCalledWith('enableSnippets', true);
150100
});
151101
});
152102

153-
describe('behavior', function () {
103+
describe('basic behavior', function () {
154104

155105
it('should not throw an error when window.ace is defined', function () {
156106
function compile() {
@@ -160,7 +110,6 @@ describe('uiAce', function () {
160110
expect(compile).not.toThrow();
161111
});
162112

163-
164113
it('should watch the uiAce attribute', function () {
165114
spyOn(scope, '$watch');
166115
$compile('<div ui-ace ng-model="foo">')(scope);
@@ -169,15 +118,20 @@ describe('uiAce', function () {
169118
});
170119

171120
describe('instance', function () {
172-
var _ace;
173-
121+
var _ace, aceEditFunction;
174122

175123
beforeEach(function () {
176-
var aceEditFunction = window.ace.edit;
177-
spyOn(window.ace, 'edit').andCallFake(function () {
178-
_ace = aceEditFunction.apply(this, arguments);
179-
return _ace;
180-
});
124+
aceEditFunction = window.ace.edit;
125+
window.ace.edit = jasmine
126+
.createSpy('window.ace.edit')
127+
.and.callFake(function () {
128+
_ace = aceEditFunction.apply(this, arguments);
129+
return _ace;
130+
});
131+
});
132+
133+
afterEach(function () {
134+
window.ace.edit = aceEditFunction;
181135
});
182136

183137
it('should call ace.edit', function () {
@@ -286,8 +240,10 @@ describe('uiAce', function () {
286240

287241
it('should call destroy when the element is removed', function () {
288242
var element = $compile('<div ui-ace ng-model="foo">')(scope);
289-
spyOn(_ace, 'destroy').andCallThrough();
290-
spyOn(_ace.session, '$stopWorker').andCallThrough();
243+
_ace.destroy = jasmine.createSpy('ace.destroy')
244+
.and.callThrough();
245+
_ace.session.$stopWorker = jasmine.createSpy('ace.session.$stopWorker')
246+
.and.callThrough();
291247

292248
element.remove();
293249
scope.$apply();

0 commit comments

Comments
 (0)