2017-02-22 18:13:21 +00:00
|
|
|
import { browser, element, by } from 'protractor';
|
|
|
|
|
2020-07-30 13:03:13 +03:00
|
|
|
describe('Pipes', () => {
|
2017-02-22 18:13:21 +00:00
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
beforeAll(() => browser.get(''));
|
2017-02-22 18:13:21 +00:00
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
it('should open correctly', async () => {
|
|
|
|
expect(await element.all(by.tagName('h1')).get(0).getText()).toEqual('Pipes');
|
|
|
|
expect(await element(by.css('app-hero-birthday p')).getText()).toEqual(`The hero's birthday is Apr 15, 1988`);
|
2017-02-22 18:13:21 +00:00
|
|
|
});
|
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
it('should show 4 heroes', async () => {
|
|
|
|
expect(await element.all(by.css('app-hero-list div')).count()).toEqual(4);
|
2017-02-22 18:13:21 +00:00
|
|
|
});
|
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
it('should show a familiar hero in json', async () => {
|
|
|
|
expect(await element(by.cssContainingText('app-hero-list p', 'Heroes as JSON')).getText()).toContain('Bombasto');
|
2017-02-22 18:13:21 +00:00
|
|
|
});
|
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
it('should show alternate birthday formats', async () => {
|
|
|
|
expect(await element(by.cssContainingText('app-root > p', `The hero's birthday is Apr 15, 1988`)).isDisplayed())
|
|
|
|
.toBe(true);
|
|
|
|
expect(await element(by.cssContainingText('app-root > p', `The hero's birthday is 04/15/88`)).isDisplayed())
|
|
|
|
.toBe(true);
|
2017-02-22 18:13:21 +00:00
|
|
|
});
|
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
it('should be able to toggle birthday formats', async () => {
|
2020-07-30 13:03:19 +03:00
|
|
|
const birthDayEle = element(by.css('app-hero-birthday2 > p'));
|
2020-11-23 20:17:10 +02:00
|
|
|
expect(await birthDayEle.getText()).toEqual(`The hero's birthday is 4/15/88`);
|
|
|
|
|
2020-07-30 13:03:19 +03:00
|
|
|
const buttonEle = element(by.cssContainingText('app-hero-birthday2 > button', 'Toggle Format'));
|
2020-11-23 20:17:10 +02:00
|
|
|
expect(await buttonEle.isDisplayed()).toBe(true);
|
|
|
|
|
|
|
|
await buttonEle.click();
|
|
|
|
expect(await birthDayEle.getText()).toEqual(`The hero's birthday is Friday, April 15, 1988`);
|
2017-02-22 18:13:21 +00:00
|
|
|
});
|
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
it('should be able to chain and compose pipes', async () => {
|
2020-07-30 13:03:19 +03:00
|
|
|
const chainedPipeEles = element.all(by.cssContainingText('app-root p', `The chained hero's`));
|
2020-11-23 20:17:10 +02:00
|
|
|
expect(await chainedPipeEles.count()).toBe(3, 'should have 3 chained pipe examples');
|
|
|
|
expect(await chainedPipeEles.get(0).getText()).toContain('APR 15, 1988');
|
|
|
|
expect(await chainedPipeEles.get(1).getText()).toContain('FRIDAY, APRIL 15, 1988');
|
|
|
|
expect(await chainedPipeEles.get(2).getText()).toContain('FRIDAY, APRIL 15, 1988');
|
2017-02-22 18:13:21 +00:00
|
|
|
});
|
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
it('should be able to use ExponentialStrengthPipe pipe', async () => {
|
2020-07-30 13:03:19 +03:00
|
|
|
const ele = element(by.css('app-power-booster p'));
|
2020-11-23 20:17:10 +02:00
|
|
|
expect(await ele.getText()).toContain('Super power boost: 1024');
|
2017-02-22 18:13:21 +00:00
|
|
|
});
|
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
it('should be able to use the exponential calculator', async () => {
|
2020-07-30 13:03:19 +03:00
|
|
|
const eles = element.all(by.css('app-power-boost-calculator input'));
|
|
|
|
const baseInputEle = eles.get(0);
|
|
|
|
const factorInputEle = eles.get(1);
|
|
|
|
const outputEle = element(by.css('app-power-boost-calculator p'));
|
2020-11-23 20:17:10 +02:00
|
|
|
|
|
|
|
await baseInputEle.clear();
|
|
|
|
await baseInputEle.sendKeys('7');
|
|
|
|
await factorInputEle.clear();
|
|
|
|
await factorInputEle.sendKeys('3');
|
|
|
|
expect(await outputEle.getText()).toContain('343');
|
2017-02-22 18:13:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
it('should support flying heroes (pure) ', async () => {
|
2020-07-30 13:03:19 +03:00
|
|
|
const nameEle = element(by.css('app-flying-heroes input[type="text"]'));
|
|
|
|
const canFlyCheckEle = element(by.css('app-flying-heroes #can-fly'));
|
|
|
|
const mutateCheckEle = element(by.css('app-flying-heroes #mutate'));
|
|
|
|
const resetEle = element(by.css('app-flying-heroes button'));
|
|
|
|
const flyingHeroesEle = element.all(by.css('app-flying-heroes #flyers div'));
|
2017-02-22 18:13:21 +00:00
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
expect(await canFlyCheckEle.getAttribute('checked')).toEqual('true', 'should default to "can fly"');
|
|
|
|
expect(await mutateCheckEle.getAttribute('checked')).toEqual('true', 'should default to mutating array');
|
|
|
|
expect(await flyingHeroesEle.count()).toEqual(2, 'only two of the original heroes can fly');
|
|
|
|
|
|
|
|
await nameEle.sendKeys('test1\n');
|
|
|
|
expect(await flyingHeroesEle.count()).toEqual(2, 'no change while mutating array');
|
|
|
|
|
|
|
|
await mutateCheckEle.click();
|
|
|
|
await nameEle.sendKeys('test2\n');
|
|
|
|
expect(await flyingHeroesEle.count()).toEqual(4, 'not mutating; should see both adds');
|
|
|
|
expect(await flyingHeroesEle.get(2).getText()).toContain('test1');
|
|
|
|
expect(await flyingHeroesEle.get(3).getText()).toContain('test2');
|
|
|
|
|
|
|
|
await resetEle.click();
|
|
|
|
expect(await flyingHeroesEle.count()).toEqual(2, 'reset should restore original flying heroes');
|
2017-02-22 18:13:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
it('should support flying heroes (impure) ', async () => {
|
2020-07-30 13:03:19 +03:00
|
|
|
const nameEle = element(by.css('app-flying-heroes-impure input[type="text"]'));
|
|
|
|
const canFlyCheckEle = element(by.css('app-flying-heroes-impure #can-fly'));
|
|
|
|
const mutateCheckEle = element(by.css('app-flying-heroes-impure #mutate'));
|
|
|
|
const flyingHeroesEle = element.all(by.css('app-flying-heroes-impure #flyers div'));
|
2017-02-22 18:13:21 +00:00
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
expect(await canFlyCheckEle.getAttribute('checked')).toEqual('true', 'should default to "can fly"');
|
|
|
|
expect(await mutateCheckEle.getAttribute('checked')).toEqual('true', 'should default to mutating array');
|
|
|
|
expect(await flyingHeroesEle.count()).toEqual(2, 'only two of the original heroes can fly');
|
2017-02-22 18:13:21 +00:00
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
await nameEle.sendKeys('test1\n');
|
|
|
|
expect(await flyingHeroesEle.count()).toEqual(3, 'new flying hero should show in mutating array');
|
2017-02-22 18:13:21 +00:00
|
|
|
});
|
|
|
|
|
2020-11-23 20:17:10 +02:00
|
|
|
it('should show an async hero message', async () => {
|
|
|
|
expect(await element.all(by.tagName('app-hero-message')).get(0).getText()).toContain('hero');
|
2017-02-22 18:13:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|