mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +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: {
|
transform: {
|
||||||
'.*\\.(vue)$': 'vue-jest',
|
'.*\\.(vue)$': 'vue-jest',
|
||||||
'^.+\\.js$': 'babel-jest',
|
'^.+\\.js$': 'babel-jest',
|
||||||
'<rootDir>/node_modules/@mapbox/mapbox-gl-geocoder/dist/*': 'babel-jest',
|
|
||||||
},
|
},
|
||||||
testMatch: ['**/?(*.)+(spec|test).js?(x)'],
|
testMatch: ['**/?(*.)+(spec|test).js?(x)'],
|
||||||
modulePathIgnorePatterns: ['<rootDir>/build/'],
|
modulePathIgnorePatterns: ['<rootDir>/build/'],
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'\\.(svg)$': '<rootDir>/test/fileMock.js',
|
'\\.(svg)$': '<rootDir>/test/fileMock.js',
|
||||||
'\\.(css|less)$': 'identity-obj-proxy',
|
'\\.(css|less)$': 'identity-obj-proxy',
|
||||||
|
'@mapbox/mapbox-gl-geocoder': 'identity-obj-proxy',
|
||||||
'^@/(.*)$': '<rootDir>/src/$1',
|
'^@/(.*)$': '<rootDir>/src/$1',
|
||||||
'^~/(.*)$': '<rootDir>/$1',
|
'^~/(.*)$': '<rootDir>/$1',
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['js', 'json', 'vue'],
|
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 VueMeta from 'vue-meta'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import Map from './map'
|
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', () => {
|
jest.mock('mapbox-gl', () => {
|
||||||
return {
|
return {
|
||||||
@ -70,6 +73,7 @@ describe('map', () => {
|
|||||||
let mocks
|
let mocks
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
MapboxGeocoder.mockClear()
|
||||||
mocks = {
|
mocks = {
|
||||||
$t: (t) => t,
|
$t: (t) => t,
|
||||||
$env: {
|
$env: {
|
||||||
@ -97,7 +101,7 @@ describe('map', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('renders', () => {
|
it('renders', () => {
|
||||||
expect(wrapper.is('div')).toBeTruthy()
|
expect(wrapper.element.tagName).toBe('DIV')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has correct <head> content', () => {
|
it('has correct <head> content', () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user