2016-09-09 00:41:09 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-11-10 21:13:11 -05:00
|
|
|
import {$, ExpectedConditions, browser, by, element} from 'protractor';
|
2019-01-28 15:59:25 -05:00
|
|
|
import {verifyNoBrowserErrors} from '../../../../test-utils';
|
2016-09-09 00:41:09 -04:00
|
|
|
|
|
|
|
function waitForElement(selector: string) {
|
2016-11-12 08:08:58 -05:00
|
|
|
const EC = ExpectedConditions;
|
2016-09-09 00:41:09 -04:00
|
|
|
// Waits for the element with id 'abc' to be present on the dom.
|
|
|
|
browser.wait(EC.presenceOf($(selector)), 20000);
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('pipe', () => {
|
|
|
|
afterEach(verifyNoBrowserErrors);
|
2019-01-28 15:59:25 -05:00
|
|
|
const URL = '/pipes';
|
2016-09-09 00:41:09 -04:00
|
|
|
|
|
|
|
describe('async', () => {
|
|
|
|
it('should resolve and display promise', () => {
|
|
|
|
browser.get(URL);
|
|
|
|
waitForElement('async-promise-pipe');
|
|
|
|
expect(element.all(by.css('async-promise-pipe span')).get(0).getText())
|
|
|
|
.toEqual('Wait for it...');
|
|
|
|
element(by.css('async-promise-pipe button')).click();
|
|
|
|
expect(element.all(by.css('async-promise-pipe span')).get(0).getText())
|
|
|
|
.toEqual('Wait for it... hi there!');
|
|
|
|
});
|
2018-03-13 22:46:10 -04:00
|
|
|
});
|
2016-09-09 00:41:09 -04:00
|
|
|
|
2018-03-13 22:46:10 -04:00
|
|
|
describe('lowercase/uppercase', () => {
|
|
|
|
it('should work properly', () => {
|
2016-09-09 00:41:09 -04:00
|
|
|
browser.get(URL);
|
|
|
|
waitForElement('lowerupper-pipe');
|
|
|
|
element(by.css('lowerupper-pipe input')).sendKeys('Hello World!');
|
|
|
|
expect(element.all(by.css('lowerupper-pipe pre')).get(0).getText())
|
|
|
|
.toEqual('\'hello world!\'');
|
|
|
|
expect(element.all(by.css('lowerupper-pipe pre')).get(1).getText())
|
|
|
|
.toEqual('\'HELLO WORLD!\'');
|
|
|
|
});
|
|
|
|
});
|
2018-03-13 22:46:10 -04:00
|
|
|
|
|
|
|
describe('titlecase', () => {
|
|
|
|
it('should work properly', () => {
|
|
|
|
browser.get(URL);
|
|
|
|
waitForElement('titlecase-pipe');
|
|
|
|
expect(element.all(by.css('titlecase-pipe p')).get(0).getText()).toEqual('Some String');
|
|
|
|
expect(element.all(by.css('titlecase-pipe p')).get(1).getText())
|
|
|
|
.toEqual('This Is Mixed Case');
|
|
|
|
expect(element.all(by.css('titlecase-pipe p')).get(2).getText())
|
|
|
|
.toEqual('It\'s Non-trivial Question');
|
|
|
|
expect(element.all(by.css('titlecase-pipe p')).get(3).getText()).toEqual('One,two,three');
|
|
|
|
expect(element.all(by.css('titlecase-pipe p')).get(4).getText()).toEqual('True|false');
|
|
|
|
expect(element.all(by.css('titlecase-pipe p')).get(5).getText()).toEqual('Foo-vs-bar');
|
|
|
|
});
|
|
|
|
});
|
2018-06-13 17:19:06 -04:00
|
|
|
|
|
|
|
describe('keyvalue', () => {
|
2018-06-06 05:31:22 -04:00
|
|
|
it('should work properly', () => {
|
|
|
|
browser.get(URL);
|
|
|
|
waitForElement('keyvalue-pipe');
|
|
|
|
expect(element.all(by.css('keyvalue-pipe div')).get(0).getText()).toEqual('1:bar');
|
|
|
|
expect(element.all(by.css('keyvalue-pipe div')).get(1).getText()).toEqual('2:foo');
|
|
|
|
expect(element.all(by.css('keyvalue-pipe div')).get(2).getText()).toEqual('1:bar');
|
|
|
|
expect(element.all(by.css('keyvalue-pipe div')).get(3).getText()).toEqual('2:foo');
|
|
|
|
});
|
|
|
|
});
|
2018-06-25 14:23:38 -04:00
|
|
|
|
|
|
|
describe('number', () => {
|
|
|
|
it('should work properly', () => {
|
|
|
|
browser.get(URL);
|
|
|
|
waitForElement('number-pipe');
|
|
|
|
const examples = element.all(by.css('number-pipe p'));
|
|
|
|
expect(examples.get(0).getText()).toEqual('e (no formatting): 2.718');
|
|
|
|
expect(examples.get(1).getText()).toEqual('e (3.1-5): 002.71828');
|
|
|
|
expect(examples.get(2).getText()).toEqual('e (4.5-5): 0,002.71828');
|
|
|
|
expect(examples.get(3).getText()).toEqual('e (french): 0 002,71828');
|
|
|
|
expect(examples.get(4).getText()).toEqual('pi (no formatting): 3.14');
|
|
|
|
expect(examples.get(5).getText()).toEqual('pi (3.1-5): 003.14');
|
|
|
|
expect(examples.get(6).getText()).toEqual('pi (3.5-5): 003.14000');
|
|
|
|
expect(examples.get(7).getText()).toEqual('-2.5 (1.0-0): -3');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('percent', () => {
|
|
|
|
it('should work properly', () => {
|
|
|
|
browser.get(URL);
|
|
|
|
waitForElement('percent-pipe');
|
|
|
|
const examples = element.all(by.css('percent-pipe p'));
|
|
|
|
expect(examples.get(0).getText()).toEqual('A: 26%');
|
|
|
|
expect(examples.get(1).getText()).toEqual('B: 0,134.950%');
|
|
|
|
expect(examples.get(2).getText()).toEqual('B: 0 134,950 %');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('currency', () => {
|
|
|
|
it('should work properly', () => {
|
|
|
|
browser.get(URL);
|
|
|
|
waitForElement('currency-pipe');
|
|
|
|
const examples = element.all(by.css('currency-pipe p'));
|
|
|
|
expect(examples.get(0).getText()).toEqual('A: $0.26');
|
|
|
|
expect(examples.get(1).getText()).toEqual('A: CA$0.26');
|
|
|
|
expect(examples.get(2).getText()).toEqual('A: CAD0.26');
|
|
|
|
expect(examples.get(3).getText()).toEqual('B: CA$0,001.35');
|
|
|
|
expect(examples.get(4).getText()).toEqual('B: $0,001.35');
|
|
|
|
expect(examples.get(5).getText()).toEqual('B: 0 001,35 CA$');
|
|
|
|
expect(examples.get(6).getText()).toEqual('B: CLP1');
|
|
|
|
});
|
|
|
|
});
|
2016-09-09 00:41:09 -04:00
|
|
|
});
|