Skip to content

chore(checkbox): add e2e test for spacebar checking #2397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions e2e/components/checkbox/checkbox.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
import {browser, by, element} from 'protractor';
import {browser, by, element, Key} from 'protractor';

describe('checkbox', function () {

describe('check behavior', function () {

beforeEach(function() {
browser.get('/checkbox');
});
it('should be checked when clicked, and be unchecked when clicked again', function () {
element(by.id('test-checkbox')).click();
element(by.css('input[id=input-test-checkbox]')).getAttribute('checked').then((value: string) => {

it('should be checked when clicked, and be unchecked when clicked again', () => {
let checkboxEl = element(by.id('test-checkbox'));
let inputEl = element(by.css('input[id=input-test-checkbox]'));

checkboxEl.click();
inputEl.getAttribute('checked').then((value: string) => {
expect(value).toBeTruthy('Expect checkbox "checked" property to be true');
});

element(by.id('test-checkbox')).click();
element(by.css('input[id=input-test-checkbox]')).getAttribute('checked').then((value: string) => {
checkboxEl.click();
inputEl.getAttribute('checked').then((value: string) => {
expect(value).toBeFalsy('Expect checkbox "checked" property to be false');
});
});

it('should toggle the checkbox when pressing space', () => {
let inputEl = element(by.css('input[id=input-test-checkbox]'));

inputEl.getAttribute('checked').then((value: string) => {
expect(value).toBeFalsy('Expect checkbox "checked" property to be false');
});

inputEl.sendKeys(Key.SPACE);

inputEl.getAttribute('checked').then((value: string) => {
expect(value).toBeTruthy('Expect checkbox "checked" property to be true');
});
});

});
});
1 change: 0 additions & 1 deletion src/lib/checkbox/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {ViewportRuler} from '../core/overlay/position/viewport-ruler';
import {FakeViewportRuler} from '../core/overlay/position/fake-viewport-ruler';


// TODO: Implement E2E tests for spacebar/click behavior for checking/unchecking

describe('MdCheckbox', () => {
let fixture: ComponentFixture<any>;
Expand Down