mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
hack MapboxGeocoder in unit tests by simply stubbing the import
This commit is contained in:
parent
4ac3d21e2a
commit
b75c7c6977
@ -20,16 +20,16 @@ module.exports = {
|
||||
transform: {
|
||||
'.*\\.(vue)$': 'vue-jest',
|
||||
'^.+\\.js$': 'babel-jest',
|
||||
'<rootDir>/node_modules/@mapbox/mapbox-gl-geocoder/dist/*': 'babel-jest',
|
||||
},
|
||||
testMatch: ['**/?(*.)+(spec|test).js?(x)'],
|
||||
modulePathIgnorePatterns: ['<rootDir>/build/'],
|
||||
moduleNameMapper: {
|
||||
'\\.(svg)$': '<rootDir>/test/fileMock.js',
|
||||
'\\.(css|less)$': 'identity-obj-proxy',
|
||||
'@mapbox/mapbox-gl-geocoder': 'identity-obj-proxy',
|
||||
'^@/(.*)$': '<rootDir>/src/$1',
|
||||
'^~/(.*)$': '<rootDir>/$1',
|
||||
},
|
||||
moduleFileExtensions: ['js', 'json', 'vue'],
|
||||
testEnvironment: 'jsdom',
|
||||
testEnvironment: 'jest-environment-jsdom',
|
||||
}
|
||||
|
||||
@ -4,8 +4,11 @@ import { mount } from '@vue/test-utils'
|
||||
import VueMeta from 'vue-meta'
|
||||
import Vuex from 'vuex'
|
||||
import Map from './map'
|
||||
import MapboxGeocoder from '@mapbox/mapbox-gl-geocoder'
|
||||
|
||||
jest.mock('@mapbox/mapbox-gl-geocoder')
|
||||
jest.mock('@mapbox/mapbox-gl-geocoder', () => {
|
||||
return jest.fn().mockImplementation(jest.fn())
|
||||
})
|
||||
|
||||
jest.mock('mapbox-gl', () => {
|
||||
return {
|
||||
@ -70,6 +73,7 @@ describe('map', () => {
|
||||
let mocks
|
||||
|
||||
beforeEach(() => {
|
||||
MapboxGeocoder.mockClear()
|
||||
mocks = {
|
||||
$t: (t) => t,
|
||||
$env: {
|
||||
@ -97,7 +101,7 @@ describe('map', () => {
|
||||
})
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.is('div')).toBeTruthy()
|
||||
expect(wrapper.element.tagName).toBe('DIV')
|
||||
})
|
||||
|
||||
it('has correct <head> content', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user