diff options
| author | Igor Minar | 2011-01-04 00:46:25 -0800 |
|---|---|---|
| committer | Igor Minar | 2011-01-04 16:40:41 -0800 |
| commit | 3ea5941f0e51c57f55071a85f2033c23c99847c0 (patch) | |
| tree | 74b8b20178e96f13c5f3550740e35dcb68642a8a /test | |
| parent | d0270d92568e1b7c762b42a0ee0712b65d9acc5c (diff) | |
| download | angular.js-3ea5941f0e51c57f55071a85f2033c23c99847c0.tar.bz2 | |
removing support for 'eager-published' services
Diffstat (limited to 'test')
| -rw-r--r-- | test/BinderTest.js | 16 | ||||
| -rw-r--r-- | test/InjectorSpec.js | 16 | ||||
| -rw-r--r-- | test/ValidatorsTest.js | 2 | ||||
| -rw-r--r-- | test/servicesSpec.js | 46 |
4 files changed, 37 insertions, 43 deletions
diff --git a/test/BinderTest.js b/test/BinderTest.js index 58081f25..c5c81ee9 100644 --- a/test/BinderTest.js +++ b/test/BinderTest.js @@ -515,38 +515,38 @@ BinderTest.prototype.testValidateForm = function() { var items = [{}, {}]; c.scope.$set("items", items); c.scope.$eval(); - assertEquals(3, c.scope.$get("$invalidWidgets.length")); + assertEquals(3, c.scope.$inject('$invalidWidgets').length); c.scope.$set('name', ''); c.scope.$eval(); - assertEquals(3, c.scope.$get("$invalidWidgets.length")); + assertEquals(3, c.scope.$inject('$invalidWidgets').length); c.scope.$set('name', ' '); c.scope.$eval(); - assertEquals(3, c.scope.$get("$invalidWidgets.length")); + assertEquals(3, c.scope.$inject('$invalidWidgets').length); c.scope.$set('name', 'abc'); c.scope.$eval(); - assertEquals(2, c.scope.$get("$invalidWidgets.length")); + assertEquals(2, c.scope.$inject('$invalidWidgets').length); items[0].name = 'abc'; c.scope.$eval(); - assertEquals(1, c.scope.$get("$invalidWidgets.length")); + assertEquals(1, c.scope.$inject('$invalidWidgets').length); items[1].name = 'abc'; c.scope.$eval(); - assertEquals(0, c.scope.$get("$invalidWidgets.length")); + assertEquals(0, c.scope.$inject('$invalidWidgets').length); }; BinderTest.prototype.testValidateOnlyVisibleItems = function(){ var c = this.compile('<div><input name="name" ng:required><input ng:show="show" name="name" ng:required></div>', undefined, jqLite(document.body)); c.scope.$set("show", true); c.scope.$eval(); - assertEquals(2, c.scope.$get("$invalidWidgets.length")); + assertEquals(2, c.scope.$inject('$invalidWidgets').length); c.scope.$set("show", false); c.scope.$eval(); - assertEquals(1, c.scope.$invalidWidgets.visible()); + assertEquals(1, c.scope.$inject('$invalidWidgets').visible()); }; BinderTest.prototype.testDeleteAttributeIfEvaluatesFalse = function() { diff --git a/test/InjectorSpec.js b/test/InjectorSpec.js index ba0f27f7..275d98ff 100644 --- a/test/InjectorSpec.js +++ b/test/InjectorSpec.js @@ -53,19 +53,9 @@ describe('injector', function(){ it('should autostart eager services', function(){ var log = ''; - providers('eager', function(){log += 'eager;';}, {$creation: 'eager'}); + providers('eager', function(){log += 'eager;'; return 'foo'}, {$creation: 'eager'}); inject(); expect(log).toEqual('eager;'); - expect(scope.eager).not.toBeDefined(); + expect(inject('eager')).toBe('foo'); }); - - - it('should return a list of published objects', function(){ - var log = ''; - providers('eager', function(){log += 'eager;'; return 'pub'; }, {$creation: 'eager-published'}); - inject(); - expect(log).toEqual('eager;'); - expect(scope.eager).toEqual('pub'); - - }); -});
\ No newline at end of file +}); diff --git a/test/ValidatorsTest.js b/test/ValidatorsTest.js index f740c7b2..d6df7184 100644 --- a/test/ValidatorsTest.js +++ b/test/ValidatorsTest.js @@ -128,7 +128,7 @@ describe('Validator:asynchronous', function(){ it("should not make second request to same value", function(){ asynchronous.call(self, "kai", function(v,f){value=v; fn=f;}); expect(value).toEqual('kai'); - expect(self.$invalidWidgets[0]).toEqual(self.$element); + expect(self.$inject('$invalidWidgets')[0]).toEqual(self.$element); var spy = jasmine.createSpy(); asynchronous.call(self, "kai", spy); diff --git a/test/servicesSpec.js b/test/servicesSpec.js index 014acae4..e7bf39cb 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -24,7 +24,7 @@ describe("service", function(){ it("should inject $window", function(){ - expect(scope.$window).toEqual(window); + expect(scope.$inject('$window')).toEqual(window); }); xit('should add stylesheets', function(){ @@ -44,11 +44,12 @@ describe("service", function(){ function warn(){ logger+= 'warn;'; } function info(){ logger+= 'info;'; } function error(){ logger+= 'error;'; } - var scope = createScope({}, angularService, {$window: {console:{log:log, warn:warn, info:info, error:error}}, $document:[{cookie:''}]}); - scope.$log.log(); - scope.$log.warn(); - scope.$log.info(); - scope.$log.error(); + var scope = createScope({}, angularService, {$window: {console:{log:log, warn:warn, info:info, error:error}}, $document:[{cookie:''}]}), + $log = scope.$inject('$log'); + $log.log(); + $log.warn(); + $log.info(); + $log.error(); expect(logger).toEqual('log;warn;info;error;'); }); @@ -56,19 +57,21 @@ describe("service", function(){ var logger = ""; function log(){ logger+= 'log;'; } var scope = createScope({}, angularService, {$window: {console:{log:log}}, $document:[{cookie:''}]}); - scope.$log.log(); - scope.$log.warn(); - scope.$log.info(); - scope.$log.error(); + var $log = scope.$inject('$log'); + $log.log(); + $log.warn(); + $log.info(); + $log.error(); expect(logger).toEqual('log;log;log;log;'); }); it('should use noop if no console', function(){ - var scope = createScope({}, angularService, {$window: {}, $document:[{cookie:''}]}); - scope.$log.log(); - scope.$log.warn(); - scope.$log.info(); - scope.$log.error(); + var scope = createScope({}, angularService, {$window: {}, $document:[{cookie:''}]}), + $log = scope.$inject('$log'); + $log.log(); + $log.warn(); + $log.info(); + $log.error(); }); describe('Error', function(){ @@ -112,7 +115,7 @@ describe("service", function(){ it('should log errors', function(){ var error = ''; $log.error = function(m) { error += m; }; - scope.$exceptionHandler('myError'); + scope.$inject('$exceptionHandler')('myError'); expect(error).toEqual('myError'); }); }); @@ -263,25 +266,26 @@ describe("service", function(){ scope = compile('<input name="price" ng:required ng:validate="number"></input>'); jqLite(document.body).append(scope.$element); scope.$init(); - expect(scope.$invalidWidgets.length).toEqual(1); + var $invalidWidgets = scope.$inject('$invalidWidgets'); + expect($invalidWidgets.length).toEqual(1); scope.price = 123; scope.$eval(); - expect(scope.$invalidWidgets.length).toEqual(0); + expect($invalidWidgets.length).toEqual(0); scope.$element.remove(); scope.price = 'abc'; scope.$eval(); - expect(scope.$invalidWidgets.length).toEqual(0); + expect($invalidWidgets.length).toEqual(0); jqLite(document.body).append(scope.$element); scope.price = 'abcd'; //force revalidation, maybe this should be done automatically? scope.$eval(); - expect(scope.$invalidWidgets.length).toEqual(1); + expect($invalidWidgets.length).toEqual(1); jqLite(document.body).html(''); scope.$eval(); - expect(scope.$invalidWidgets.length).toEqual(0); + expect($invalidWidgets.length).toEqual(0); }); }); |
