forked from openearth/vue2mapbox-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
56 lines (49 loc) · 1.32 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import 'URL'
import Vue from 'vue'
import { mount } from '@vue/test-utils'
import install from './src/main'
import { propsDefaults, propsBinder } from './src/utils/propsBinder'
import VMapbox from './src/components/VMapbox'
test('install', () => {
Vue.use(install)
// get the component
// Testing is not working in node, consider testing in a browser component
// https://github.com/mapbox/mapbox-gl-js/issues/4593
let VMapbox = Vue.component('v-mapbox')
expect(VMapbox).toBeDefined()
})
test('default properties', () => {
// get the default properties
let defaults = propsDefaults(VMapbox.props)
let expected = {
"preserveDrawingBuffer": false,
}
expect(defaults).toEqual(expected)
})
test('default properties override', () => {
// override some of the defalt properties
let props = {
interactive: {
type: Boolean,
default: true
},
minZoom: {
type: Number
},
bearing: undefined
}
let defaults = propsDefaults(props)
let expected = {interactive: true}
expect(defaults).toEqual(expected)
})
test('bind properties', () => {
let defaults = {
minZoom: {
type: Number
}
}
let vueElement = {$watch: jest.fn()}
let mapboxMap = {setMinZoom: jest.fn()}
propsBinder(vueElement, mapboxMap, defaults)
expect(vueElement.$watch.mock.calls.length).toBe(1)
})