docs(aio): fix pipes example e2e spec to work with Angular v4 (#19511)

There was a breaking change between 4 and 5 for i18n formatting of dates.

PR Close #19511
This commit is contained in:
Peter Bacon Darwin 2017-10-03 10:38:43 +01:00 committed by Tobias Bosch
parent d3fd088162
commit 6586265a0c
1 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,7 @@
'use strict'; // necessary for es6 output in node
import { browser, element, by } from 'protractor';
const { version: angularVersion } = require('@angular/core/package.json');
describe('Pipes', function () {
@ -28,7 +29,11 @@ describe('Pipes', function () {
it('should be able to toggle birthday formats', function () {
let birthDayEle = element(by.css('app-hero-birthday2 > p'));
expect(birthDayEle.getText()).toEqual(`The hero's birthday is 4/15/88`);
if (angularVersion.indexOf('4.') === 0) { // Breaking change between v4 and v5 (https://github.com/angular/angular/commit/079d884)
expect(birthDayEle.getText()).toEqual(`The hero's birthday is 4/15/1988`);
} else {
expect(birthDayEle.getText()).toEqual(`The hero's birthday is 4/15/88`);
}
let buttonEle = element(by.cssContainingText('app-hero-birthday2 > button', 'Toggle Format'));
expect(buttonEle.isDisplayed()).toBe(true);
buttonEle.click().then(function() {