aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/directive/ngClass.js
diff options
context:
space:
mode:
authorJulie2014-01-11 16:59:15 -0800
committerCaitlin Potter2014-01-28 14:14:20 -0500
commit7aef2d54e0a48fae18a289813f699962d8310565 (patch)
tree60d1d559510c17e879aff798f298e6bcc262d3ab /src/ng/directive/ngClass.js
parentce37ae28687167f7b4274ba547f013980126a219 (diff)
downloadangular.js-7aef2d54e0a48fae18a289813f699962d8310565.tar.bz2
test(docs): convert example end to end doc tests from scenario runner to protractor
Thanks to jeffbcross, petebacondarwin, btford, jdeboer, tbosch for contributions! Closes #6023
Diffstat (limited to 'src/ng/directive/ngClass.js')
-rw-r--r--src/ng/directive/ngClass.js62
1 files changed, 33 insertions, 29 deletions
diff --git a/src/ng/directive/ngClass.js b/src/ng/directive/ngClass.js
index 21316c57..c9384b08 100644
--- a/src/ng/directive/ngClass.js
+++ b/src/ng/directive/ngClass.js
@@ -114,31 +114,35 @@ function classDirective(name, selector) {
color: red;
}
</file>
- <file name="scenario.js">
+ <file name="protractorTest.js">
+ var ps = element.all(by.css('.doc-example-live p'));
+
it('should let you toggle the class', function() {
- expect(element('.doc-example-live p:first').prop('className')).not().toMatch(/bold/);
- expect(element('.doc-example-live p:first').prop('className')).not().toMatch(/red/);
+ expect(ps.first().getAttribute('class')).not.toMatch(/bold/);
+ expect(ps.first().getAttribute('class')).not.toMatch(/red/);
- input('important').check();
- expect(element('.doc-example-live p:first').prop('className')).toMatch(/bold/);
+ element(by.model('important')).click();
+ expect(ps.first().getAttribute('class')).toMatch(/bold/);
- input('error').check();
- expect(element('.doc-example-live p:first').prop('className')).toMatch(/red/);
+ element(by.model('error')).click();
+ expect(ps.first().getAttribute('class')).toMatch(/red/);
});
it('should let you toggle string example', function() {
- expect(element('.doc-example-live p:nth-of-type(2)').prop('className')).toBe('');
- input('style').enter('red');
- expect(element('.doc-example-live p:nth-of-type(2)').prop('className')).toBe('red');
+ expect(ps.get(1).getAttribute('class')).toBe('');
+ element(by.model('style')).clear();
+ element(by.model('style')).sendKeys('red');
+ browser.debugger();
+ expect(ps.get(1).getAttribute('class')).toBe('red');
});
it('array example should have 3 classes', function() {
- expect(element('.doc-example-live p:last').prop('className')).toBe('');
- input('style1').enter('bold');
- input('style2').enter('strike');
- input('style3').enter('red');
- expect(element('.doc-example-live p:last').prop('className')).toBe('bold strike red');
+ expect(ps.last().getAttribute('class')).toBe('');
+ element(by.model('style1')).sendKeys('bold');
+ element(by.model('style2')).sendKeys('strike');
+ element(by.model('style3')).sendKeys('red');
+ expect(ps.last().getAttribute('class')).toBe('bold strike red');
});
</file>
</example>
@@ -149,8 +153,8 @@ function classDirective(name, selector) {
<example animations="true">
<file name="index.html">
- <input type="button" value="set" ng-click="myVar='my-class'">
- <input type="button" value="clear" ng-click="myVar=''">
+ <input id="setbtn" type="button" value="set" ng-click="myVar='my-class'">
+ <input id="clearbtn" type="button" value="clear" ng-click="myVar=''">
<br>
<span class="base-class" ng-class="myVar">Sample Text</span>
</file>
@@ -165,19 +169,19 @@ function classDirective(name, selector) {
font-size:3em;
}
</file>
- <file name="scenario.js">
+ <file name="protractorTest.js">
it('should check ng-class', function() {
- expect(element('.doc-example-live span').prop('className')).not().
+ expect(element(by.css('.base-class')).getAttribute('class')).not.
toMatch(/my-class/);
- using('.doc-example-live').element(':button:first').click();
+ element(by.id('setbtn')).click();
- expect(element('.doc-example-live span').prop('className')).
+ expect(element(by.css('.base-class')).getAttribute('class')).
toMatch(/my-class/);
- using('.doc-example-live').element(':button:last').click();
+ element(by.id('clearbtn')).click();
- expect(element('.doc-example-live span').prop('className')).not().
+ expect(element(by.css('.base-class')).getAttribute('class')).not.
toMatch(/my-class/);
});
</file>
@@ -229,11 +233,11 @@ var ngClassDirective = classDirective('', true);
color: blue;
}
</file>
- <file name="scenario.js">
+ <file name="protractorTest.js">
it('should check ng-class-odd and ng-class-even', function() {
- expect(element('.doc-example-live li:first span').prop('className')).
+ expect(element(by.repeater('name in names').row(0).column('name')).getAttribute('class')).
toMatch(/odd/);
- expect(element('.doc-example-live li:last span').prop('className')).
+ expect(element(by.repeater('name in names').row(1).column('name')).getAttribute('class')).
toMatch(/even/);
});
</file>
@@ -277,11 +281,11 @@ var ngClassOddDirective = classDirective('Odd', 0);
color: blue;
}
</file>
- <file name="scenario.js">
+ <file name="protractorTest.js">
it('should check ng-class-odd and ng-class-even', function() {
- expect(element('.doc-example-live li:first span').prop('className')).
+ expect(element(by.repeater('name in names').row(0).column('name')).getAttribute('class')).
toMatch(/odd/);
- expect(element('.doc-example-live li:last span').prop('className')).
+ expect(element(by.repeater('name in names').row(1).column('name')).getAttribute('class')).
toMatch(/even/);
});
</file>