diff options
| -rw-r--r-- | src/scenario/DSL.js | 14 | ||||
| -rw-r--r-- | src/scenario/Runner.js | 1 | ||||
| -rw-r--r-- | test/scenario/DSLSpec.js | 7 | ||||
| -rw-r--r-- | test/scenario/RunnerSpec.js | 24 | ||||
| -rw-r--r-- | test/scenario/TestContext.js | 8 |
5 files changed, 29 insertions, 25 deletions
diff --git a/src/scenario/DSL.js b/src/scenario/DSL.js index fe834835..d57a61df 100644 --- a/src/scenario/DSL.js +++ b/src/scenario/DSL.js @@ -5,7 +5,7 @@ angular.scenario.dsl.browser = { this.testFrame.load(function(){ self.testFrame.unbind(); self.testWindow = self.testFrame[0].contentWindow; - self.testDocument = jQuery(self.testWindow.document); + self.testDocument = self.jQuery(self.testWindow.document); self.$browser = self.testWindow.angular.service.$browser(); self.notifyWhenNoOutstandingRequests = bind(self.$browser, self.$browser.notifyWhenNoOutstandingRequests); @@ -53,17 +53,18 @@ angular.scenario.dsl.repeater = function(selector) { }, collect: function() { return $scenario.addFuture(namePrefix + ' collect', function(done) { + var self = this; var doCollect = bind(this, function() { var repeaterArray = []; this.testDocument.find(selector).each(function(index) { - var element = angular.extend(_jQuery(this), + var element = angular.extend(self.jQuery(this), {bindings: [], boundTo: function(name) { return this.bindings[name]; }} ); element.find('*').each(function(index) { - var bindName = _jQuery(this).attr('ng:bind'); + var bindName = self.jQuery(this).attr('ng:bind'); if (bindName) { - element.bindings[bindName] = _jQuery(this).text(); + element.bindings[bindName] = self.jQuery(this).text(); } }); repeaterArray[index] = element; @@ -79,14 +80,15 @@ angular.scenario.dsl.repeater = function(selector) { angular.scenario.dsl.element = function(selector) { var nameSuffix = "element '" + selector + "'"; return $scenario.addFuture('Find ' + nameSuffix, function(done) { + var self = this; var element = angular.extend(this.testDocument.find(selector), { bindings: [], boundTo: function(name) { return this.bindings[name]; } }); element.find('*').each(function(index) { - var bindName = _jQuery(this).attr('ng:bind'); + var bindName = self.jQuery(this).attr('ng:bind'); if (bindName) { - element.bindings[bindName] = _jQuery(this).text(); + element.bindings[bindName] = self.jQuery(this).text(); } }); done(element); diff --git a/src/scenario/Runner.js b/src/scenario/Runner.js index 13dfbe7d..ac32559c 100644 --- a/src/scenario/Runner.js +++ b/src/scenario/Runner.js @@ -134,6 +134,7 @@ angular.scenario.Runner.prototype = { }, specThis = createScope({ result: result, + jQuery: this.jQuery, testFrame: this.testFrame, testWindow: this.testWindow }, angularService, {}); diff --git a/test/scenario/DSLSpec.js b/test/scenario/DSLSpec.js index a6a291f8..374f49c8 100644 --- a/test/scenario/DSLSpec.js +++ b/test/scenario/DSLSpec.js @@ -5,15 +5,16 @@ describe("DSL", function() { beforeEach(function() { setUpContext(); executeFuture = function(future, html, callback) { - lastDocument =_jQuery('<div>' + html + '</div>'); + lastDocument = _jQuery('<div>' + html + '</div>'); _jQuery(document.body).append(lastDocument); var specThis = { testWindow: window, - testDocument: lastDocument + testDocument: lastDocument, + jQuery: _jQuery }; future.behavior.call(specThis, callback || noop); }; - Expect = scenario.expect; + Expect = _window.expect; }); describe("input", function() { diff --git a/test/scenario/RunnerSpec.js b/test/scenario/RunnerSpec.js index 2eb13f7f..b12c43c6 100644 --- a/test/scenario/RunnerSpec.js +++ b/test/scenario/RunnerSpec.js @@ -4,10 +4,10 @@ describe('Runner', function() { beforeEach(function() { setUpContext(); - Describe = scenario.describe; - It = scenario.it; - BeforeEach = scenario.beforeEach; - AfterEach = scenario.afterEach; + Describe = _window.describe; + It = _window.it; + BeforeEach = _window.beforeEach; + AfterEach = _window.afterEach; body = _jQuery('<div></div>'); }); @@ -101,7 +101,7 @@ describe('Runner', function() { }); $scenario.run(body); expect(log).toEqual('future1;after;future2;after;'); - expect(scenario.$testrun.results).toEqual([ + expect(_window.$testrun.results).toEqual([ { name : 'describe name: it should text1', passed : false, error : 'AfterError', @@ -186,7 +186,7 @@ describe('Runner', function() { expect(spec.result.failed).toEqual(true); expect(spec.result.finished).toEqual(true); expect(spec.result.error).toEqual("MyError"); - expect(scenario.$testrun.results).toEqual([{ + expect(_window.$testrun.results).toEqual([{ name: 'spec', passed: false, error: 'MyError', @@ -217,16 +217,16 @@ describe('Runner', function() { expect(log).toEqual('s1,s2,s3,s4,'); }); it('should publish done state and results as tests are run', function() { - expect(scenario.$testrun.done).toBeFalsy(); - expect(scenario.$testrun.results).toEqual([]); + expect(_window.$testrun.done).toBeFalsy(); + expect(_window.$testrun.results).toEqual([]); $scenario.run(body); - expect(scenario.$testrun.done).toBeFalsy(); - expect(scenario.$testrun.results).toEqual([ + expect(_window.$testrun.done).toBeFalsy(); + expect(_window.$testrun.results).toEqual([ {name: 'd1: it it1', passed: true, error: undefined, steps: ['s1']} ]); next(); - expect(scenario.$testrun.done).toBeTruthy(); - expect(scenario.$testrun.results).toEqual([ + expect(_window.$testrun.done).toBeTruthy(); + expect(_window.$testrun.results).toEqual([ {name: 'd1: it it1', passed: true, error: undefined, steps: ['s1']}, {name: 'd1: it it2', passed: true, error: undefined, steps: ['s2', 's2.2']}, {name: 'd2: it it3', passed: true, error: undefined, steps: ['s3']}, diff --git a/test/scenario/TestContext.js b/test/scenario/TestContext.js index ebb40b95..0c8e6143 100644 --- a/test/scenario/TestContext.js +++ b/test/scenario/TestContext.js @@ -1,4 +1,4 @@ -var scenario, runner, log, $scenario; +var _window, runner, log, $scenario; function logger(text) { return function(done){ @@ -8,8 +8,8 @@ function logger(text) { } function setUpContext() { - scenario = {}; - runner = new angular.scenario.Runner(scenario, _jQuery); - $scenario = scenario.$scenario; + _window = {}; + runner = new angular.scenario.Runner(_window, _jQuery); + $scenario = _window.$scenario; log = ''; } |
