|
| 1 | +describe('Component Style Tests', function () { |
| 2 | + |
| 3 | + beforeAll(function () { |
| 4 | + browser.get(''); |
| 5 | + }); |
| 6 | + |
| 7 | + it('scopes component styles to component view', function() { |
| 8 | + var componentH1 = element(by.css('hero-app > h1')); |
| 9 | + var externalH1 = element(by.css('body > h1')); |
| 10 | + |
| 11 | + expect(componentH1.getCssValue('fontWeight')).toEqual('normal'); |
| 12 | + expect(externalH1.getCssValue('fontWeight')).not.toEqual('normal'); |
| 13 | + }); |
| 14 | + |
| 15 | + |
| 16 | + it('allows styling :host element', function() { |
| 17 | + var host = element(by.css('hero-details')); |
| 18 | + |
| 19 | + expect(host.getCssValue('borderWidth')).toEqual('1px'); |
| 20 | + }); |
| 21 | + |
| 22 | + it('supports :host() in function form', function() { |
| 23 | + var host = element(by.css('hero-details')); |
| 24 | + |
| 25 | + host.element(by.buttonText('Activate')).click(); |
| 26 | + expect(host.getCssValue('borderWidth')).toEqual('3px'); |
| 27 | + }); |
| 28 | + |
| 29 | + it('allows conditional :host-context() styling', function() { |
| 30 | + var h2 = element(by.css('hero-details h2')); |
| 31 | + |
| 32 | + expect(h2.getCssValue('backgroundColor')).toEqual('rgba(238, 238, 255, 1)'); // #eeeeff |
| 33 | + }); |
| 34 | + |
| 35 | + it('styles both view and content children with /deep/', function() { |
| 36 | + var viewH3 = element(by.css('hero-team h3')); |
| 37 | + var contentH3 = element(by.css('hero-controls h3')); |
| 38 | + |
| 39 | + expect(viewH3.getCssValue('fontStyle')).toEqual('italic'); |
| 40 | + expect(contentH3.getCssValue('fontStyle')).toEqual('italic'); |
| 41 | + }); |
| 42 | + |
| 43 | + it('includes styles loaded with CSS @import', function() { |
| 44 | + var host = element(by.css('hero-details')); |
| 45 | + |
| 46 | + expect(host.getCssValue('padding')).toEqual('10px'); |
| 47 | + }); |
| 48 | + |
| 49 | + it('processes template inline styles', function() { |
| 50 | + var button = element(by.css('hero-controls button')); |
| 51 | + var externalButton = element(by.css('body > button')); |
| 52 | + expect(button.getCssValue('backgroundColor')).toEqual('rgba(255, 255, 255, 1)'); // #ffffff |
| 53 | + expect(externalButton.getCssValue('backgroundColor')).not.toEqual('rgba(255, 255, 255, 1)'); |
| 54 | + }); |
| 55 | + |
| 56 | + it('processes template <link>s', function() { |
| 57 | + var li = element(by.css('hero-team li:first-child')); |
| 58 | + var externalLi = element(by.css('body > ul li')); |
| 59 | + |
| 60 | + expect(li.getCssValue('listStyleType')).toEqual('square'); |
| 61 | + expect(externalLi.getCssValue('listStyleType')).not.toEqual('square'); |
| 62 | + }); |
| 63 | + |
| 64 | + it('supports relative loading with moduleId', function() { |
| 65 | + var host = element(by.css('quest-summary')); |
| 66 | + expect(host.getCssValue('color')).toEqual('rgba(255, 255, 255, 1)'); // #ffffff |
| 67 | + }); |
| 68 | + |
| 69 | +}); |
0 commit comments