Skip to content

Instantly share code, notes, and snippets.

@Robdel12
Last active November 2, 2018 01:09
Show Gist options
  • Save Robdel12/78eced76a24333a56e97c2033525b731 to your computer and use it in GitHub Desktop.
Save Robdel12/78eced76a24333a56e97c2033525b731 to your computer and use it in GitHub Desktop.
describe("Checkbox", () => {
let checkbox = new CheckboxInteractor("label");
//...previous test
it("has the right tabindex", async () => {
await mount(() => <Checkbox tabIndex="2" />);
expect(checkbox.tabIndex).toBe("2");
});
it("toggles the checkbox via label click", async () => {
await mount(() => <Checkbox />);
expect(checkbox.isChecked).toBe(false);
// the label is the interactors $root element
await checkbox.click();
expect(checkbox.isChecked).toBe(true);
});
it("toggles the checkbox when a default value is passed", async () => {
await mount(() => <Checkbox defaultChecked />);
expect(checkbox.isChecked).toBe(true);
await checkbox.toggleCheckbox();
expect(checkbox.isChecked).toBe(false);
});
it("is disabled with prop", async () => {
await mount(() => <Checkbox disabled />);
expect(checkbox.isDisabled).toBe(true);
});
it("is not disabled by default", async () => {
await mount(() => <Checkbox />);
expect(checkbox.isDisabled).toBe(false);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment