Created
November 20, 2019 00:32
-
-
Save Jones-S/2d92501a4f19adee296b9cc1ea3ba857 to your computer and use it in GitHub Desktop.
Vue testing file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { shallowMount } from '@vue/test-utils'; | |
import jest from 'jest-mock'; | |
import StoreFinderMap from '../../src/modules/StoreFinder/components/StoreFinderMap/StoreFinderMap.vue'; | |
describe('StoreFinderMap', () => { | |
let wrapper; | |
beforeEach(() => { | |
const initMapMock = jest.fn(); | |
const initMarkersMock = jest.fn(); | |
const subscribeToMapScrollMock = jest.fn(); | |
wrapper = shallowMount(StoreFinderMap, { | |
// pass in some required props, with dummy content | |
propsData: { | |
google: {}, | |
markerClusterStyle: ['markerClusterStyleMock'], | |
mapOptions: {}, | |
}, | |
// override methods which are called on mounted | |
methods: { | |
initMap: initMapMock, | |
initMarkers: initMarkersMock, | |
subscribeToMapScroll: subscribeToMapScrollMock, | |
}, | |
computed: { | |
searchCoordinates: jest.fn(), | |
mapCoordinates: jest.fn(), | |
activeLocation: jest.fn(), | |
storeFilter: jest.fn(), | |
}, | |
}); | |
jest.clearAllMocks(); | |
}); | |
test('If marker represents a searched location/current user location, it should show the result icon', () => { | |
wrapper.setData({ mapOptions: { iconPath: 'filepath/' } }); | |
expect(wrapper.vm.iconType({ attributes: { isResult: true } })).toEqual(`${wrapper.vm.mapOptions.iconPath}storefinder-result.svg`); | |
}); | |
test('Set new map bounds when search coordinates are changed in vuex store', () => { | |
const spy = jest.spyOn(wrapper.vm, 'setMapBounds'); | |
wrapper.vm.searchCoordinates = jest.fn(() => 'lala'); | |
expect(spy).toBeCalled(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment