Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('renders markers with popups', async () => {
const wrapper = mountWithDefaults(StandardMap, {
propsData: {
markers,
},
})
await nextTicks(1)
expect(wrapper.findAll(Vue2Leaflet.LMap).length).toBe(1)
expect(wrapper.findAll(ExtendedMarker).length).toBe(markers.length)
expect(wrapper.findAll(Vue2Leaflet.LPopup).length).toBe(markers.length)
// add and remove some markers
for (let i = 0; i < 3; i++) {
wrapper.setProps({ markers: markers.filter((e, idx) => idx !== i) })
await nextTicks(1)
expect(wrapper.findAll(ExtendedMarker).length).toBe(markers.length - 1)
expect(wrapper.findAll(Vue2Leaflet.LPopup).length).toBe(markers.length - 1)
}
})
})
import GroupMap from './GroupMap'
import { usersMock, placesMock } from '>/mockdata'
import * as Vue2Leaflet from 'vue2-leaflet'
import ExtendedMarker from './ExtendedMarker'
import { mountWithDefaults } from '>/helpers'
import Vue from 'vue'
/* vue2-leaflet library does not name its components, which vue-test-utils needs to find them
so we give them names here... */
Vue2Leaflet.LMap.name = 'Vue2LeafletMap'
Vue2Leaflet.LTileLayer.name = 'Vue2LeafletTileLayer'
Vue2Leaflet.LPopup.name = 'Vue2LeafletPopup'
Vue2Leaflet.LMarker.name = 'Vue2LeafletMarker'
const defaultProps = {
users: usersMock,
places: placesMock,
showUsers: true,
showPlaces: true,
currentGroup: {
membership: {
isEditor: true,
},
},
}
it('renders users and places', async () => {
const wrapper = mountWithDefaults(GroupMap, {
propsData: defaultProps,
})
await Vue.nextTick()
expect(wrapper.findAll(Vue2Leaflet.LMap).length).toBe(1)
expect(wrapper.findAll(ExtendedMarker).length).toBe(usersMock.length + placesMock.length)
for (const marker of wrapper.findAll(ExtendedMarker)) {
expect(marker.props().opacity).toEqual(1)
}
expect(wrapper.findAll(Vue2Leaflet.LPopup).length).toBe(usersMock.length + placesMock.length)
})