2017-03-27 11:08:53 -04:00
|
|
|
'use strict'; // necessary for es6 output in node
|
2017-02-22 13:13:21 -05:00
|
|
|
|
|
|
|
import { browser, element, by } from 'protractor';
|
|
|
|
|
|
|
|
describe('Component Style Tests', function () {
|
|
|
|
|
|
|
|
beforeAll(function () {
|
|
|
|
browser.get('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('scopes component styles to component view', function() {
|
2017-08-22 15:31:15 -04:00
|
|
|
let componentH1 = element(by.css('app-root > h1'));
|
2017-02-22 13:13:21 -05:00
|
|
|
let externalH1 = element(by.css('body > h1'));
|
|
|
|
|
2017-10-18 11:50:00 -04:00
|
|
|
// Note: sometimes webdriver returns the fontWeight as "normal",
|
2017-11-03 14:12:34 -04:00
|
|
|
// other times as "400", both of which are equal in CSS terms.
|
2017-10-18 11:50:00 -04:00
|
|
|
expect(componentH1.getCssValue('fontWeight')).toMatch(/normal|400/);
|
|
|
|
expect(externalH1.getCssValue('fontWeight')).not.toMatch(/normal|400/);
|
2017-02-22 13:13:21 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('allows styling :host element', function() {
|
2017-08-22 15:31:15 -04:00
|
|
|
let host = element(by.css('app-hero-details'));
|
2017-02-22 13:13:21 -05:00
|
|
|
|
|
|
|
expect(host.getCssValue('borderWidth')).toEqual('1px');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('supports :host() in function form', function() {
|
2017-08-22 15:31:15 -04:00
|
|
|
let host = element(by.css('app-hero-details'));
|
2017-02-22 13:13:21 -05:00
|
|
|
|
|
|
|
host.element(by.buttonText('Activate')).click();
|
|
|
|
expect(host.getCssValue('borderWidth')).toEqual('3px');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('allows conditional :host-context() styling', function() {
|
2017-08-22 15:31:15 -04:00
|
|
|
let h2 = element(by.css('app-hero-details h2'));
|
2017-02-22 13:13:21 -05:00
|
|
|
|
|
|
|
expect(h2.getCssValue('backgroundColor')).toEqual('rgba(238, 238, 255, 1)'); // #eeeeff
|
|
|
|
});
|
|
|
|
|
|
|
|
it('styles both view and content children with /deep/', function() {
|
2017-08-22 15:31:15 -04:00
|
|
|
let viewH3 = element(by.css('app-hero-team h3'));
|
|
|
|
let contentH3 = element(by.css('app-hero-controls h3'));
|
2017-02-22 13:13:21 -05:00
|
|
|
|
|
|
|
expect(viewH3.getCssValue('fontStyle')).toEqual('italic');
|
|
|
|
expect(contentH3.getCssValue('fontStyle')).toEqual('italic');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('includes styles loaded with CSS @import', function() {
|
2017-08-22 15:31:15 -04:00
|
|
|
let host = element(by.css('app-hero-details'));
|
2017-02-22 13:13:21 -05:00
|
|
|
|
|
|
|
expect(host.getCssValue('padding')).toEqual('10px');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('processes template inline styles', function() {
|
2017-08-22 15:31:15 -04:00
|
|
|
let button = element(by.css('app-hero-controls button'));
|
2017-02-22 13:13:21 -05:00
|
|
|
let externalButton = element(by.css('body > button'));
|
|
|
|
expect(button.getCssValue('backgroundColor')).toEqual('rgba(255, 255, 255, 1)'); // #ffffff
|
|
|
|
expect(externalButton.getCssValue('backgroundColor')).not.toEqual('rgba(255, 255, 255, 1)');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('processes template <link>s', function() {
|
2017-08-22 15:31:15 -04:00
|
|
|
let li = element(by.css('app-hero-team li:first-child'));
|
2017-02-22 13:13:21 -05:00
|
|
|
let externalLi = element(by.css('body > ul li'));
|
|
|
|
|
|
|
|
expect(li.getCssValue('listStyleType')).toEqual('square');
|
|
|
|
expect(externalLi.getCssValue('listStyleType')).not.toEqual('square');
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|