aboutsummaryrefslogtreecommitdiffstats
path: root/docs/component-spec/mocks.js
diff options
context:
space:
mode:
Diffstat (limited to 'docs/component-spec/mocks.js')
-rw-r--r--docs/component-spec/mocks.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/docs/component-spec/mocks.js b/docs/component-spec/mocks.js
new file mode 100644
index 00000000..143a1f39
--- /dev/null
+++ b/docs/component-spec/mocks.js
@@ -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;
+};