2016-11-22 07:07:16 -05:00
|
|
|
'use strict'; // necessary for es6 output in node
|
2016-10-06 18:25:52 -04:00
|
|
|
|
|
|
|
import { browser, element, by } from 'protractor';
|
|
|
|
|
2016-03-16 12:01:33 -04:00
|
|
|
describe('TypeScript to Javascript tests', function () {
|
|
|
|
|
|
|
|
beforeAll(function () {
|
|
|
|
browser.get('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should display the basic component example', function () {
|
2016-11-22 07:07:16 -05:00
|
|
|
testTag('hero-view', 'Hero Detail: Windstorm');
|
2016-03-16 12:01:33 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should display the component example with lifecycle methods', function () {
|
|
|
|
testTag('hero-lifecycle', 'Hero: Windstorm');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should display component with DI example', function () {
|
|
|
|
testTag('hero-di', 'Hero: Windstorm');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should display component with DI using @Inject example', function () {
|
|
|
|
testTag('hero-di-inject', 'Hero: Windstorm');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should support optional, attribute, and query injections', function () {
|
2016-05-30 14:05:09 -04:00
|
|
|
let app = element(by.css('hero-di-inject-additional'));
|
|
|
|
let h1 = app.element(by.css('h1'));
|
2016-08-31 21:08:57 -04:00
|
|
|
let okMsg = app.element(by.css('p'));
|
2016-03-16 12:01:33 -04:00
|
|
|
|
|
|
|
expect(h1.getText()).toBe('Tour of Heroes');
|
|
|
|
app.element(by.buttonText('OK')).click();
|
|
|
|
expect(okMsg.getText()).toBe('OK!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should support component with inputs and outputs', function () {
|
2016-05-30 14:05:09 -04:00
|
|
|
let app = element(by.css('hero-io'));
|
2016-11-22 07:07:16 -05:00
|
|
|
let confirmComponent = app.element(by.css('app-confirm'));
|
2016-03-16 12:01:33 -04:00
|
|
|
|
|
|
|
confirmComponent.element(by.buttonText('OK')).click();
|
|
|
|
expect(app.element(by.cssContainingText('span', 'OK clicked')).isPresent()).toBe(true);
|
|
|
|
|
|
|
|
confirmComponent.element(by.buttonText('Cancel')).click();
|
|
|
|
expect(app.element(by.cssContainingText('span', 'Cancel clicked')).isPresent()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should support host bindings and host listeners', function() {
|
2016-11-22 07:07:16 -05:00
|
|
|
let app = element(by.css('hero-host'));
|
2016-05-30 14:05:09 -04:00
|
|
|
let h1 = app.element(by.css('h1'));
|
2016-03-16 12:01:33 -04:00
|
|
|
|
|
|
|
expect(app.getAttribute('class')).toBe('heading');
|
2016-11-22 07:07:16 -05:00
|
|
|
expect(app.getAttribute('title')).toContain('Tooltip');
|
2016-03-16 12:01:33 -04:00
|
|
|
|
|
|
|
h1.click();
|
|
|
|
expect(h1.getAttribute('class')).toBe('active');
|
|
|
|
|
|
|
|
h1.click();
|
2016-10-06 18:25:52 -04:00
|
|
|
browser.actions().doubleClick(h1.getWebElement()).perform();
|
2016-03-16 12:01:33 -04:00
|
|
|
expect(h1.getAttribute('class')).toBe('active');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should support content and view queries', function() {
|
2016-11-22 07:07:16 -05:00
|
|
|
let app = element(by.css('hero-queries'));
|
|
|
|
let windstorm = app.element(by.css('view-child:first-child'));
|
2016-03-16 12:01:33 -04:00
|
|
|
|
2016-11-22 07:07:16 -05:00
|
|
|
app.element(by.css('button')).click();
|
2016-03-16 12:01:33 -04:00
|
|
|
expect(windstorm.element(by.css('h2')).getAttribute('class')).toBe('active');
|
2016-11-22 07:07:16 -05:00
|
|
|
expect(windstorm.element(by.css('content-child')).getText()).toBe('Active');
|
2016-03-16 12:01:33 -04:00
|
|
|
});
|
|
|
|
|
2016-05-30 14:05:09 -04:00
|
|
|
function testTag(selector: string, expectedText: string) {
|
|
|
|
let component = element(by.css(selector));
|
2016-03-16 12:01:33 -04:00
|
|
|
expect(component.getText()).toBe(expectedText);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|