|
| 1 | +describe('TypeScript to Javascript tests', function () { |
| 2 | + |
| 3 | + beforeAll(function () { |
| 4 | + browser.get(''); |
| 5 | + }); |
| 6 | + |
| 7 | + it('should display the basic component example', function () { |
| 8 | + testTag('hero-view', 'Hero: Windstorm'); |
| 9 | + }); |
| 10 | + |
| 11 | + it('should display the component example with lifecycle methods', function () { |
| 12 | + testTag('hero-lifecycle', 'Hero: Windstorm'); |
| 13 | + }); |
| 14 | + |
| 15 | + it('should display component with DI example', function () { |
| 16 | + testTag('hero-di', 'Hero: Windstorm'); |
| 17 | + }); |
| 18 | + |
| 19 | + it('should display component with DI using @Inject example', function () { |
| 20 | + testTag('hero-di-inject', 'Hero: Windstorm'); |
| 21 | + }); |
| 22 | + |
| 23 | + it('should support optional, attribute, and query injections', function () { |
| 24 | + var app = element(by.css('hero-di-inject-additional')); |
| 25 | + var h1 = app.element(by.css('h1')); |
| 26 | + var okMsg = app.element(by.css('.ok-msg')); |
| 27 | + |
| 28 | + expect(h1.getText()).toBe('Tour of Heroes'); |
| 29 | + app.element(by.buttonText('OK')).click(); |
| 30 | + expect(okMsg.getText()).toBe('OK!'); |
| 31 | + }); |
| 32 | + |
| 33 | + it('should support component with inputs and outputs', function () { |
| 34 | + var app = element(by.css('hero-io')); |
| 35 | + var confirmComponent = app.element(by.css('my-confirm')); |
| 36 | + |
| 37 | + confirmComponent.element(by.buttonText('OK')).click(); |
| 38 | + expect(app.element(by.cssContainingText('span', 'OK clicked')).isPresent()).toBe(true); |
| 39 | + |
| 40 | + confirmComponent.element(by.buttonText('Cancel')).click(); |
| 41 | + expect(app.element(by.cssContainingText('span', 'Cancel clicked')).isPresent()).toBe(true); |
| 42 | + }); |
| 43 | + |
| 44 | + it('should support host bindings and host listeners', function() { |
| 45 | + var app = element(by.css('heroes-bindings')); |
| 46 | + var h1 = app.element(by.css('h1')); |
| 47 | + |
| 48 | + expect(app.getAttribute('class')).toBe('heading'); |
| 49 | + expect(app.getAttribute('title')).toBe('Tooltip content'); |
| 50 | + |
| 51 | + h1.click(); |
| 52 | + expect(h1.getAttribute('class')).toBe('active'); |
| 53 | + |
| 54 | + h1.click(); |
| 55 | + browser.actions().doubleClick(h1).perform(); |
| 56 | + expect(h1.getAttribute('class')).toBe('active'); |
| 57 | + }); |
| 58 | + |
| 59 | + it('should support content and view queries', function() { |
| 60 | + var app = element(by.css('heroes-queries')); |
| 61 | + var windstorm = app.element(by.css('hero:first-child')); |
| 62 | + |
| 63 | + app.element(by.buttonText('Activate')).click(); |
| 64 | + expect(windstorm.element(by.css('h2')).getAttribute('class')).toBe('active'); |
| 65 | + expect(windstorm.element(by.css('active-label')).getText()).toBe('Active'); |
| 66 | + }); |
| 67 | + |
| 68 | + function testTag(selector, expectedText) { |
| 69 | + var component = element(by.css(selector)); |
| 70 | + expect(component.getText()).toBe(expectedText); |
| 71 | + } |
| 72 | + |
| 73 | +}); |
0 commit comments