mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
test(docs): add missing createMockWindow()
Add missing angular.mock.createMockWindow (removed in
0dd062231a), that the docs tests were
using.
This commit is contained in:
parent
b73c46c2fd
commit
670ca75c8a
3 changed files with 32 additions and 3 deletions
|
|
@ -68,7 +68,7 @@ describe('Docs Annotations', function() {
|
|||
var $scope, parent, element, url, window;
|
||||
beforeEach(function() {
|
||||
module(function($provide, $animateProvider) {
|
||||
$provide.value('$window', window = angular.mock.createMockWindow());
|
||||
$provide.value('$window', window = createMockWindow());
|
||||
$animateProvider.register('.foldout', function($timeout) {
|
||||
return {
|
||||
enter : function(element, done) {
|
||||
|
|
@ -161,7 +161,7 @@ describe('Docs Annotations', function() {
|
|||
var window, $scope, ctrl;
|
||||
beforeEach(function() {
|
||||
module(function($provide, $animateProvider) {
|
||||
$provide.value('$window', window = angular.mock.createMockWindow());
|
||||
$provide.value('$window', window = createMockWindow());
|
||||
});
|
||||
inject(function($rootScope, $controller, $location, $cookies, sections) {
|
||||
$scope = $rootScope.$new();
|
||||
|
|
|
|||
29
docs/component-spec/mocks.js
Normal file
29
docs/component-spec/mocks.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
var createMockWindow = function() {
|
||||
var mockWindow = {};
|
||||
var setTimeoutQueue = [];
|
||||
|
||||
mockWindow.location = window.location;
|
||||
mockWindow.document = window.document;
|
||||
mockWindow.getComputedStyle = angular.bind(window, window.getComputedStyle);
|
||||
mockWindow.scrollTo = angular.bind(window, window.scrollTo);
|
||||
mockWindow.navigator = window.navigator;
|
||||
mockWindow.setTimeout = function(fn, delay) {
|
||||
setTimeoutQueue.push({fn: fn, delay: delay});
|
||||
};
|
||||
mockWindow.setTimeout.queue = setTimeoutQueue;
|
||||
mockWindow.setTimeout.expect = function(delay) {
|
||||
if (setTimeoutQueue.length > 0) {
|
||||
return {
|
||||
process: function() {
|
||||
var tick = setTimeoutQueue.shift();
|
||||
expect(tick.delay).toEqual(delay);
|
||||
tick.fn();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
expect('SetTimoutQueue empty. Expecting delay of ').toEqual(delay);
|
||||
}
|
||||
};
|
||||
|
||||
return mockWindow;
|
||||
};
|
||||
|
|
@ -22,7 +22,7 @@ describe('DocsApp', function() {
|
|||
'1.1.4',
|
||||
'2.1.3'
|
||||
]);
|
||||
$provide.value('$window', window = angular.mock.createMockWindow());
|
||||
$provide.value('$window', window = createMockWindow());
|
||||
});
|
||||
inject(function($controller, $rootScope) {
|
||||
$scope = $rootScope.$new();
|
||||
|
|
|
|||
Loading…
Reference in a new issue