unit test WIP

This commit is contained in:
Katie Kroell 2023-07-25 14:30:58 -04:00
parent 14fb8f8d77
commit 14517035b1

View file

@ -479,22 +479,42 @@ describe('coverageStatement.vue', () => {
expect(wrapper.vm.coverageUnverified).toBeFalsy(); expect(wrapper.vm.coverageUnverified).toBeFalsy();
}); });
}); });
describe('Navigation', () => {
test('Back button clicked triggers navigation', () => {
// Arrange
const wrapper = shallowMount(coverageStatement, getMountOptions({
router: {
navigate: jest.fn()
},
}));
mountOptions.mixins = [mockMixin];
// Act
wrapper.vm.backButtonAction();
// Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, undefined);
});
});
}) })
//const testWidget = getRandomString(50, 100);
const mockMixin = { const mockMixin = {
methods: { methods: {
getCmsContent: jest.fn().mockImplementation(() => ''), getCmsContent: jest.fn().mockImplementation(() => ''),
setCmsContent: jest.fn(), setCmsContent: jest.fn(),
getBodyTextFromCms: jest.fn().mockImplementation(() => ''),
}, },
}; };
function setupMocks() function setupMocks()
{ {
const mountOptions = getMountOptions({ const mountOptions = getMountOptions({
// router: { router: {
// navigate: jest.fn() navigate: jest.fn()
// }, },
// global: { // global: {
// plugins: [createTestingPinia()] // plugins: [createTestingPinia()]