unit testing
This commit is contained in:
parent
918addb3cb
commit
75f7c4abbc
3 changed files with 22 additions and 11 deletions
|
|
@ -1,16 +1,30 @@
|
|||
import { shallowMount } from "@vue/test-utils";
|
||||
import radioQuestion from "@/common-components/radio-question/radio-question";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper";
|
||||
|
||||
describe("radioQuestion.vue", () => {
|
||||
it("Should render the 'questionText' prop value as a span value for the radio question and the 'answer' values should render as text values for radio components.", () => {
|
||||
// Act
|
||||
const wrapper = shallowMount(radioQuestion, {
|
||||
propsData: {
|
||||
questionText: "Question Text",
|
||||
answers: ["2023", "2022", "2021"],
|
||||
modelValue: '2020'
|
||||
},
|
||||
it("Should render the 'questionText' prop value as a span value for the radio question and the 'answer' values should render as text values for radio components.", async () => {
|
||||
// Arrange
|
||||
const chooseAnswer = jest.fn();
|
||||
chooseAnswer.mockImplementation((answer) => {
|
||||
mockData.answer = answer;
|
||||
});
|
||||
const mockData = {
|
||||
chooseAnswer: chooseAnswer,
|
||||
answer: ''
|
||||
}
|
||||
|
||||
const mountOptions = getMountOptions(mockData);
|
||||
|
||||
// Act
|
||||
const wrapper = shallowMount(radioQuestion, mountOptions)
|
||||
await wrapper.setProps({
|
||||
questionText: "Question Text",
|
||||
answers: ["2023", "2022", "2021"],
|
||||
modelValue: "2020"
|
||||
});
|
||||
//wrapper.vm.chooseAnswer("2021");
|
||||
console.log(mockData.answer);
|
||||
|
||||
// Assert
|
||||
expect(wrapper.find(".needed_car_info-text").text()).toEqual(
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ export default {
|
|||
answers: Array,
|
||||
modelValue: String
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
methods: {
|
||||
chooseAnswer(answer) {
|
||||
this.$emit('update:modelValue', answer);
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ export default {
|
|||
years: Array,
|
||||
modelValue: String
|
||||
},
|
||||
created() {
|
||||
},
|
||||
components: {
|
||||
radioQuestion,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue