This repository was archived by the owner on Apr 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 185
Expand file tree
/
Copy pathangularjs.org.spec.js
More file actions
202 lines (153 loc) · 7.33 KB
/
Copy pathangularjs.org.spec.js
File metadata and controls
202 lines (153 loc) · 7.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
describe('Angularjs.org', function () {
var webdriver = require('selenium-webdriver');
describe('App', function () {
beforeEach(function () {
browser.get('');
});
it('should have the correct version of angularjs loaded', function() {
//This only runs if an environment variable tells us to check
if (process.env.CHECK_SCRIPT_TAG !== 'true') return;
var scriptTag = browser.findElement(by.css('script#angularScript'));
expect(scriptTag.getAttribute('src')).
toContain(process.env.ANGULAR_VERSION);
});
it('should load the web page', function () {
var body = browser.findElement(by.css('body'));
expect(body.getAttribute('ng-controller')).toEqual('AppController');
});
describe('Download', function () {
var stableVersion, cdnInput,
downloadVersions = process.env.ANGULAR_DOWNLOAD_VERSIONS.split(' ');
beforeEach(function () {
var downloadBtn = browser.findElement(by.css('.download-btn')), done;
downloadBtn.click();
browser.driver.sleep(500);
cdnInput = browser.findElement(by.css('#cdnURL'));
cdnInput.getAttribute('value');
cdnInput.getText().then(function (text) {
stableVersion = text.toString().split('/').splice(-2,1)[0];
});
});
it('should open a modal prompting for download configuration', function () {
var downloadModal = browser.findElement(by.css('.download-modal'))
expect(downloadModal.getCssValue('display')).toEqual('block');
});
it('should change the CDN url based on user selection of stable or unstable', function () {
var okay;
var unstableButton = browser.findElement(by.css(".branch-btns button:nth-child(1)"));
browser.driver.sleep(500);
unstableButton.click();
cdnInput.getAttribute('value').then(function (val) {
var unstableVersion = val.split('/').splice(-2,1)[0];
for (i = 0; i < unstableVersion.split('.').length; i++) {
if (unstableVersion.split('.')[i] > stableVersion.split('.')[i]) {
okay = true;
break;
}
}
expect(okay).toBe(true);
});
});
downloadVersions.forEach(function(version) {
it('should have the correct version available for download ' + version, function () {
var versionAndBranch = version.split(':'),
branchBtnSelector = '.branch-' + versionAndBranch[1].
replace(/\./g, '-').
replace(/\*/g, 'x'),
branchBtn = browser.findElement(
by.css(branchBtnSelector));
branchBtn.click();
expect(cdnInput.getAttribute('value')).
toContain(versionAndBranch[0]);
});
});
it('should allow downloading uncompressed AngularJS', function () {
var uncompressedBtn = browser.findElement(
by.css(
'.download-modal .modal-body > dl button.uncompressed'));
uncompressedBtn.click();
expect(cdnInput.getAttribute('value')).toContain('angular.js');
});
it('should have a working close button', function () {
var closeButton = browser.findElement(by.css('.download-modal .modal-header button.close'));
closeButton.click();
browser.driver.sleep(300);
expect(element(by.css('.download-modal')).isPresent()).toBe(false);
});
describe('explanatory popover', function() {
['Branches', 'Builds', 'Why Google CDN?','What is Bower?'].forEach(function(value) {
it('should be displayed for ' + value, function () {
var popoverButton = browser.findElement(by.css('.download-modal [popover-title="'+value+'"]'));
popoverButton.click();
var popover = browser.findElement(by.css('.popover'));
expect(popover.getCssValue('display')).toEqual('block');
});
});
});
});
describe('The Basics', function () {
it('should show the code example', function () {
var hello = browser.findElement(by.css('[app-source="hello.html"]'));
expect(hello.getText()).toContain('{{yourName}}');
});
it('should have a hoverable region called ng-app', function () {
var noCode = browser.findElement(by.css('[popover-title="ng-app"]'))
expect(noCode.getText()).toEqual('ng-app');
});
it('should update the Hello text after entering a name', function () {
var el = browser.findElement(by.model('yourName'));
el.click()
el.sendKeys('Jeff')
var bound = browser.findElement(by.css('[app-run="hello.html"] h1'));
expect(bound.getText()).toEqual('Hello Jeff!');
});
});
describe('Add Some Control', function () {
it('should strike out a todo when clicked', function () {
var el = browser.findElement(by.css('[ng-controller="TodoListController as todoList"] ul >li:nth-child(2) input'));
el.click();
expect(el.getAttribute('value')).toBe('on');
});
it('should add a new todo when added through text field', function () {
var el = browser.findElement(by.model('todoList.todoText'));
el.click();
el.sendKeys('Write tests!');
el.sendKeys(webdriver.Key.RETURN);
var lastTodo = browser.findElement(by.css('[ng-repeat="todo in todoList.todos"]:nth-child(3) span'));
expect(lastTodo.getText()).toEqual('Write tests!');
});
it('should show a secondary tab when selected', function () {
var todoJsTab = browser.findElement(by.css('[annotate="todo.annotation"] ul.nav-tabs li:nth-child(2) a'));
todoJsTab.click()
browser.driver.sleep(500);
var todojs = browser.findElement(by.css('[annotate="todo.annotation"] .tab-pane:nth-child(2)'));
expect(todojs.getCssValue('display')).toEqual('block');
});
});
describe('Create Components', function () {
it('should show the US localization of date', function () {
var dateText = browser.findElement(by.css('[module="app-us"] .tab-content > .tab-pane > span:first-child'));
var text = dateText.getText();
expect(text).toMatch(/^Date: [A-Za-z]*, [A-Za-z]+ [0-9]{1,2}, [0-9]{4}$/);
});
/*it('should show the US pluralization of beer', function () {
var pluralTabLink = browser.findElement(by.css('[module="app-us"] .nav-tabs > li:nth-child(2) a'));
pluralTabLink.click()
var pluralTab = browser.findElement(by.css('[module="app-us"] [ng-controller="BeerCounter"] > div > ng-pluralize'));
expect(pluralTab.getText()).toEqual('no beers');
});
it('should show the Slovak pluralization of beer', function () {
var pluralTabLink = browser.findElement(by.css('[module="app-sk"] .nav-tabs > li:nth-child(2) a'));
pluralTabLink.click();
var pluralTab = browser.findElement(by.css('[module="app-sk"] [ng-controller="BeerCounter"] > div > ng-pluralize'));
expect(pluralTab.getText()).toEqual('žiadne pivo');
});*/
});
describe('Testability Built-in', function () {
it('should have some content under and "Testability Built-in" heading', function () {
var testability = browser.findElement(by.css('#testability'))
expect(testability.getText()).toEqual('Testability Built-in');
});
});
});
});