mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-24 18:30:23 +00:00
feat(mocks.$browser): add simple addJs() method into $browser mock
This commit is contained in:
parent
4d2d70e7fb
commit
540701a8d8
2 changed files with 33 additions and 0 deletions
7
src/angular-mocks.js
vendored
7
src/angular-mocks.js
vendored
|
|
@ -300,6 +300,13 @@ angular.module.ngMock.$Browser = function() {
|
|||
self.baseHref = function() {
|
||||
return this.$$baseHref;
|
||||
};
|
||||
|
||||
self.$$scripts = [];
|
||||
self.addJs = function(url, domId, done) {
|
||||
var script = {url: url, id: domId, done: done};
|
||||
self.$$scripts.push(script);
|
||||
return script;
|
||||
};
|
||||
}
|
||||
angular.module.ngMock.$Browser.prototype = {
|
||||
|
||||
|
|
|
|||
26
test/angular-mocksSpec.js
vendored
26
test/angular-mocksSpec.js
vendored
|
|
@ -1,6 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
describe('mocks', function() {
|
||||
|
||||
describe('$browser', function() {
|
||||
|
||||
describe('addJs', function() {
|
||||
|
||||
it('should store url, id, done', inject(function($browser) {
|
||||
var url = 'some.js',
|
||||
id = 'js-id',
|
||||
done = noop;
|
||||
|
||||
$browser.addJs(url, id, done);
|
||||
|
||||
var script = $browser.$$scripts.shift();
|
||||
expect(script.url).toBe(url);
|
||||
expect(script.id).toBe(id);
|
||||
expect(script.done).toBe(done);
|
||||
}));
|
||||
|
||||
|
||||
it('should return the script object', inject(function($browser) {
|
||||
expect($browser.addJs('some.js', null, noop)).toBe($browser.$$scripts[0]);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('TzDate', function() {
|
||||
|
||||
function minutes(min) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue