Files
angular__angular/e2e/components/checkbox-e2e.spec.ts
T
Paul Gschwendtner bcf48261f4 fix(checkbox, radio): setting id to null causes invalid id for input (#5398)
* In some situations, developers will change the `id` of a component dynamically. At some point if they set the `[id]` to `null` the input id will look like the following: `null-input`.
* If developers are setting the `id` using a binding then the DOM Id for the host component won't be set at all (because the @Input is triggered instead of the DOM property)

Fixes #5394
2017-07-11 10:09:02 -07:00

46 lines
1.5 KiB
TypeScript

import {browser, by, element, Key, ExpectedConditions} from 'protractor';
import {screenshot} from '../screenshot';
describe('checkbox', () => {
describe('check behavior', () => {
beforeEach(() => browser.get('/checkbox'));
it('should be checked when clicked, and unchecked when clicked again', async () => {
let checkboxEl = element(by.id('test-checkbox'));
let inputEl = element(by.css('input[id=test-checkbox-input]'));
screenshot('start');
checkboxEl.click();
expect(inputEl.getAttribute('checked'))
.toBeTruthy('Expect checkbox "checked" property to be true');
await browser.wait(ExpectedConditions.not(
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
screenshot('checked');
checkboxEl.click();
expect(inputEl.getAttribute('checked'))
.toBeFalsy('Expect checkbox "checked" property to be false');
await browser.wait(ExpectedConditions.not(
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
screenshot('unchecked');
});
it('should toggle the checkbox when pressing space', () => {
let inputEl = element(by.css('input[id=test-checkbox-input]'));
expect(inputEl.getAttribute('checked'))
.toBeFalsy('Expect checkbox "checked" property to be false');
inputEl.sendKeys(Key.SPACE);
expect(inputEl.getAttribute('checked'))
.toBeTruthy('Expect checkbox "checked" property to be true');
});
});
});