Last active
November 2, 2018 01:09
-
-
Save Robdel12/78eced76a24333a56e97c2033525b731 to your computer and use it in GitHub Desktop.
For this blog post: https://medium.com/@robdel12/jest-bigtest-interactor-component-test-%EF%B8%8F-11b1947954c8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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