Skip to content

Commit

Permalink
Add unit test for clearable prop
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyFeliz committed Jan 18, 2020
1 parent 9bc2758 commit 4004b51
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/unit/email-dropdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ describe("EmailDropdown.vue", () => {
expect(wrapper.find(".email-dropdown-item").text()).to.be.equal("hello@gmail.com");
});

it("hides suggestion list if remove '@' from the email", async () => {
const wrapper = shallowMount(EmailDropdown, {
propsData
});

expect(wrapper.findAll(".email-dropdown-item")).to.have.length(2);
wrapper.find("input").setValue("hello");
await Vue.nextTick();
expect(wrapper.find(".email-dropdown-list").exists()).to.be.false;
});

it("clears the email field when the x is clicked", async () => {
propsData.clearable = true;
const wrapper = shallowMount(EmailDropdown, {
Expand All @@ -95,18 +106,18 @@ describe("EmailDropdown.vue", () => {
await Vue.nextTick();
wrapper.find("button").trigger("click");
await Vue.nextTick();
expect(wrapper.vm.$refs.email.value).to.be.equal("");
expect(wrapper.vm.$data.email).to.be.empty;
});

it("hides suggestion list if remove '@' from the email", async () => {
it("hides the x if the input not clearable", async () => {
propsData.clearable = false;
const wrapper = shallowMount(EmailDropdown, {
propsData
});

expect(wrapper.findAll(".email-dropdown-item")).to.have.length(2);
wrapper.find("input").setValue("hello");
await Vue.nextTick();
expect(wrapper.find(".email-dropdown-list").exists()).to.be.false;
expect(wrapper.find("button").exists()).to.be.false;
});

describe("events", () => {
Expand All @@ -128,6 +139,8 @@ describe("EmailDropdown.vue", () => {
});
});

describe("props", () => {});

describe("computed", () => {
describe("includesAt", () => {
it("returns 'true' if email includes '@'", () => {
Expand Down

0 comments on commit 4004b51

Please sign in to comment.