diff --git a/docs/content/cookbook/advancedform.ngdoc b/docs/content/cookbook/advancedform.ngdoc index bcf8069a1072..8b02cae6ab60 100644 --- a/docs/content/cookbook/advancedform.ngdoc +++ b/docs/content/cookbook/advancedform.ngdoc @@ -89,25 +89,31 @@ detection, and preventing invalid form submission.
form={{form}}
- + + var saveButton = element(by.css('[ng-click="save()"]')); + var cancelButton = element(by.css('[ng-click="cancel()"]')); + var nameInput = element(by.model('form.name')); + it('should enable save button', function() { - expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy(); - input('form.name').enter(''); - expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy(); - input('form.name').enter('change'); - expect(element(':button:contains(Save)').attr('disabled')).toBeFalsy(); - element(':button:contains(Save)').click(); - expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy(); + expect(saveButton.getAttribute('disabled')).toBeTruthy(); + nameInput.clear(); + nameInput.sendKeys(''); + expect(saveButton.getAttribute('disabled')).toBeTruthy(); + nameInput.sendKeys('change'); + saveButton.click(); + expect(saveButton.getAttribute('disabled')).toBeTruthy(); }); + it('should enable cancel button', function() { - expect(element(':button:contains(Cancel)').attr('disabled')).toBeTruthy(); - input('form.name').enter('change'); - expect(element(':button:contains(Cancel)').attr('disabled')).toBeFalsy(); - element(':button:contains(Cancel)').click(); - expect(element(':button:contains(Cancel)').attr('disabled')).toBeTruthy(); - expect(element(':input[ng\\:model="form.name"]').val()).toEqual('John Smith'); + expect(cancelButton.getAttribute('disabled')).toBeTruthy(); + nameInput.clear(); + nameInput.sendKeys('change'); + expect(cancelButton.getAttribute('disabled')).toBeFalsy(); + cancelButton.click(); + expect(cancelButton.getAttribute('disabled')).toBeTruthy(); + expect(nameInput.getAttribute('value')).toEqual('John Smith'); }); - + diff --git a/src/ng/directive/form.js b/src/ng/directive/form.js index 06ffad868d0c..86776ae7589f 100644 --- a/src/ng/directive/form.js +++ b/src/ng/directive/form.js @@ -305,18 +305,27 @@ function FormController(element, attrs) { myForm.$error.required = {{!!myForm.$error.required}}
- + it('should initialize to model', function() { - expect(binding('userType')).toEqual('guest'); - expect(binding('myForm.input.$valid')).toEqual('true'); + var userType = element(by.binding('userType')); + var valid = element(by.binding('myForm.input.$valid')); + + expect(userType.getText()).toContain('guest'); + expect(valid.getText()).toContain('true'); }); it('should be invalid if empty', function() { - input('userType').enter(''); - expect(binding('userType')).toEqual(''); - expect(binding('myForm.input.$valid')).toEqual('false'); + var userType = element(by.binding('userType')); + var valid = element(by.binding('myForm.input.$valid')); + var userInput = element(by.model('userType')); + + userInput.clear(); + userInput.sendKeys(''); + + expect(userType.getText()).toEqual('userType ='); + expect(valid.getText()).toContain('false'); }); - + */ var formDirectiveFactory = function(isNgForm) { diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 53a8ddd4d70a..cd8f902761b3 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -62,29 +62,31 @@ var inputType = { myForm.$error.required = {{!!myForm.$error.required}}
- + + var text = element(by.binding('text')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('text')); + it('should initialize to model', function() { - expect(binding('text')).toEqual('guest'); - expect(binding('myForm.input.$valid')).toEqual('true'); + expect(text.getText()).toContain('guest'); + expect(valid.getText()).toContain('true'); }); it('should be invalid if empty', function() { - input('text').enter(''); - expect(binding('text')).toEqual(''); - expect(binding('myForm.input.$valid')).toEqual('false'); + input.clear(); + input.sendKeys(''); + + expect(text.getText()).toEqual('text ='); + expect(valid.getText()).toContain('false'); }); it('should be invalid if multi word', function() { - input('text').enter('hello world'); - expect(binding('myForm.input.$valid')).toEqual('false'); - }); + input.clear(); + input.sendKeys('hello world'); - it('should not be trimmed', function() { - input('text').enter('untrimmed '); - expect(binding('text')).toEqual('untrimmed '); - expect(binding('myForm.input.$valid')).toEqual('true'); + expect(valid.getText()).toContain('false'); }); - + */ 'text': textInputType, @@ -138,24 +140,30 @@ var inputType = { myForm.$error.required = {{!!myForm.$error.required}}
- + + var value = element(by.binding('value')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('value')); + it('should initialize to model', function() { - expect(binding('value')).toEqual('12'); - expect(binding('myForm.input.$valid')).toEqual('true'); + expect(value.getText()).toContain('12'); + expect(valid.getText()).toContain('true'); }); it('should be invalid if empty', function() { - input('value').enter(''); - expect(binding('value')).toEqual(''); - expect(binding('myForm.input.$valid')).toEqual('false'); + input.clear(); + input.sendKeys(''); + expect(value.getText()).toEqual('value ='); + expect(valid.getText()).toContain('false'); }); it('should be invalid if over max', function() { - input('value').enter('123'); - expect(binding('value')).toEqual(''); - expect(binding('myForm.input.$valid')).toEqual('false'); + input.clear(); + input.sendKeys('123'); + expect(value.getText()).toEqual('value ='); + expect(valid.getText()).toContain('false'); }); - + */ 'number': numberInputType, @@ -207,23 +215,31 @@ var inputType = { myForm.$error.url = {{!!myForm.$error.url}}
- + + var text = element(by.binding('text')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('text')); + it('should initialize to model', function() { - expect(binding('text')).toEqual('http://google.com'); - expect(binding('myForm.input.$valid')).toEqual('true'); + expect(text.getText()).toContain('http://google.com'); + expect(valid.getText()).toContain('true'); }); it('should be invalid if empty', function() { - input('text').enter(''); - expect(binding('text')).toEqual(''); - expect(binding('myForm.input.$valid')).toEqual('false'); + input.clear(); + input.sendKeys(''); + + expect(text.getText()).toEqual('text ='); + expect(valid.getText()).toContain('false'); }); it('should be invalid if not url', function() { - input('text').enter('xxx'); - expect(binding('myForm.input.$valid')).toEqual('false'); + input.clear(); + input.sendKeys('box'); + + expect(valid.getText()).toContain('false'); }); - + */ 'url': urlInputType, @@ -275,23 +291,30 @@ var inputType = { myForm.$error.email = {{!!myForm.$error.email}}
- + + var text = element(by.binding('text')); + var valid = element(by.binding('myForm.input.$valid')); + var input = element(by.model('text')); + it('should initialize to model', function() { - expect(binding('text')).toEqual('me@example.com'); - expect(binding('myForm.input.$valid')).toEqual('true'); + expect(text.getText()).toContain('me@example.com'); + expect(valid.getText()).toContain('true'); }); it('should be invalid if empty', function() { - input('text').enter(''); - expect(binding('text')).toEqual(''); - expect(binding('myForm.input.$valid')).toEqual('false'); + input.clear(); + input.sendKeys(''); + expect(text.getText()).toEqual('text ='); + expect(valid.getText()).toContain('false'); }); it('should be invalid if not email', function() { - input('text').enter('xxx'); - expect(binding('myForm.input.$valid')).toEqual('false'); + input.clear(); + input.sendKeys('xxx'); + + expect(valid.getText()).toContain('false'); }); - + */ 'email': emailInputType, @@ -332,14 +355,17 @@ var inputType = { Note that `ng-value="specialValue"` sets radio item's value to be the value of `$scope.specialValue`. - + it('should change state', function() { - expect(binding('color')).toEqual('"blue"'); + var color = element(by.binding('color')); + + expect(color.getText()).toContain('blue'); - input('color').select('red'); - expect(binding('color')).toEqual('"red"'); + element.all(by.model('color')).get(0).click(); + + expect(color.getText()).toContain('red'); }); - + */ 'radio': radioInputType, @@ -376,17 +402,21 @@ var inputType = { value2 = {{value2}}
- + it('should change state', function() { - expect(binding('value1')).toEqual('true'); - expect(binding('value2')).toEqual('YES'); + var value1 = element(by.binding('value1')); + var value2 = element(by.binding('value2')); + + expect(value1.getText()).toContain('true'); + expect(value2.getText()).toContain('YES'); + + element(by.model('value1')).click(); + element(by.model('value2')).click(); - input('value1').check(); - input('value2').check(); - expect(binding('value1')).toEqual('false'); - expect(binding('value2')).toEqual('NO'); + expect(value1.getText()).toContain('false'); + expect(value2.getText()).toContain('NO'); }); - + */ 'checkbox': checkboxInputType, @@ -739,44 +769,59 @@ function checkboxInputType(scope, element, attr, ctrl) { myForm.$error.maxlength = {{!!myForm.$error.maxlength}}
- + + var user = element(by.binding('{{user}}')); + var userNameValid = element(by.binding('myForm.userName.$valid')); + var lastNameValid = element(by.binding('myForm.lastName.$valid')); + var lastNameError = element(by.binding('myForm.lastName.$error')); + var formValid = element(by.binding('myForm.$valid')); + var userNameInput = element(by.model('user.name')); + var userLastInput = element(by.model('user.last')); + it('should initialize to model', function() { - expect(binding('user')).toEqual('{"name":"guest","last":"visitor"}'); - expect(binding('myForm.userName.$valid')).toEqual('true'); - expect(binding('myForm.$valid')).toEqual('true'); + expect(user.getText()).toContain('{"name":"guest","last":"visitor"}'); + expect(userNameValid.getText()).toContain('true'); + expect(formValid.getText()).toContain('true'); }); it('should be invalid if empty when required', function() { - input('user.name').enter(''); - expect(binding('user')).toEqual('{"last":"visitor"}'); - expect(binding('myForm.userName.$valid')).toEqual('false'); - expect(binding('myForm.$valid')).toEqual('false'); + userNameInput.clear(); + userNameInput.sendKeys(''); + + expect(user.getText()).toContain('{"last":"visitor"}'); + expect(userNameValid.getText()).toContain('false'); + expect(formValid.getText()).toContain('false'); }); it('should be valid if empty when min length is set', function() { - input('user.last').enter(''); - expect(binding('user')).toEqual('{"name":"guest","last":""}'); - expect(binding('myForm.lastName.$valid')).toEqual('true'); - expect(binding('myForm.$valid')).toEqual('true'); + userLastInput.clear(); + userLastInput.sendKeys(''); + + expect(user.getText()).toContain('{"name":"guest","last":""}'); + expect(lastNameValid.getText()).toContain('true'); + expect(formValid.getText()).toContain('true'); }); it('should be invalid if less than required min length', function() { - input('user.last').enter('xx'); - expect(binding('user')).toEqual('{"name":"guest"}'); - expect(binding('myForm.lastName.$valid')).toEqual('false'); - expect(binding('myForm.lastName.$error')).toMatch(/minlength/); - expect(binding('myForm.$valid')).toEqual('false'); + userLastInput.clear(); + userLastInput.sendKeys('xx'); + + expect(user.getText()).toContain('{"name":"guest"}'); + expect(lastNameValid.getText()).toContain('false'); + expect(lastNameError.getText()).toContain('minlength'); + expect(formValid.getText()).toContain('false'); }); it('should be invalid if longer than max length', function() { - input('user.last').enter('some ridiculously long name'); - expect(binding('user')) - .toEqual('{"name":"guest"}'); - expect(binding('myForm.lastName.$valid')).toEqual('false'); - expect(binding('myForm.lastName.$error')).toMatch(/maxlength/); - expect(binding('myForm.$valid')).toEqual('false'); + userLastInput.clear(); + userLastInput.sendKeys('some ridiculously long name'); + + expect(user.getText()).toContain('{"name":"guest"}'); + expect(lastNameValid.getText()).toContain('false'); + expect(lastNameError.getText()).toContain('maxlength'); + expect(formValid.getText()).toContain('false'); }); - + */ var inputDirective = ['$browser', '$sniffer', function($browser, $sniffer) { @@ -1222,24 +1267,30 @@ var ngModelDirective = function() { * * *
- * debug = {{confirmed}}
- * counter = {{counter}} + * debug = {{confirmed}}
+ * counter = {{counter}}
* * - * + * + * var counter = element(by.binding('counter')); + * var debug = element(by.binding('confirmed')); + * * it('should evaluate the expression if changing from view', function() { - * expect(binding('counter')).toEqual('0'); - * element('#ng-change-example1').click(); - * expect(binding('counter')).toEqual('1'); - * expect(binding('confirmed')).toEqual('true'); + * expect(counter.getText()).toContain('0'); + * + * element(by.id('ng-change-example1')).click(); + * + * expect(counter.getText()).toContain('1'); + * expect(debug.getText()).toContain('true'); * }); * * it('should not evaluate the expression if changing from model', function() { - * element('#ng-change-example2').click(); - * expect(binding('counter')).toEqual('0'); - * expect(binding('confirmed')).toEqual('true'); + * element(by.id('ng-change-example2')).click(); + + * expect(counter.getText()).toContain('0'); + * expect(debug.getText()).toContain('true'); * }); - * + * * */ var ngChangeDirective = valueFn({ @@ -1312,20 +1363,26 @@ var requiredDirective = function() { myForm.$error.required = {{!!myForm.$error.required}}
- + + var listInput = element(by.model('names')); + var names = element(by.binding('{{names}}')); + var valid = element(by.binding('myForm.namesInput.$valid')); + var error = element(by.css('span.error')); + it('should initialize to model', function() { - expect(binding('names')).toEqual('["igor","misko","vojta"]'); - expect(binding('myForm.namesInput.$valid')).toEqual('true'); - expect(element('span.error').css('display')).toBe('none'); + expect(names.getText()).toContain('["igor","misko","vojta"]'); + expect(valid.getText()).toContain('true'); + expect(error.getCssValue('display')).toBe('none'); }); it('should be invalid if empty', function() { - input('names').enter(''); - expect(binding('names')).toEqual(''); - expect(binding('myForm.namesInput.$valid')).toEqual('false'); - expect(element('span.error').css('display')).not().toBe('none'); - }); - + listInput.clear(); + listInput.sendKeys(''); + + expect(names.getText()).toContain(''); + expect(valid.getText()).toContain('false'); + expect(error.getCssValue('display')).not.toBe('none'); }); + */ var ngListDirective = function() { @@ -1407,15 +1464,17 @@ var CONSTANT_VALUE_REGEXP = /^(true|false|\d+)$/;
You chose {{my.favorite}}
- + + var favorite = element(by.binding('my.favorite')); + it('should initialize to model', function() { - expect(binding('my.favorite')).toEqual('unicorns'); + expect(favorite.getText()).toContain('unicorns'); }); it('should bind the values to the inputs', function() { - input('my.favorite').select('pizza'); - expect(binding('my.favorite')).toEqual('pizza'); + element.all(by.model('my.favorite')).get(0).click(); + expect(favorite.getText()).toContain('pizza'); }); - + */ var ngValueDirective = function() { diff --git a/src/ng/directive/ngBind.js b/src/ng/directive/ngBind.js index ecfc8ab63097..5d0e300926f4 100644 --- a/src/ng/directive/ngBind.js +++ b/src/ng/directive/ngBind.js @@ -38,13 +38,17 @@ Hello ! - + it('should check ng-bind', function() { - expect(using('.doc-example-live').binding('name')).toBe('Whirled'); - using('.doc-example-live').input('name').enter('world'); - expect(using('.doc-example-live').binding('name')).toBe('world'); + var exampleContainer = $('.doc-example-live'); + var nameInput = element(by.model('name')); + + expect(exampleContainer.findElement(by.binding('name')).getText()).toBe('Whirled'); + nameInput.clear(); + nameInput.sendKeys('world'); + expect(exampleContainer.findElement(by.binding('name')).getText()).toBe('world'); }); - + */ var ngBindDirective = ngDirective(function(scope, element, attr) { @@ -90,20 +94,22 @@ var ngBindDirective = ngDirective(function(scope, element, attr) {

        
      
-     
+     
        it('should check ng-bind', function() {
-         expect(using('.doc-example-live').binding('salutation')).
-           toBe('Hello');
-         expect(using('.doc-example-live').binding('name')).
-           toBe('World');
-         using('.doc-example-live').input('salutation').enter('Greetings');
-         using('.doc-example-live').input('name').enter('user');
-         expect(using('.doc-example-live').binding('salutation')).
-           toBe('Greetings');
-         expect(using('.doc-example-live').binding('name')).
-           toBe('user');
+         var salutationElem = element(by.binding('salutation'));
+         var salutationInput = element(by.model('salutation'));
+         var nameInput = element(by.model('name'));
+
+         expect(salutationElem.getText()).toBe('Hello World!');
+
+         salutationInput.clear();
+         salutationInput.sendKeys('Greetings');
+         nameInput.clear();
+         nameInput.sendKeys('user');
+
+         expect(salutationElem.getText()).toBe('Greetings user!');
        });
-     
+     
    
  */
 var ngBindTemplateDirective = ['$interpolate', function($interpolate) {
@@ -156,12 +162,10 @@ var ngBindTemplateDirective = ['$interpolate', function($interpolate) {
        }]);
      
 
-     
+     
        it('should check ng-bind-html', function() {
-         expect(using('.doc-example-live').binding('myHTML')).
-           toBe(
-           'I am an HTMLstring with links! and other stuff'
-           );
+         expect(element(by.binding('myHTML')).getText()).toBe(
+             'I am an HTMLstring with links! and other stuff');
        });
      
    
diff --git a/src/ng/directive/ngCloak.js b/src/ng/directive/ngCloak.js
index 5072c8c2ee43..220c964dce0e 100644
--- a/src/ng/directive/ngCloak.js
+++ b/src/ng/directive/ngCloak.js
@@ -45,14 +45,14 @@
         
{{ 'hello' }}
{{ 'hello IE7' }}
- + it('should remove the template directive and css class', function() { - expect(element('.doc-example-live #template1').attr('ng-cloak')). - not().toBeDefined(); - expect(element('.doc-example-live #template2').attr('ng-cloak')). - not().toBeDefined(); + expect($('.doc-example-live #template1').getAttribute('ng-cloak')). + toBeNull(); + expect($('.doc-example-live #template2').getAttribute('ng-cloak')). + toBeNull(); }); - + * */ diff --git a/src/ng/directive/ngController.js b/src/ng/directive/ngController.js index 5550b77fd852..7149d090d5b9 100644 --- a/src/ng/directive/ngController.js +++ b/src/ng/directive/ngController.js @@ -82,22 +82,36 @@ - + it('should check controller as', function() { - expect(element('#ctrl-as-exmpl>:input').val()).toBe('John Smith'); - expect(element('#ctrl-as-exmpl li:nth-child(1) input').val()) - .toBe('408 555 1212'); - expect(element('#ctrl-as-exmpl li:nth-child(2) input').val()) - .toBe('john.smith@example.org'); - - element('#ctrl-as-exmpl li:first a:contains("clear")').click(); - expect(element('#ctrl-as-exmpl li:first input').val()).toBe(''); - - element('#ctrl-as-exmpl li:last a:contains("add")').click(); - expect(element('#ctrl-as-exmpl li:nth-child(3) input').val()) - .toBe('yourname@example.org'); + var container = element(by.id('ctrl-as-exmpl')); + + expect(container.findElement(by.model('settings.name')) + .getAttribute('value')).toBe('John Smith'); + + var firstRepeat = + container.findElement(by.repeater('contact in settings.contacts').row(0)); + var secondRepeat = + container.findElement(by.repeater('contact in settings.contacts').row(1)); + + expect(firstRepeat.findElement(by.model('contact.value')).getAttribute('value')) + .toBe('408 555 1212'); + expect(secondRepeat.findElement(by.model('contact.value')).getAttribute('value')) + .toBe('john.smith@example.org'); + + firstRepeat.findElement(by.linkText('clear')).click() + + expect(firstRepeat.findElement(by.model('contact.value')).getAttribute('value')) + .toBe(''); + + container.findElement(by.linkText('add')).click(); + + expect(container.findElement(by.repeater('contact in settings.contacts').row(2)) + .findElement(by.model('contact.value')) + .getAttribute('value')) + .toBe('yourname@example.org'); }); - + @@ -145,22 +159,36 @@ - + it('should check controller', function() { - expect(element('#ctrl-exmpl>:input').val()).toBe('John Smith'); - expect(element('#ctrl-exmpl li:nth-child(1) input').val()) - .toBe('408 555 1212'); - expect(element('#ctrl-exmpl li:nth-child(2) input').val()) - .toBe('john.smith@example.org'); - - element('#ctrl-exmpl li:first a:contains("clear")').click(); - expect(element('#ctrl-exmpl li:first input').val()).toBe(''); - - element('#ctrl-exmpl li:last a:contains("add")').click(); - expect(element('#ctrl-exmpl li:nth-child(3) input').val()) - .toBe('yourname@example.org'); + var container = element(by.id('ctrl-exmpl')); + + expect(container.findElement(by.model('name')) + .getAttribute('value')).toBe('John Smith'); + + var firstRepeat = + container.findElement(by.repeater('contact in contacts').row(0)); + var secondRepeat = + container.findElement(by.repeater('contact in contacts').row(1)); + + expect(firstRepeat.findElement(by.model('contact.value')).getAttribute('value')) + .toBe('408 555 1212'); + expect(secondRepeat.findElement(by.model('contact.value')).getAttribute('value')) + .toBe('john.smith@example.org'); + + firstRepeat.findElement(by.linkText('clear')).click() + + expect(firstRepeat.findElement(by.model('contact.value')).getAttribute('value')) + .toBe(''); + + container.findElement(by.linkText('add')).click(); + + expect(container.findElement(by.repeater('contact in contacts').row(2)) + .findElement(by.model('contact.value')) + .getAttribute('value')) + .toBe('yourname@example.org'); }); - + */ diff --git a/src/ng/directive/ngEventDirs.js b/src/ng/directive/ngEventDirs.js index 7dba5749b059..f63d3ca1e7bf 100644 --- a/src/ng/directive/ngEventDirs.js +++ b/src/ng/directive/ngEventDirs.js @@ -327,20 +327,20 @@ forEach(
list={{list}}
- + it('should check ng-submit', function() { - expect(binding('list')).toBe('[]'); - element('.doc-example-live #submit').click(); - expect(binding('list')).toBe('["hello"]'); - expect(input('text').val()).toBe(''); + expect(element(by.binding('list')).getText()).toBe('list=[]'); + element(by.css('.doc-example-live #submit')).click(); + expect(element(by.binding('list')).getText()).toContain('hello'); + expect(element(by.input('text')).getAttribute('value')).toBe(''); }); it('should ignore empty strings', function() { - expect(binding('list')).toBe('[]'); - element('.doc-example-live #submit').click(); - element('.doc-example-live #submit').click(); - expect(binding('list')).toBe('["hello"]'); - }); - + expect(element(by.binding('list')).getText()).toBe('list=[]'); + element(by.css('.doc-example-live #submit')).click(); + element(by.css('.doc-example-live #submit')).click(); + expect(element(by.binding('list')).getText()).toContain('hello'); + }); + */ diff --git a/src/ng/directive/ngInit.js b/src/ng/directive/ngInit.js index 6270a6d8f8b2..d5a1e24521d4 100644 --- a/src/ng/directive/ngInit.js +++ b/src/ng/directive/ngInit.js @@ -44,15 +44,15 @@ - + it('should alias index positions', function() { - expect(element('.example-init').text()) - .toBe('list[ 0 ][ 0 ] = a;' + - 'list[ 0 ][ 1 ] = b;' + - 'list[ 1 ][ 0 ] = c;' + - 'list[ 1 ][ 1 ] = d;'); + var elements = element.all(by.css('.example-init')); + expect(elements.get(0).getText()).toBe('list[ 0 ][ 0 ] = a;'); + expect(elements.get(1).getText()).toBe('list[ 0 ][ 1 ] = b;'); + expect(elements.get(2).getText()).toBe('list[ 1 ][ 0 ] = c;'); + expect(elements.get(3).getText()).toBe('list[ 1 ][ 1 ] = d;'); }); - + */ var ngInitDirective = ngDirective({ diff --git a/src/ng/directive/ngNonBindable.js b/src/ng/directive/ngNonBindable.js index 473b416b8cde..160733762b09 100644 --- a/src/ng/directive/ngNonBindable.js +++ b/src/ng/directive/ngNonBindable.js @@ -24,13 +24,12 @@
Normal: {{1 + 2}}
Ignored: {{1 + 2}}
- + it('should check ng-non-bindable', function() { - expect(using('.doc-example-live').binding('1 + 2')).toBe('3'); - expect(using('.doc-example-live').element('div:last').text()). - toMatch(/1 \+ 2/); + expect(element(by.binding('1 + 2')).getText()).toContain('3'); + expect(element.all(by.css('.doc-example-live div')).last().getText()).toMatch(/1 \+ 2/); }); - + */ var ngNonBindableDirective = ngDirective({ terminal: true, priority: 1000 }); diff --git a/src/ng/directive/ngTransclude.js b/src/ng/directive/ngTransclude.js index 8eefb6fff528..295e47a9922c 100644 --- a/src/ng/directive/ngTransclude.js +++ b/src/ng/directive/ngTransclude.js @@ -40,14 +40,18 @@ {{text}} - + it('should have transcluded', function() { - input('title').enter('TITLE'); - input('text').enter('TEXT'); - expect(binding('title')).toEqual('TITLE'); - expect(binding('text')).toEqual('TEXT'); + var titleElement = element(by.model('title')); + titleElement.clear(); + titleElement.sendKeys('TITLE'); + var textElement = element(by.model('text')); + textElement.clear(); + textElement.sendKeys('TEXT'); + expect(element(by.binding('title')).getText()).toEqual('TITLE'); + expect(element(by.binding('text')).getText()).toEqual('TEXT'); }); - + * */ diff --git a/src/ng/directive/script.js b/src/ng/directive/script.js index 86233ff80df3..e86285ae5743 100644 --- a/src/ng/directive/script.js +++ b/src/ng/directive/script.js @@ -25,12 +25,12 @@ Load inlined template
- + it('should load template defined inside script tag', function() { - element('#tpl-link').click(); - expect(element('#tpl-content').text()).toMatch(/Content of the template/); + element(by.css('#tpl-link')).click(); + expect(element(by.css('#tpl-content')).getText()).toMatch(/Content of the template/); }); - + */ var scriptDirective = ['$templateCache', function($templateCache) { diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index e44b61e955cb..3b80ba3b2cf7 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -120,15 +120,17 @@ var ngOptionsMinErr = minErr('ngOptions'); - + it('should check ng-options', function() { - expect(binding('{selected_color:color}')).toMatch('red'); - select('color').option('0'); - expect(binding('{selected_color:color}')).toMatch('black'); - using('.nullable').select('color').option(''); - expect(binding('{selected_color:color}')).toMatch('null'); + expect(element(by.binding('{selected_color:color}')).getText()).toMatch('red'); + element.all(by.select('color')).first().click(); + element.all(by.css('select[ng-model="color"] option')).first().click(); + expect(element(by.binding('{selected_color:color}')).getText()).toMatch('black'); + element(by.css('.nullable select[ng-model="color"]')).click(); + element.all(by.css('.nullable select[ng-model="color"] option')).first().click(); + expect(element(by.binding('{selected_color:color}')).getText()).toMatch('null'); }); - + */ diff --git a/src/ng/filter/filters.js b/src/ng/filter/filters.js index c92ed384792e..00748034cec8 100644 --- a/src/ng/filter/filters.js +++ b/src/ng/filter/filters.js @@ -24,21 +24,22 @@

- default currency symbol ($): {{amount | currency}}
- custom currency identifier (USD$): {{amount | currency:"USD$"}} + default currency symbol ($): {{amount | currency}}
+ custom currency identifier (USD$): {{amount | currency:"USD$"}}
- + it('should init with 1234.56', function() { - expect(binding('amount | currency')).toBe('$1,234.56'); - expect(binding('amount | currency:"USD$"')).toBe('USD$1,234.56'); + expect(element(by.binding('amount | currency')).getText()).toBe('$1,234.56'); + expect(element(by.binding('amount | currency:"USD$"')).getText()).toBe('USD$1,234.56'); }); it('should update', function() { - input('amount').enter('-1234'); - expect(binding('amount | currency')).toBe('($1,234.00)'); - expect(binding('amount | currency:"USD$"')).toBe('(USD$1,234.00)'); + element(by.model('amount')).clear(); + element(by.model('amount')).sendKeys('-1234'); + expect(element(by.binding('amount | currency')).getText()).toBe('($1,234.00)'); + expect(element(by.binding('amount | currency:"USD$"')).getText()).toBe('(USD$1,234.00)'); }); - + */ currencyFilter.$inject = ['$locale']; @@ -77,25 +78,26 @@ function currencyFilter($locale) {
Enter number:
- Default formatting: {{val | number}}
- No fractions: {{val | number:0}}
- Negative number: {{-val | number:4}} + Default formatting: {{val | number}}
+ No fractions: {{val | number:0}}
+ Negative number: {{-val | number:4}}
- + it('should format numbers', function() { - expect(binding('val | number')).toBe('1,234.568'); - expect(binding('val | number:0')).toBe('1,235'); - expect(binding('-val | number:4')).toBe('-1,234.5679'); + expect(element(by.binding('val | number')).getText()).toBe('1,234.568'); + expect(element(by.binding('val | number:0')).getText()).toBe('1,235'); + expect(element(by.binding('-val | number:4')).getText()).toBe('-1,234.5679'); }); it('should update', function() { - input('val').enter('3374.333'); - expect(binding('val | number')).toBe('3,374.333'); - expect(binding('val | number:0')).toBe('3,374'); - expect(binding('-val | number:4')).toBe('-3,374.3330'); - }); - + element(by.model('val')).clear(); + element(by.model('val')).sendKeys('3374.333'); + expect(element(by.binding('val | number')).getText()).toBe('3,374.333'); + expect(element(by.binding('val | number:0')).getText()).toBe('3,374'); + expect(element(by.binding('-val | number:4')).getText()).toBe('-3,374.3330'); + }); + */ @@ -325,22 +327,22 @@ var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+ {{1288323623006 | date:'medium'}}: - {{1288323623006 | date:'medium'}}
+ {{1288323623006 | date:'medium'}}
{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}: - {{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}
+ {{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}
{{1288323623006 | date:'MM/dd/yyyy @ h:mma'}}: - {{'1288323623006' | date:'MM/dd/yyyy @ h:mma'}}
+ {{'1288323623006' | date:'MM/dd/yyyy @ h:mma'}}
- + it('should format date', function() { - expect(binding("1288323623006 | date:'medium'")). + expect(element(by.binding("1288323623006 | date:'medium'")).getText()). toMatch(/Oct 2\d, 2010 \d{1,2}:\d{2}:\d{2} (AM|PM)/); - expect(binding("1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'")). + expect(element(by.binding("1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'")).getText()). toMatch(/2010\-10\-2\d \d{2}:\d{2}:\d{2} (\-|\+)?\d{4}/); - expect(binding("'1288323623006' | date:'MM/dd/yyyy @ h:mma'")). + expect(element(by.binding("'1288323623006' | date:'MM/dd/yyyy @ h:mma'")).getText()). toMatch(/10\/2\d\/2010 @ \d{1,2}:\d{2}(AM|PM)/); }); - +
*/ dateFilter.$inject = ['$locale']; @@ -439,11 +441,11 @@ function dateFilter($locale) {
{{ {'name':'value'} | json }}
- + it('should jsonify filtered objects', function() { - expect(binding("{'name':'value'}")).toMatch(/\{\n "name": ?"value"\n}/); + expect(element(by.binding("{'name':'value'}")).getText()).toMatch(/\{\n "name": ?"value"\n}/); }); - + * */ diff --git a/src/ngSanitize/sanitize.js b/src/ngSanitize/sanitize.js index 5e45eb338b47..1b6cb94ef9e5 100644 --- a/src/ngSanitize/sanitize.js +++ b/src/ngSanitize/sanitize.js @@ -99,35 +99,37 @@ var $sanitizeMinErr = angular.$$minErr('$sanitize'); - + it('should sanitize the html snippet by default', function() { - expect(using('#bind-html-with-sanitize').element('div').html()). + expect(element(by.css('#bind-html-with-sanitize div')).getInnerHtml()). toBe('

an html\nclick here\nsnippet

'); }); it('should inline raw snippet if bound to a trusted value', function() { - expect(using('#bind-html-with-trust').element("div").html()). + expect(element(by.css('#bind-html-with-trust div')).getInnerHtml()). toBe("

an html\n" + "click here\n" + "snippet

"); }); it('should escape snippet without any filter', function() { - expect(using('#bind-default').element('div').html()). + expect(element(by.css('#bind-default div')).getInnerHtml()). toBe("<p style=\"color:blue\">an html\n" + "<em onmouseover=\"this.textContent='PWN3D!'\">click here</em>\n" + "snippet</p>"); }); it('should update', function() { - input('snippet').enter('new text'); - expect(using('#bind-html-with-sanitize').element('div').html()).toBe('new text'); - expect(using('#bind-html-with-trust').element('div').html()).toBe( + element(by.model('snippet')).clear(); + element(by.model('snippet')).sendKeys('new text'); + expect(element(by.css('#bind-html-with-sanitize div')).getInnerHtml()). + toBe('new text'); + expect(element(by.css('#bind-html-with-trust div')).getInnerHtml()).toBe( 'new text'); - expect(using('#bind-default').element('div').html()).toBe( + expect(element(by.css('#bind-default div')).getInnerHtml()).toBe( "new <b onclick=\"alert(1)\">text</b>"); }); -
+ */ function $SanitizeProvider() {