Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit e91659a

Browse files
committed
docs(tutorial/ts): delete tutorial sample in favor of toh-6
1 parent e4db340 commit e91659a

24 files changed

+134
-550
lines changed

public/docs/_examples/toh-4/ts/app/mock-heroes.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
import { Hero } from './hero';
33

44
export var HEROES: Hero[] = [
5-
{"id": 11, "name": "Mr. Nice"},
6-
{"id": 12, "name": "Narco"},
7-
{"id": 13, "name": "Bombasto"},
8-
{"id": 14, "name": "Celeritas"},
9-
{"id": 15, "name": "Magneta"},
10-
{"id": 16, "name": "RubberMan"},
11-
{"id": 17, "name": "Dynama"},
12-
{"id": 18, "name": "Dr IQ"},
13-
{"id": 19, "name": "Magma"},
14-
{"id": 20, "name": "Tornado"}
5+
{id: 11, name: 'Mr. Nice'},
6+
{id: 12, name: 'Narco'},
7+
{id: 13, name: 'Bombasto'},
8+
{id: 14, name: 'Celeritas'},
9+
{id: 15, name: 'Magneta'},
10+
{id: 16, name: 'RubberMan'},
11+
{id: 17, name: 'Dynama'},
12+
{id: 18, name: 'Dr IQ'},
13+
{id: 19, name: 'Magma'},
14+
{id: 20, name: 'Tornado'}
1515
];
1616
// #enddocregion

public/docs/_examples/toh-5/ts/app/mock-heroes.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
import { Hero } from './hero';
33

44
export var HEROES: Hero[] = [
5-
{"id": 11, "name": "Mr. Nice"},
6-
{"id": 12, "name": "Narco"},
7-
{"id": 13, "name": "Bombasto"},
8-
{"id": 14, "name": "Celeritas"},
9-
{"id": 15, "name": "Magneta"},
10-
{"id": 16, "name": "RubberMan"},
11-
{"id": 17, "name": "Dynama"},
12-
{"id": 18, "name": "Dr IQ"},
13-
{"id": 19, "name": "Magma"},
14-
{"id": 20, "name": "Tornado"}
5+
{id: 11, name: 'Mr. Nice'},
6+
{id: 12, name: 'Narco'},
7+
{id: 13, name: 'Bombasto'},
8+
{id: 14, name: 'Celeritas'},
9+
{id: 15, name: 'Magneta'},
10+
{id: 16, name: 'RubberMan'},
11+
{id: 17, name: 'Dynama'},
12+
{id: 18, name: 'Dr IQ'},
13+
{id: 19, name: 'Magma'},
14+
{id: 20, name: 'Tornado'}
1515
];
16-
// #enddocregion
16+
// #enddocregion

public/docs/_examples/toh-6/e2e-spec.js

Lines changed: 102 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('TOH Http Chapter', function () {
1616
myHeroesHref: hrefEles.get(1),
1717
myHeroesParent: element(by.css('my-app my-heroes')),
1818
allHeroes: element.all(by.css('my-app my-heroes li .hero-element')),
19-
19+
2020
firstDeleteButton: element.all(by.buttonText('Delete')).get(0),
2121

2222
addButton: element.all(by.buttonText('Add New Hero')).get(0),
@@ -28,21 +28,21 @@ describe('TOH Http Chapter', function () {
2828
it('should be able to add a hero from the "Heroes" view', function(){
2929
var page = getPageStruct();
3030
var heroCount;
31-
31+
3232
page.myHeroesHref.click().then(function() {
3333
browser.waitForAngular();
3434
heroCount = page.allHeroes.count();
35-
expect(heroCount).toBe(4, 'should show 4');
35+
expect(heroCount).toBe(10, 'should show 10');
3636
}).then(function() {
3737
return page.addButton.click();
3838
}).then(function(){
3939
return save(page,'','The New Hero');
4040
}).then(function(){
4141
browser.waitForAngular();
42-
42+
4343
heroCount = page.allHeroes.count();
44-
expect(heroCount).toBe(5, 'should show 5');
45-
44+
expect(heroCount).toBe(11, 'should show 11');
45+
4646
var newHero = element(by.xpath('//span[@class="hero-element" and contains(text(),"The New Hero")]'));
4747
expect(newHero).toBeDefined();
4848
});
@@ -51,17 +51,17 @@ describe('TOH Http Chapter', function () {
5151
it('should be able to delete hero from "Heroes" view', function(){
5252
var page = getPageStruct();
5353
var heroCount;
54-
54+
5555
page.myHeroesHref.click().then(function() {
5656
browser.waitForAngular();
5757
heroCount = page.allHeroes.count();
58-
expect(heroCount).toBe(4, 'should show 4');
58+
expect(heroCount).toBe(10, 'should show 10');
5959
}).then(function() {
6060
return page.firstDeleteButton.click();
6161
}).then(function(){
6262
browser.waitForAngular();
6363
heroCount = page.allHeroes.count();
64-
expect(heroCount).toBe(3, 'should show 3');
64+
expect(heroCount).toBe(9, 'should show 9');
6565
});
6666
});
6767

@@ -71,7 +71,7 @@ describe('TOH Http Chapter', function () {
7171
var heroEle = page.topHeroes.get(2);
7272
var heroDescrEle = heroEle.element(by.css('h4'));
7373
var heroDescr;
74-
74+
7575
return heroDescrEle.getText().then(function(text) {
7676
heroDescr = text;
7777
return heroEle.click();
@@ -89,10 +89,10 @@ describe('TOH Http Chapter', function () {
8989

9090
it('should be able to save details from "Heroes" view', function () {
9191
var page = getPageStruct();
92-
92+
9393
var viewDetailsButtonEle = page.myHeroesParent.element(by.cssContainingText('button', 'View Details'));
9494
var heroEle, heroDescr;
95-
95+
9696
page.myHeroesHref.click().then(function() {
9797
expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present');
9898
expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be present');
@@ -130,4 +130,94 @@ describe('TOH Http Chapter', function () {
130130
return saveButtonEle.click();
131131
});
132132
}
133+
134+
it('should be able to see the start screen', function () {
135+
var page = getPageStruct();
136+
expect(page.hrefs.count()).toEqual(2, 'should be two dashboard choices');
137+
expect(page.myDashboardHref.getText()).toEqual("Dashboard");
138+
expect(page.myHeroesHref.getText()).toEqual("Heroes");
139+
});
140+
141+
it('should be able to see dashboard choices', function () {
142+
var page = getPageStruct();
143+
expect(page.topHeroes.count()).toBe(4, "should be 4 dashboard hero choices");
144+
});
145+
146+
it('should be able to toggle the views', function () {
147+
var page = getPageStruct();
148+
149+
expect(page.myDashboardParent.element(by.css('h3')).getText()).toEqual('Top Heroes');
150+
page.myHeroesHref.click().then(function() {
151+
expect(page.myDashboardParent.isPresent()).toBe(false, 'should no longer see dashboard element');
152+
expect(page.allHeroes.count()).toBeGreaterThan(4, "should be more than 4 heroes shown");
153+
return page.myDashboardHref.click();
154+
}).then(function() {
155+
expect(page.myDashboardParent.isPresent()).toBe(true, 'should once again see the dashboard element');
156+
});
157+
158+
});
159+
160+
it('should be able to edit details from "Dashboard" view', function () {
161+
var page = getPageStruct();
162+
expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be available');
163+
var heroEle = page.topHeroes.get(3);
164+
var heroDescrEle = heroEle.element(by.css('h4'));
165+
var heroDescr;
166+
return heroDescrEle.getText().then(function(text) {
167+
heroDescr = text;
168+
return heroEle.click();
169+
}).then(function() {
170+
return editDetails(page, heroDescr, '-foo');
171+
}).then(function() {
172+
expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be back');
173+
expect(heroDescrEle.getText()).toEqual(heroDescr + '-foo');
174+
});
175+
});
176+
177+
it('should be able to edit details from "Heroes" view', function () {
178+
var page = getPageStruct();
179+
expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be present');
180+
var viewDetailsButtonEle = page.myHeroesParent.element(by.cssContainingText('button', 'View Details'));
181+
var heroEle, heroDescr;
182+
page.myHeroesHref.click().then(function() {
183+
expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present');
184+
expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be present');
185+
expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should not yet be present');
186+
heroEle = page.allHeroes.get(2);
187+
return heroEle.getText();
188+
}).then(function(text) {
189+
// remove leading 'id' from the element
190+
heroDescr = text.substr(text.indexOf(' ')+1);
191+
return heroEle.click();
192+
}).then(function() {
193+
expect(viewDetailsButtonEle.isDisplayed()).toBe(true, 'viewDetails button should now be visible');
194+
return viewDetailsButtonEle.click();
195+
}).then(function() {
196+
return editDetails(page, heroDescr, '-bar');
197+
}).then(function() {
198+
expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be back');
199+
expect(heroEle.getText()).toContain(heroDescr + '-bar');
200+
expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should again NOT be present');
201+
});
202+
});
203+
204+
function editDetails(page, origValue, textToAdd) {
205+
expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present');
206+
expect(page.myHeroesParent.isPresent()).toBe(false, 'myHeroes element should NOT be present');
207+
expect(page.heroDetail.isDisplayed()).toBe(true, 'should be able to see hero-details');
208+
var inputEle = page.heroDetail.element(by.css('input'));
209+
expect(inputEle.isDisplayed()).toBe(true, 'should be able to see the input box');
210+
var buttons = page.heroDetail.all(by.css('button'));
211+
var backButtonEle = buttons.get(0);
212+
var saveButtonEle = buttons.get(1);
213+
expect(backButtonEle.isDisplayed()).toBe(true, 'should be able to see the back button');
214+
expect(saveButtonEle.isDisplayed()).toBe(true, 'should be able to see the save button');
215+
var detailTextEle = page.heroDetail.element(by.css('div h2'));
216+
expect(detailTextEle.getText()).toContain(origValue);
217+
return sendKeys(inputEle, textToAdd).then(function () {
218+
expect(detailTextEle.getText()).toContain(origValue + textToAdd);
219+
return saveButtonEle.click();
220+
});
221+
}
222+
133223
});

public/docs/_examples/toh-6/ts/app/in-memory-data.service.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22
export class InMemoryDataService {
33
createDb() {
44
let heroes = [
5-
{ id: 1, name: 'Windstorm' },
6-
{ id: 2, name: 'Bombasto' },
7-
{ id: 3, name: 'Magneta' },
8-
{ id: 4, name: 'Tornado' }
5+
{id: 11, name: 'Mr. Nice'},
6+
{id: 12, name: 'Narco'},
7+
{id: 13, name: 'Bombasto'},
8+
{id: 14, name: 'Celeritas'},
9+
{id: 15, name: 'Magneta'},
10+
{id: 16, name: 'RubberMan'},
11+
{id: 17, name: 'Dynama'},
12+
{id: 18, name: 'Dr IQ'},
13+
{id: 19, name: 'Magma'},
14+
{id: 20, name: 'Tornado'}
915
];
1016
return {heroes};
1117
}

public/docs/_examples/tutorial/e2e-spec.js

Lines changed: 0 additions & 111 deletions
This file was deleted.

public/docs/_examples/tutorial/ts/app/app.component.css

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)