Skip to content

Commit

Permalink
Fixes warnings in StatelessTags.test.vue.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Nov 20, 2024
1 parent 2808eed commit f19c9d0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions client/src/components/TagsMultiselect/StatelessTags.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { mount } from "@vue/test-utils";
import { useToast } from "composables/toast";
import { getLocalVue } from "tests/jest/helpers";
import { computed } from "vue";
import { getLocalVue, suppressBootstrapVueWarnings } from "tests/jest/helpers";

import { normalizeTag, useUserTagsStore } from "@/stores/userTagsStore";

Expand All @@ -19,10 +18,12 @@ const mountWithProps = (props) => {
});
};

suppressBootstrapVueWarnings();

jest.mock("@/stores/userTagsStore");
const onNewTagSeenMock = jest.fn((tag) => tag);
useUserTagsStore.mockReturnValue({
userTags: computed(() => autocompleteTags),
userTags: autocompleteTags,
onNewTagSeen: onNewTagSeenMock,
onTagUsed: jest.fn(),
onMultipleNewTagsSeen: jest.fn(),
Expand Down
4 changes: 1 addition & 3 deletions client/src/components/TagsMultiselect/StatelessTags.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { BButton } from "bootstrap-vue";
import { storeToRefs } from "pinia";
import { computed, onMounted, ref } from "vue";
import { useToast } from "@/composables/toast";
Expand Down Expand Up @@ -36,7 +35,6 @@ const emit = defineEmits<{
}>();
const userTagsStore = useUserTagsStore();
const { userTags } = storeToRefs(userTagsStore);
const { warning } = useToast();
onMounted(() => {
Expand Down Expand Up @@ -110,7 +108,7 @@ function onTagClicked(tag: string) {
</div>

<HeadlessMultiselect
:options="userTags"
:options="userTagsStore.userTags"
:selected="props.value"
:placeholder="props.placeholder"
:validator="isValid"
Expand Down
10 changes: 10 additions & 0 deletions client/tests/jest/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,13 @@ export function injectTestRouter(localVue) {
export function suppressDebugConsole() {
jest.spyOn(console, "debug").mockImplementation(jest.fn());
}

export function suppressBootstrapVueWarnings() {
jest.spyOn(console, "warn").mockImplementation(
jest.fn((msg) => {
if (msg.indexOf("BootstrapVue warn") < 0) {
console.warn(msg);
}
})
);
}

0 comments on commit f19c9d0

Please sign in to comment.