2018-09-20 18:19:08 +02:00
|
|
|
import {browser, by, element, Key} from 'protractor';
|
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
|
|
|
|
|
|
|
|
checkboxEl.click();
|
2017-06-01 17:49:20 +02:00
|
|
|
|
|
|
|
|
expect(inputEl.getAttribute('checked'))
|
|
|
|
|
.toBeTruthy('Expect checkbox "checked" property to be true');
|
|
|
|
|
|
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');
|
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
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|