mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 19:40:56 +08:00
chore(protractor tests): fix up e2e tests
This commit is contained in:
committed by
Peter Bacon Darwin
parent
cd508678cd
commit
9565cca15b
@@ -176,9 +176,9 @@
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should toggle button', function() {
|
||||
expect(element(by.css('.doc-example-live button')).getAttribute('disabled')).toBeFalsy();
|
||||
expect(element(by.css('button')).getAttribute('disabled')).toBeFalsy();
|
||||
element(by.model('checked')).click();
|
||||
expect(element(by.css('.doc-example-live button')).getAttribute('disabled')).toBeTruthy();
|
||||
expect(element(by.css('button')).getAttribute('disabled')).toBeTruthy();
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
@@ -246,9 +246,9 @@
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should toggle readonly attr', function() {
|
||||
expect(element(by.css('.doc-example-live [type="text"]')).getAttribute('readonly')).toBeFalsy();
|
||||
expect(element(by.css('[type="text"]')).getAttribute('readonly')).toBeFalsy();
|
||||
element(by.model('checked')).click();
|
||||
expect(element(by.css('.doc-example-live [type="text"]')).getAttribute('readonly')).toBeTruthy();
|
||||
expect(element(by.css('[type="text"]')).getAttribute('readonly')).toBeTruthy();
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
|
||||
@@ -955,13 +955,13 @@ var VALID_CLASS = 'ng-valid',
|
||||
<textarea ng-model="userContent"></textarea>
|
||||
</form>
|
||||
</file>
|
||||
<file name="protractorTest.js">
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should data-bind and become invalid', function() {
|
||||
if (browser.params.browser = 'safari') {
|
||||
// SafariDriver can't handle contenteditable.
|
||||
return;
|
||||
};
|
||||
var contentEditable = element(by.css('.doc-example-live [contenteditable]'));
|
||||
var contentEditable = element(by.css('[contenteditable]'));
|
||||
|
||||
expect(contentEditable.getText()).toEqual('Change me!');
|
||||
|
||||
|
||||
@@ -40,13 +40,12 @@
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should check ng-bind', function() {
|
||||
var exampleContainer = $('.doc-example-live');
|
||||
var nameInput = element(by.model('name'));
|
||||
|
||||
expect(exampleContainer.findElement(by.binding('name')).getText()).toBe('Whirled');
|
||||
expect(element(by.binding('name')).getText()).toBe('Whirled');
|
||||
nameInput.clear();
|
||||
nameInput.sendKeys('world');
|
||||
expect(exampleContainer.findElement(by.binding('name')).getText()).toBe('world');
|
||||
expect(element(by.binding('name')).getText()).toBe('world');
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
@@ -162,7 +161,7 @@ var ngBindTemplateDirective = ['$interpolate', function($interpolate) {
|
||||
}]);
|
||||
</file>
|
||||
|
||||
<file name="protractorTest.js">
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should check ng-bind-html', function() {
|
||||
expect(element(by.binding('myHTML')).getText()).toBe(
|
||||
'I am an HTMLstring with links! and other stuff');
|
||||
|
||||
@@ -114,8 +114,8 @@ function classDirective(name, selector) {
|
||||
color: red;
|
||||
}
|
||||
</file>
|
||||
<file name="protractorTest.js">
|
||||
var ps = element.all(by.css('.doc-example-live p'));
|
||||
<file name="protractor.js" type="protractor">
|
||||
var ps = element.all(by.css('p'));
|
||||
|
||||
it('should let you toggle the class', function() {
|
||||
|
||||
@@ -168,7 +168,7 @@ function classDirective(name, selector) {
|
||||
font-size:3em;
|
||||
}
|
||||
</file>
|
||||
<file name="protractorTest.js">
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should check ng-class', function() {
|
||||
expect(element(by.css('.base-class')).getAttribute('class')).not.
|
||||
toMatch(/my-class/);
|
||||
@@ -232,7 +232,7 @@ var ngClassDirective = classDirective('', true);
|
||||
color: blue;
|
||||
}
|
||||
</file>
|
||||
<file name="protractorTest.js">
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should check ng-class-odd and ng-class-even', function() {
|
||||
expect(element(by.repeater('name in names').row(0).column('name')).getAttribute('class')).
|
||||
toMatch(/odd/);
|
||||
@@ -280,7 +280,7 @@ var ngClassOddDirective = classDirective('Odd', 0);
|
||||
color: blue;
|
||||
}
|
||||
</file>
|
||||
<file name="protractorTest.js">
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should check ng-class-odd and ng-class-even', function() {
|
||||
expect(element(by.repeater('name in names').row(0).column('name')).getAttribute('class')).
|
||||
toMatch(/odd/);
|
||||
|
||||
@@ -47,9 +47,9 @@
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should remove the template directive and css class', function() {
|
||||
expect($('.doc-example-live #template1').getAttribute('ng-cloak')).
|
||||
expect($('#template1').getAttribute('ng-cloak')).
|
||||
toBeNull();
|
||||
expect($('.doc-example-live #template2').getAttribute('ng-cloak')).
|
||||
expect($('#template2').getAttribute('ng-cloak')).
|
||||
toBeNull();
|
||||
});
|
||||
</file>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should check ng-click', function() {
|
||||
expect(element(by.binding('count')).getText()).toMatch('0');
|
||||
element(by.css('.doc-example-live button')).click();
|
||||
element(by.css('button')).click();
|
||||
expect(element(by.binding('count')).getText()).toMatch('1');
|
||||
});
|
||||
</file>
|
||||
@@ -330,14 +330,14 @@ forEach(
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should check ng-submit', function() {
|
||||
expect(element(by.binding('list')).getText()).toBe('list=[]');
|
||||
element(by.css('.doc-example-live #submit')).click();
|
||||
element(by.css('#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(element(by.binding('list')).getText()).toBe('list=[]');
|
||||
element(by.css('.doc-example-live #submit')).click();
|
||||
element(by.css('.doc-example-live #submit')).click();
|
||||
element(by.css('#submit')).click();
|
||||
element(by.css('#submit')).click();
|
||||
expect(element(by.binding('list')).getText()).toContain('hello');
|
||||
});
|
||||
</file>
|
||||
|
||||
@@ -110,9 +110,9 @@
|
||||
top:50px;
|
||||
}
|
||||
</file>
|
||||
<file name="protractorTest.js">
|
||||
<file name="protractor.js" type="protractor">
|
||||
var templateSelect = element(by.model('template'));
|
||||
var includeElem = element(by.css('.doc-example-live [ng-include]'));
|
||||
var includeElem = element(by.css('[ng-include]'));
|
||||
|
||||
it('should load template1.html', function() {
|
||||
expect(includeElem.getText()).toMatch(/Content of template1.html/);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should check ng-non-bindable', function() {
|
||||
expect(element(by.binding('1 + 2')).getText()).toContain('3');
|
||||
expect(element.all(by.css('.doc-example-live div')).last().getText()).toMatch(/1 \+ 2/);
|
||||
expect(element.all(by.css('div')).last().getText()).toMatch(/1 \+ 2/);
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
|
||||
@@ -172,9 +172,8 @@
|
||||
max-height:40px;
|
||||
}
|
||||
</file>
|
||||
<file name="protractorTest.js">
|
||||
var friends = element(by.css('.doc-example-live'))
|
||||
.element.all(by.repeater('friend in friends'));
|
||||
<file name="protractor.js" type="protractor">
|
||||
var friends = element.all(by.repeater('friend in friends'));
|
||||
|
||||
it('should render initial data set', function() {
|
||||
expect(friends.count()).toBe(10);
|
||||
@@ -188,7 +187,7 @@
|
||||
it('should update repeater when filter predicate changes', function() {
|
||||
expect(friends.count()).toBe(10);
|
||||
|
||||
element(by.css('.doc-example-live')).element(by.model('q')).sendKeys('ma');
|
||||
element(by.model('q')).sendKeys('ma');
|
||||
|
||||
expect(friends.count()).toBe(2);
|
||||
expect(friends.get(0).getText()).toEqual('[1] Mary who is 28 years old.');
|
||||
|
||||
@@ -132,9 +132,9 @@
|
||||
background:white;
|
||||
}
|
||||
</file>
|
||||
<file name="protractorTest.js">
|
||||
var thumbsUp = element(by.css('.doc-example-live span.icon-thumbs-up'));
|
||||
var thumbsDown = element(by.css('.doc-example-live span.icon-thumbs-down'));
|
||||
<file name="protractor.js" type="protractor">
|
||||
var thumbsUp = element(by.css('span.icon-thumbs-up'));
|
||||
var thumbsDown = element(by.css('span.icon-thumbs-down'));
|
||||
|
||||
it('should check ng-show / ng-hide', function() {
|
||||
expect(thumbsUp.isDisplayed()).toBeFalsy();
|
||||
@@ -289,9 +289,9 @@ var ngShowDirective = ['$animate', function($animate) {
|
||||
background:white;
|
||||
}
|
||||
</file>
|
||||
<file name="protractorTest.js">
|
||||
var thumbsUp = element(by.css('.doc-example-live span.icon-thumbs-up'));
|
||||
var thumbsDown = element(by.css('.doc-example-live span.icon-thumbs-down'));
|
||||
<file name="protractor.js" type="protractor">
|
||||
var thumbsUp = element(by.css('span.icon-thumbs-up'));
|
||||
var thumbsDown = element(by.css('span.icon-thumbs-down'));
|
||||
|
||||
it('should check ng-show / ng-hide', function() {
|
||||
expect(thumbsUp.isDisplayed()).toBeFalsy();
|
||||
|
||||
@@ -27,14 +27,14 @@
|
||||
color: black;
|
||||
}
|
||||
</file>
|
||||
<file name="protractorTest.js">
|
||||
var colorSpan = element(by.css('.doc-example-live span'));
|
||||
<file name="protractor.js" type="protractor">
|
||||
var colorSpan = element(by.css('span'));
|
||||
|
||||
it('should check ng-style', function() {
|
||||
expect(colorSpan.getCssValue('color')).toBe('rgba(0, 0, 0, 1)');
|
||||
element(by.css('.doc-example-live input[value=set]')).click();
|
||||
element(by.css('input[value=set]')).click();
|
||||
expect(colorSpan.getCssValue('color')).toBe('rgba(255, 0, 0, 1)');
|
||||
element(by.css('.doc-example-live input[value=clear]')).click();
|
||||
element(by.css('input[value=clear]')).click();
|
||||
expect(colorSpan.getCssValue('color')).toBe('rgba(0, 0, 0, 1)');
|
||||
});
|
||||
</file>
|
||||
|
||||
@@ -107,8 +107,8 @@
|
||||
top:0;
|
||||
}
|
||||
</file>
|
||||
<file name="protractorTest.js">
|
||||
var switchElem = element(by.css('.doc-example-live [ng-switch]'));
|
||||
<file name="protractor.js" type="protractor">
|
||||
var switchElem = element(by.css('[ng-switch]'));
|
||||
var select = element(by.model('selection'));
|
||||
|
||||
it('should start in settings', function() {
|
||||
|
||||
@@ -631,7 +631,7 @@ function $HttpProvider() {
|
||||
<file name="http-hello.html">
|
||||
Hello, $http!
|
||||
</file>
|
||||
<file name="protractorTest.js">
|
||||
<file name="protractor.js" type="protractor">
|
||||
var status = element(by.binding('status'));
|
||||
var data = element(by.binding('data'));
|
||||
var fetchBtn = element(by.id('fetchbtn'));
|
||||
|
||||
@@ -619,7 +619,7 @@ function $SceDelegateProvider() {
|
||||
]
|
||||
</file>
|
||||
|
||||
<file name="protractorTest.js">
|
||||
<file name="protractor.js" type="protractor">
|
||||
describe('SCE doc demo', function() {
|
||||
it('should sanitize untrusted values', function() {
|
||||
expect(element(by.css('.htmlComment')).getInnerHtml())
|
||||
|
||||
@@ -151,17 +151,17 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory);
|
||||
}
|
||||
</file>
|
||||
|
||||
<file name="protractorTest.js">
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should load and compile correct template', function() {
|
||||
element(by.linkText('Moby: Ch1')).click();
|
||||
var content = element(by.css('.doc-example-live [ng-view]')).getText();
|
||||
var content = element(by.css('[ng-view]')).getText();
|
||||
expect(content).toMatch(/controller\: ChapterCntl/);
|
||||
expect(content).toMatch(/Book Id\: Moby/);
|
||||
expect(content).toMatch(/Chapter Id\: 1/);
|
||||
|
||||
element(by.partialLinkText('Scarlet')).click();
|
||||
|
||||
content = element(by.css('.doc-example-live [ng-view]')).getText();
|
||||
content = element(by.css('[ng-view]')).getText();
|
||||
expect(content).toMatch(/controller\: BookCntl/);
|
||||
expect(content).toMatch(/Book Id\: Scarlet/);
|
||||
});
|
||||
|
||||
@@ -343,17 +343,17 @@ function $RouteProvider(){
|
||||
}
|
||||
</file>
|
||||
|
||||
<file name="protractorTest.js">
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should load and compile correct template', function() {
|
||||
element(by.linkText('Moby: Ch1')).click();
|
||||
var content = element(by.css('.doc-example-live [ng-view]')).getText();
|
||||
var content = element(by.css('[ng-view]')).getText();
|
||||
expect(content).toMatch(/controller\: ChapterCntl/);
|
||||
expect(content).toMatch(/Book Id\: Moby/);
|
||||
expect(content).toMatch(/Chapter Id\: 1/);
|
||||
|
||||
element(by.partialLinkText('Scarlet')).click();
|
||||
|
||||
content = element(by.css('.doc-example-live [ng-view]')).getText();
|
||||
content = element(by.css('[ng-view]')).getText();
|
||||
expect(content).toMatch(/controller\: BookCntl/);
|
||||
expect(content).toMatch(/Book Id\: Scarlet/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user