diff options
Diffstat (limited to 'src/ng/directive/ngPluralize.js')
| -rw-r--r-- | src/ng/directive/ngPluralize.js | 74 | 
1 files changed, 39 insertions, 35 deletions
| diff --git a/src/ng/directive/ngPluralize.js b/src/ng/directive/ngPluralize.js index 7004bf4f..58af4515 100644 --- a/src/ng/directive/ngPluralize.js +++ b/src/ng/directive/ngPluralize.js @@ -123,49 +123,53 @@            </ng-pluralize>          </div>        </doc:source> -      <doc:scenario> +      <doc:protractor>          it('should show correct pluralized string', function() { -          expect(element('.doc-example-live ng-pluralize:first').text()). -                                             toBe('1 person is viewing.'); -          expect(element('.doc-example-live ng-pluralize:last').text()). -                                                toBe('Igor is viewing.'); +          var withoutOffset = element.all(by.css('ng-pluralize')).get(0); +          var withOffset = element.all(by.css('ng-pluralize')).get(1); +          var countInput = element(by.model('personCount')); -          using('.doc-example-live').input('personCount').enter('0'); -          expect(element('.doc-example-live ng-pluralize:first').text()). -                                               toBe('Nobody is viewing.'); -          expect(element('.doc-example-live ng-pluralize:last').text()). -                                              toBe('Nobody is viewing.'); +          expect(withoutOffset.getText()).toEqual('1 person is viewing.'); +          expect(withOffset.getText()).toEqual('Igor is viewing.'); -          using('.doc-example-live').input('personCount').enter('2'); -          expect(element('.doc-example-live ng-pluralize:first').text()). -                                            toBe('2 people are viewing.'); -          expect(element('.doc-example-live ng-pluralize:last').text()). -                              toBe('Igor and Misko are viewing.'); +          countInput.clear(); +          countInput.sendKeys('0'); -          using('.doc-example-live').input('personCount').enter('3'); -          expect(element('.doc-example-live ng-pluralize:first').text()). -                                            toBe('3 people are viewing.'); -          expect(element('.doc-example-live ng-pluralize:last').text()). -                              toBe('Igor, Misko and one other person are viewing.'); +          expect(withoutOffset.getText()).toEqual('Nobody is viewing.'); +          expect(withOffset.getText()).toEqual('Nobody is viewing.'); -          using('.doc-example-live').input('personCount').enter('4'); -          expect(element('.doc-example-live ng-pluralize:first').text()). -                                            toBe('4 people are viewing.'); -          expect(element('.doc-example-live ng-pluralize:last').text()). -                              toBe('Igor, Misko and 2 other people are viewing.'); -        }); +          countInput.clear(); +          countInput.sendKeys('2'); + +          expect(withoutOffset.getText()).toEqual('2 people are viewing.'); +          expect(withOffset.getText()).toEqual('Igor and Misko are viewing.'); + +          countInput.clear(); +          countInput.sendKeys('3'); -        it('should show data-binded names', function() { -          using('.doc-example-live').input('personCount').enter('4'); -          expect(element('.doc-example-live ng-pluralize:last').text()). -              toBe('Igor, Misko and 2 other people are viewing.'); +          expect(withoutOffset.getText()).toEqual('3 people are viewing.'); +          expect(withOffset.getText()).toEqual('Igor, Misko and one other person are viewing.'); -          using('.doc-example-live').input('person1').enter('Di'); -          using('.doc-example-live').input('person2').enter('Vojta'); -          expect(element('.doc-example-live ng-pluralize:last').text()). -              toBe('Di, Vojta and 2 other people are viewing.'); +          countInput.clear(); +          countInput.sendKeys('4'); + +          expect(withoutOffset.getText()).toEqual('4 people are viewing.'); +          expect(withOffset.getText()).toEqual('Igor, Misko and 2 other people are viewing.'); +        }); +        it('should show data-bound names', function() { +          var withOffset = element.all(by.css('ng-pluralize')).get(1); +          var personCount = element(by.model('personCount')); +          var person1 = element(by.model('person1')); +          var person2 = element(by.model('person2')); +          personCount.clear(); +          personCount.sendKeys('4'); +          person1.clear(); +          person1.sendKeys('Di'); +          person2.clear(); +          person2.sendKeys('Vojta'); +          expect(withOffset.getText()).toEqual('Di, Vojta and 2 other people are viewing.');          }); -      </doc:scenario> +      </doc:protractor>      </doc:example>   */  var ngPluralizeDirective = ['$locale', '$interpolate', function($locale, $interpolate) { | 
