Skip to content

Commit 3b0d0e2

Browse files
chalinfiliph
authored andcommitted
[ng] ng.io sync for misc minor updates (#312)
* config file sync * e2e test update * s/falsey/falsy * src/resources/js/util.js fix for IE11 - angular.io/pull/3095 angular/angular.io#3095 * cache.sh: exclude files that we no longer sync
1 parent 729f742 commit 3b0d0e2

File tree

9 files changed

+102
-54
lines changed

9 files changed

+102
-54
lines changed

gulp/ngio-get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ module.exports = function (gulp, plugins, config) {
230230
// Patch live-example.js
231231
.pipe(replace(/target: '_blank/g, '$&" rel="noopener'))
232232
// Patch resources/js/util.js
233-
.pipe(replace("loc.includes('/docs/' + lang + '/')", "loc.includes('/angular/')"))
233+
.pipe(replace("loc.indexOf('/docs/' + lang + '/')", "loc.indexOf('/angular/')"))
234234
.pipe(gulp.dest('src'));
235235
});
236236

public/docs/_examples/_boilerplate/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"sourceMap": true,
77
"emitDecoratorMetadata": true,
88
"experimentalDecorators": true,
9-
"lib": ["es2015", "dom"],
9+
"lib": [ "es2015", "dom" ],
1010
"noImplicitAny": true,
1111
"suppressImplicitAnyIndexErrors": true,
1212
"typeRoots": [
Lines changed: 87 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,103 @@
1-
import { browser, element, by } from 'protractor';
1+
'use strict'; // necessary for es6 output in node
22

3-
describe('Hierarchical dependency injection', function () {
3+
import { browser, by, element } from 'protractor';
44

5-
beforeEach(function () {
5+
describe('Hierarchical dependency injection', () => {
6+
7+
beforeAll(() => {
68
browser.get('');
79
});
810

9-
it('should open with a card view', function () {
10-
expect(element.all(by.cssContainingText('button', 'edit')).get(0).isDisplayed()).toBe(true,
11-
'edit button should be displayed');
12-
});
11+
describe('Heroes Scenario', () => {
12+
let page = {
13+
heroName: '',
14+
income: '',
1315

14-
it('should have multiple heroes listed', function () {
15-
expect(element.all(by.css('heroes-list li')).count()).toBeGreaterThan(1);
16-
});
16+
// queries
17+
heroEl: element.all(by.css('heroes-list li')).get(0), // first hero
18+
heroCardEl: element(by.css('heroes-list hero-tax-return')), // first hero tax-return
19+
taxReturnNameEl: element.all(by.css('heroes-list hero-tax-return #name')).get(0),
20+
incomeInputEl: element.all(by.css('heroes-list hero-tax-return input')).get(0),
21+
cancelButtonEl: element(by.cssContainingText('heroes-list hero-tax-return button', 'Cancel')),
22+
closeButtonEl: element(by.cssContainingText('heroes-list hero-tax-return button', 'Close')),
23+
saveButtonEl: element(by.cssContainingText('heroes-list hero-tax-return button', 'Save'))
24+
};
1725

18-
it('should change to editor view after selection', function () {
19-
let editButtonEle = element.all(by.cssContainingText('button', 'edit')).get(0);
20-
editButtonEle.click().then(function() {
21-
expect(editButtonEle.isDisplayed()).toBe(false, 'edit button should be hidden after selection');
26+
it('should list multiple heroes', () => {
27+
expect(element.all(by.css('heroes-list li')).count()).toBeGreaterThan(1);
28+
});
29+
30+
it('should show no hero tax-returns at the start', () => {
31+
expect(element.all(by.css('heroes-list li hero-tax-return')).count()).toBe(0);
32+
});
33+
34+
it('should open first hero in hero-tax-return view after click', () => {
35+
page.heroEl.getText()
36+
.then(val => {
37+
page.heroName = val;
38+
})
39+
.then(() => page.heroEl.click())
40+
.then(() => {
41+
expect(page.heroCardEl.isDisplayed()).toBe(true);
42+
});
43+
});
44+
45+
it('hero tax-return should have first hero\'s name', () => {
46+
// Not `page.tax-returnNameInputEl.getAttribute('value')` although later that is essential
47+
expect(page.taxReturnNameEl.getText()).toEqual(page.heroName);
48+
});
49+
50+
it('should be able to cancel change', () => {
51+
page.incomeInputEl.clear()
52+
.then(() => page.incomeInputEl.sendKeys('777'))
53+
.then(() => {
54+
expect(page.incomeInputEl.getAttribute('value')).toBe('777', 'income should be 777');
55+
return page.cancelButtonEl.click();
56+
})
57+
.then(() => {
58+
expect(page.incomeInputEl.getAttribute('value')).not.toBe('777', 'income should not be 777');
59+
});
60+
});
61+
62+
it('should be able to save change', () => {
63+
page.incomeInputEl.clear()
64+
.then(() => page.incomeInputEl.sendKeys('999'))
65+
.then(() => {
66+
expect(page.incomeInputEl.getAttribute('value')).toBe('999', 'income should be 999');
67+
return page.saveButtonEl.click();
68+
})
69+
.then(() => {
70+
expect(page.incomeInputEl.getAttribute('value')).toBe('999', 'income should still be 999');
71+
});
72+
});
73+
74+
it('should be able to close tax-return', () => {
75+
page.saveButtonEl.click()
76+
.then(() => {
77+
expect(element.all(by.css('heroes-list li hero-tax-return')).count()).toBe(0);
78+
});
2279
});
23-
});
2480

25-
it('should be able to save editor change', function () {
26-
testEdit(true);
2781
});
2882

29-
it('should be able to cancel editor change', function () {
30-
testEdit(false);
83+
describe('Villains Scenario', () => {
84+
it('should list multiple villains', () => {
85+
expect(element.all(by.css('villains-list li')).count()).toBeGreaterThan(1);
86+
});
3187
});
3288

33-
function testEdit(shouldSave: boolean) {
34-
// select 2nd ele
35-
let heroEle = element.all(by.css('heroes-list li')).get(1);
36-
// get the 2nd span which is the name of the hero
37-
let heroNameEle = heroEle.all(by.css('hero-card span')).get(1);
38-
let editButtonEle = heroEle.element(by.cssContainingText('button', 'edit'));
39-
editButtonEle.click().then(function() {
40-
let inputEle = heroEle.element(by.css('hero-editor input'));
41-
return inputEle.sendKeys('foo');
42-
}).then(function() {
43-
let buttonName = shouldSave ? 'save' : 'cancel';
44-
let buttonEle = heroEle.element(by.cssContainingText('button', buttonName));
45-
return buttonEle.click();
46-
}).then(function() {
47-
if (shouldSave) {
48-
expect(heroNameEle.getText()).toContain('foo');
49-
} else {
50-
expect(heroNameEle.getText()).not.toContain('foo');
51-
}
52-
});
53-
}
89+
describe('Cars Scenario', () => {
5490

91+
it('A-component should use expected services', () => {
92+
expect(element(by.css('a-car')).getText()).toContain('C1-E1-T1');
93+
});
94+
95+
it('B-component should use expected services', () => {
96+
expect(element(by.css('b-car')).getText()).toContain('C2-E2-T1');
97+
});
5598

99+
it('C-component should use expected services', () => {
100+
expect(element(by.css('c-car')).getText()).toContain('C3-E2-T1');
101+
});
102+
});
56103
});

public/docs/_examples/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
"@angular/router": "~3.4.0",
2525
"@angular/tsc-wrapped": "^0.5.0",
2626
"@angular/upgrade": "~2.4.0",
27-
"angular-in-memory-web-api": "~0.2.2",
27+
"angular-in-memory-web-api": "~0.2.4",
2828
"core-js": "^2.4.1",
29-
"reflect-metadata": "^0.1.8",
3029
"rxjs": "5.0.1",
3130
"systemjs": "0.19.39",
3231
"zone.js": "^0.7.4"

scripts/cache.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,26 @@ CACHE="$BASE/_cache"
1515
FILES="
1616
guide/architecture.jade
1717
guide/attribute-directives.jade
18-
guide/component-styles.jade
1918
guide/dependency-injection.jade
2019
guide/displaying-data.jade
2120
guide/hierarchical-dependency-injection.jade
2221
guide/index.jade
2322
guide/learning-angular.jade
2423
guide/lifecycle-hooks.jade
25-
guide/pipes.jade
2624
guide/security.jade
2725
guide/server-communication.jade
28-
guide/structural-directives.jade
29-
guide/template-syntax.jade
3026
glossary.jade
3127
quickstart.jade
3228
_quickstart_repo.jade
3329
tutorial/index.jade
3430
tutorial/toh-pt5.jade
3531
tutorial/toh-pt6.jade"
32+
FILES_NO_LONGER_SYNCED="
33+
guide/component-styles.jade
34+
guide/pipes.jade
35+
guide/structural-directives.jade
36+
guide/template-syntax.jade
37+
"
3638

3739
function cacheRefresh() {
3840
local FILE_PATTERN="*"

src/angular/_jade/_util-fns.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
//- Other
5959
- var _truthy = 'truthy';
60-
- var _falsey = 'falsey';
60+
- var _falsy = 'falsy';
6161

6262
//- Used to prefix identifiers that are private. In Dart this will be '_'.
6363
- var _priv = '';

src/angular/_util-fns.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ include /_jade/_util-fns
1515
- var _Observable = 'Stream';
1616
- var _liveLink = 'sample repo';
1717
- var _truthy = 'true';
18-
- var _falsey = 'false';
18+
- var _falsy = 'false';
1919
- var _appDir = 'lib';
2020
- var _indexHtmlDir = 'web';
2121
- var _mainDir = 'web';

src/angular/guide/template-syntax.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ code-example(format="nocode").
695695
:marked
696696
Finally, we can bind to a specific class name.
697697
Angular adds the class when the template expression evaluates to #{_truthy}.
698-
It removes the class when the expression is #{_falsey}.
698+
It removes the class when the expression is #{_falsy}.
699699
+makeExample('template-syntax/ts/app/app.component.html', 'class-binding-3')(format=".")
700700

701701
.l-sub-section
@@ -1075,7 +1075,7 @@ figure.image-display
10751075
Don't forget the asterisk (`*`) in front of `ngIf`.
10761076
For more information, see [\* and <template>](#star-template).
10771077
:marked
1078-
Binding to a #{_falsey} expression removes the element subtree from the DOM.
1078+
Binding to a #{_falsy} expression removes the element subtree from the DOM.
10791079
+makeExample('template-syntax/ts/app/app.component.html', 'NgIf-2')(format=".")
10801080

10811081
.callout.is-helpful

src/resources/js/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var NgIoUtil = (function () {
66

77
NgIoUtil.isDoc = function ($location, lang) {
88
var loc = $location.absUrl();
9-
return loc.includes('/angular/');
9+
return loc.indexOf('/angular/') >= 0;
1010
};
1111

1212
// The following util functions are adapted from _utils-fn.jade.
@@ -19,7 +19,7 @@ var NgIoUtil = (function () {
1919
*
2020
* - app/main.ts -> web/main.dart
2121
* - displaying-data/ts/app/app.component.2.ts -> displaying-data/dart/lib/app_component.dart
22-
*
22+
*
2323
* Notice that the '.2' is dropped from the name.
2424
*/
2525
if (!_path) return _path;

0 commit comments

Comments
 (0)