File tree 2 files changed +39
-15
lines changed
2 files changed +39
-15
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
- <div :id =" id" v-resize:debounce.100 =" onResize" />
2
+ <div
3
+ :id =" id"
4
+ v-resize:debounce.100 =" onResize"
5
+ />
3
6
</template >
4
7
<script >
5
8
import Plotly from " plotly.js" ;
@@ -62,10 +65,12 @@ export default {
62
65
},
63
66
computed: {
64
67
options () {
65
- return Object .keys (this .$attrs ).reduce ((acc , key ) => {
68
+ const optionsFromAttrs = Object .keys (this .$attrs ).reduce ((acc , key ) => {
66
69
acc[camelize (key)] = this .$attrs [key];
67
70
return acc;
68
71
}, {});
72
+
73
+ return Object .assign (optionsFromAttrs, {responsive: false });
69
74
}
70
75
},
71
76
beforeDestroy () {
Original file line number Diff line number Diff line change @@ -6,24 +6,30 @@ let wrapper;
6
6
let vm ;
7
7
let layout ;
8
8
let data ;
9
+ let attrs ;
9
10
const id = "id" ;
10
11
12
+ function shallowMountPlotty ( ) {
13
+ jest . clearAllMocks ( ) ;
14
+ return shallowMount ( Plotly , {
15
+ propsData : {
16
+ layout,
17
+ data,
18
+ id
19
+ } ,
20
+ attrs,
21
+ attachToDocument : true
22
+ } ) ;
23
+ }
24
+
11
25
describe ( "Plotly.vue" , ( ) => {
12
26
beforeEach ( ( ) => {
13
- jest . clearAllMocks ( ) ;
14
27
layout = { } ;
15
28
data = [ ] ;
16
- wrapper = shallowMount ( Plotly , {
17
- propsData : {
18
- layout,
19
- data,
20
- id
21
- } ,
22
- attrs : {
23
- "display-mode-bar" : true
24
- } ,
25
- attachToDocument : true
26
- } ) ;
29
+ attrs = {
30
+ "display-mode-bar" : true
31
+ }
32
+ wrapper = shallowMountPlotty ( ) ;
27
33
vm = wrapper . vm ;
28
34
} ) ;
29
35
@@ -41,7 +47,20 @@ describe("Plotly.vue", () => {
41
47
42
48
it ( "calls plotly newPlot" , ( ) => {
43
49
expect ( plotlyjs . newPlot ) . toHaveBeenCalledWith ( vm . $el , data , layout , {
44
- displayModeBar : true
50
+ displayModeBar : true ,
51
+ responsive : false
52
+ } ) ;
53
+ expect ( plotlyjs . newPlot . mock . calls . length ) . toBe ( 1 ) ;
54
+ } ) ;
55
+
56
+ it ( "overrides responsive attribute" , ( ) => {
57
+ attrs = {
58
+ responsive : true
59
+ } ;
60
+ wrapper = shallowMountPlotty ( ) ;
61
+
62
+ expect ( plotlyjs . newPlot ) . toHaveBeenCalledWith ( vm . $el , data , layout , {
63
+ responsive : false
45
64
} ) ;
46
65
expect ( plotlyjs . newPlot . mock . calls . length ) . toBe ( 1 ) ;
47
66
} ) ;
You can’t perform that action at this time.
0 commit comments