2017-02-16 15:43:29 -08:00
|
|
|
import {browser, by, element, Key, ExpectedConditions} from 'protractor';
|
2017-06-10 01:09:08 +02:00
|
|
|
import {screenshot} from '../screenshot';
|
2016-12-19 20:17:23 +02:00
|
|
|
|
2016-12-28 04:33:23 +01:00
|
|
|
|
2017-06-01 17:49:20 +02:00
|
|
|
describe('checkbox', () => {
|
2016-12-28 04:33:23 +01:00
|
|
|
|
2017-06-01 17:49:20 +02:00
|
|
|
describe('check behavior', () => {
|
|
|
|
|
beforeEach(() => browser.get('/checkbox'));
|
2016-12-28 04:33:23 +01:00
|
|
|
|
2017-06-01 17:49:20 +02:00
|
|
|
it('should be checked when clicked, and unchecked when clicked again', async () => {
|
2016-12-28 04:33:23 +01:00
|
|
|
let checkboxEl = element(by.id('test-checkbox'));
|
2017-07-11 19:09:02 +02:00
|
|
|
let inputEl = element(by.css('input[id=test-checkbox-input]'));
|
2016-12-28 04:33:23 +01:00
|
|
|
|
2017-01-12 13:24:51 -08:00
|
|
|
screenshot('start');
|
2016-12-28 04:33:23 +01:00
|
|
|
checkboxEl.click();
|
2017-06-01 17:49:20 +02:00
|
|
|
|
|
|
|
|
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');
|
2016-10-26 11:28:00 -07:00
|
|
|
|
2016-12-28 04:33:23 +01:00
|
|
|
checkboxEl.click();
|
2017-06-01 17:49:20 +02:00
|
|
|
|
|
|
|
|
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');
|
2016-12-28 04:33:23 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should toggle the checkbox when pressing space', () => {
|
2017-07-11 19:09:02 +02:00
|
|
|
let inputEl = element(by.css('input[id=test-checkbox-input]'));
|
2016-12-28 04:33:23 +01:00
|
|
|
|
2017-06-01 17:49:20 +02:00
|
|
|
expect(inputEl.getAttribute('checked'))
|
|
|
|
|
.toBeFalsy('Expect checkbox "checked" property to be false');
|
2016-12-28 04:33:23 +01:00
|
|
|
inputEl.sendKeys(Key.SPACE);
|
|
|
|
|
|
2017-06-01 17:49:20 +02:00
|
|
|
expect(inputEl.getAttribute('checked'))
|
|
|
|
|
.toBeTruthy('Expect checkbox "checked" property to be true');
|
2016-10-26 11:28:00 -07:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|