Skip to content

Commit

Permalink
hide fallback on inline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Jara Palomino committed May 7, 2020
1 parent 1eab92b commit 2d09c64
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-swatches",
"version": "2.0.1",
"version": "2.0.3",
"description": "Help the user picking beautiful colors!",
"author": "Diego Jara <[email protected]>",
"private": false,
Expand Down
5 changes: 5 additions & 0 deletions src/VSwatches.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
/>
</span>
<button
v-if="showFallbackOk"
class="vue-swatches__fallback__button"
:class="fallbackOkClass"
@click.prevent="onFallbackButtonClick"
Expand Down Expand Up @@ -335,6 +336,10 @@ export default {
return DEFAULT_SHOW_BORDER;
},
showFallbackOk() {
return !this.inline;
},
/** DUMB COMPUTEDS (these only mutate props) **/
borderRadius() {
Expand Down
20 changes: 15 additions & 5 deletions tests/unit/specs/props.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ describe("Props", () => {
const componentWrapper = mount(VSwatches, {
propsData: {
fallbackOkClass: "class-example",
showFallback: true
showFallback: true,
inline: false
}
});
const button = componentWrapper.find(".vue-swatches__fallback__button");
Expand Down Expand Up @@ -524,6 +525,16 @@ describe("Props", () => {
expect(container.isVisible()).toBe(true);
});
});
test("should not render the fallback ok button", () => {
const componentWrapper = mount(VSwatches, {
propsData: {
inline: true,
showFallback: true
}
});
const button = componentWrapper.find(".vue-swatches__fallback__button");
expect(button.exists()).not.toBeTruthy();
});
});
describe("When inline prop is false (Popover)", () => {
test("should render the trigger", () => {
Expand Down Expand Up @@ -987,7 +998,7 @@ describe("Props", () => {
expect(fallbackWrapper.exists()).not.toBeTruthy();
});
});
test("should close the popover when click to ok button", () => {
test("should close the popover when click to ok button", async () => {
const componentWrapper = mount(VSwatches, {
propsData: {
showFallback: true,
Expand All @@ -999,9 +1010,8 @@ describe("Props", () => {
const button = componentWrapper.find(".vue-swatches__fallback__button");
button.trigger("click");

return Vue.nextTick().then(() => {
expect(container.isVisible()).not.toBeTruthy();
});
await Vue.nextTick();
return expect(container.isVisible()).not.toBeTruthy();
});
});

Expand Down

0 comments on commit 2d09c64

Please sign in to comment.