aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/scenario/ApplicationSpec.js17
-rw-r--r--test/scenario/dslSpec.js20
-rw-r--r--test/scenario/mocks.js16
3 files changed, 23 insertions, 30 deletions
diff --git a/test/scenario/ApplicationSpec.js b/test/scenario/ApplicationSpec.js
index 8caf1651..86023438 100644
--- a/test/scenario/ApplicationSpec.js
+++ b/test/scenario/ApplicationSpec.js
@@ -112,22 +112,20 @@ describe('angular.scenario.Application', function() {
expect(called).toBeTruthy();
});
- it('should wait for pending requests in executeAction', function() {
+ it('should wait for pending requests in executeAction', inject(function($injector, $browser) {
var called, polled;
var handlers = [];
var testWindow = {
- document: _jQuery('<div class="test-foo"></div>'),
+ document: jqLite('<div class="test-foo"></div>'),
angular: {
+ element: jqLite,
service: {}
}
};
- testWindow.angular.service.$browser = function() {
- return {
- notifyWhenNoOutstandingRequests: function(fn) {
- handlers.push(fn);
- }
- };
+ $browser.notifyWhenNoOutstandingRequests = function(fn) {
+ handlers.push(fn);
};
+ testWindow.document.data('$injector', $injector);
app.getWindow_ = function() {
return testWindow;
};
@@ -138,5 +136,6 @@ describe('angular.scenario.Application', function() {
});
expect(handlers.length).toEqual(1);
handlers[0]();
- });
+ dealoc(testWindow.document);
+ }));
});
diff --git a/test/scenario/dslSpec.js b/test/scenario/dslSpec.js
index 411320e8..29956801 100644
--- a/test/scenario/dslSpec.js
+++ b/test/scenario/dslSpec.js
@@ -4,13 +4,14 @@ describe("angular.scenario.dsl", function() {
var $window, $root;
var application, eventLog;
- beforeEach(function() {
+ beforeEach(inject(function($injector) {
eventLog = [];
$window = {
- document: _jQuery("<div></div>"),
+ document: jqLite('<div class="document"></div>'),
angular: new angular.scenario.testing.MockAngular()
};
- $root = angular.injector('NG')('$rootScope');
+ $window.document.data('$injector', $injector);
+ $root = $injector('$rootScope');
$root.emit = function(eventName) {
eventLog.push(eventName);
};
@@ -45,6 +46,10 @@ describe("angular.scenario.dsl", function() {
// Just use the real one since it delegates to this.addFuture
$root.addFutureAction = angular.scenario.
SpecRunner.prototype.addFutureAction;
+ }));
+
+ afterEach(function(){
+ jqLite($window.document).removeData('$injector');
});
describe('Pause', function() {
@@ -201,11 +206,14 @@ describe("angular.scenario.dsl", function() {
// ex. jQuery('#foo').find('[name="bar"]') // fails
// ex. jQuery('#foo [name="bar"]') // works, wtf?
//
- beforeEach(function() {
+ beforeEach(inject(function($injector) {
doc = _jQuery('<div id="angular-scenario-binding"></div>');
_jQuery(document.body).html('').append(doc);
- $window.document = window.document;
- });
+
+ dealoc($window.document); // we are about to override it
+ $window.document = window.document;
+ jqLite($window.document).data('$injector', $injector);
+ }));
afterEach(function() {
_jQuery(document.body).
diff --git a/test/scenario/mocks.js b/test/scenario/mocks.js
index 2db8577a..e135390f 100644
--- a/test/scenario/mocks.js
+++ b/test/scenario/mocks.js
@@ -4,32 +4,18 @@ angular.scenario.testing = angular.scenario.testing || {};
angular.scenario.testing.MockAngular = function() {
this.reset();
- this.service = this;
+ this.element = jqLite;
};
angular.scenario.testing.MockAngular.prototype.reset = function() {
this.log = [];
};
-angular.scenario.testing.MockAngular.prototype.element = function(e) {
- return jqLite(e);
-};
-
-angular.scenario.testing.MockAngular.prototype.$browser = function() {
- this.log.push('$brower()');
- return this;
-};
-
angular.scenario.testing.MockAngular.prototype.poll = function() {
this.log.push('$brower.poll()');
return this;
};
-angular.scenario.testing.MockAngular.prototype.notifyWhenNoOutstandingRequests = function(fn) {
- this.log.push('$brower.notifyWhenNoOutstandingRequests()');
- fn();
-};
-
angular.scenario.testing.MockRunner = function() {
this.listeners = [];
};