@gitlab/ui 32.32.0 → 32.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +7 -2
  3. package/dist/components/charts/area/area.js +3 -0
  4. package/dist/components/charts/bar/bar.js +2 -2
  5. package/dist/components/charts/chart/chart.js +20 -21
  6. package/dist/components/charts/legend/legend.js +1 -1
  7. package/dist/components/charts/tooltip/tooltip.js +1 -1
  8. package/dist/components/utilities/truncate/truncate.documentation.js +3 -0
  9. package/dist/components/utilities/truncate/truncate.js +34 -2
  10. package/dist/directives/resize_observer/resize_observer.documentation.js +1 -1
  11. package/dist/directives/resize_observer/resize_observer.js +43 -23
  12. package/dist/utility_classes.css +1 -1
  13. package/dist/utility_classes.css.map +1 -1
  14. package/dist/utils/charts/config.js +4 -3
  15. package/dist/utils/charts/mock_data.js +6 -3
  16. package/dist/utils/charts/theme.js +15 -9
  17. package/package.json +3 -3
  18. package/src/components/base/filtered_search/filtered_search_suggestion_list.spec.js +15 -8
  19. package/src/components/base/filtered_search/filtered_search_suggestion_list.vue +11 -2
  20. package/src/components/charts/area/area.vue +3 -0
  21. package/src/components/charts/bar/__snapshots__/bar.spec.js.snap +2 -2
  22. package/src/components/charts/bar/bar.vue +2 -2
  23. package/src/components/charts/chart/chart.spec.js +3 -1
  24. package/src/components/charts/chart/chart.vue +22 -20
  25. package/src/components/charts/column/__snapshots__/column_chart.spec.js.snap +6 -6
  26. package/src/components/charts/legend/legend.vue +1 -1
  27. package/src/components/charts/stacked_column/__snapshots__/stacked_column.spec.js.snap +26 -26
  28. package/src/components/charts/tooltip/tooltip.vue +1 -1
  29. package/src/components/utilities/truncate/truncate.documentation.js +3 -0
  30. package/src/components/utilities/truncate/truncate.spec.js +8 -0
  31. package/src/components/utilities/truncate/truncate.stories.js +6 -2
  32. package/src/components/utilities/truncate/truncate.vue +57 -7
  33. package/src/directives/resize_observer/resize_observer.js +34 -19
  34. package/src/directives/resize_observer/resize_observer.md +20 -0
  35. package/src/directives/resize_observer/resize_observer.spec.js +33 -1
  36. package/src/scss/utilities.scss +12 -0
  37. package/src/scss/utility-mixins/sizing.scss +6 -0
  38. package/src/utils/charts/config.js +3 -2
  39. package/src/utils/charts/mock_data.js +5 -2
  40. package/src/utils/charts/theme.js +14 -9
@@ -13,6 +13,7 @@ const blue500 = '#1f75cb';
13
13
  const defaultAreaOpacity = 0.2;
14
14
  const defaultFontSize = 12;
15
15
  const defaultHeight = 400;
16
+ const defaultWidth = 300;
16
17
  const validRenderers = ['canvas', 'svg'];
17
18
  const axes = {
18
19
  name: 'Value',
@@ -441,8 +442,8 @@ const generateBarSeries = ({
441
442
  yAxisIndex,
442
443
  itemStyle: {
443
444
  color: hexToRgba(color, 0.2),
444
- barBorderColor: color,
445
- barBorderWidth: 1
445
+ borderColor: color,
446
+ borderWidth: 1
446
447
  },
447
448
  emphasis: {
448
449
  itemStyle: {
@@ -526,4 +527,4 @@ var config = {
526
527
  };
527
528
 
528
529
  export default config;
529
- export { annotationsYAxisCoords, axes, dataZoomAdjustments, defaultAreaOpacity, defaultFontSize, defaultHeight, generateAnnotationSeries, generateBarSeries, generateLineSeries, getAnnotationsConfig, getDataZoomConfig, getDefaultTooltipContent, getThresholdConfig, getToolboxConfig, grid, gridWithSecondaryYAxis, lineStyle, mergeAnnotationAxisToOptions, mergeSeriesToOptions, parseAnnotations, symbolSize, validRenderers, xAxis, yAxis };
530
+ export { annotationsYAxisCoords, axes, dataZoomAdjustments, defaultAreaOpacity, defaultFontSize, defaultHeight, defaultWidth, generateAnnotationSeries, generateBarSeries, generateLineSeries, getAnnotationsConfig, getDataZoomConfig, getDefaultTooltipContent, getThresholdConfig, getToolboxConfig, grid, gridWithSecondaryYAxis, lineStyle, mergeAnnotationAxisToOptions, mergeSeriesToOptions, parseAnnotations, symbolSize, validRenderers, xAxis, yAxis };
@@ -39,7 +39,10 @@ const mockDefaultChartOptions = {
39
39
  },
40
40
  axisPointer: {
41
41
  show: true,
42
- label: {}
42
+ label: {},
43
+ lineStyle: {
44
+ type: 'solid'
45
+ }
43
46
  }
44
47
  },
45
48
  yAxis: {
@@ -182,8 +185,8 @@ const mockDefaultBarChartConfig = {
182
185
  yAxisIndex: 0,
183
186
  itemStyle: {
184
187
  color: hexToRgba(color, 0.2),
185
- barBorderColor: color,
186
- barBorderWidth: 1
188
+ borderColor: color,
189
+ borderWidth: 1
187
190
  },
188
191
  emphasis: {
189
192
  itemStyle: {
@@ -63,15 +63,14 @@ const axes = {
63
63
  margin: 8,
64
64
  show: true,
65
65
  color: gray600,
66
- textStyle: {
67
- color: gray600
68
- }
66
+ hideOverlap: true
69
67
  },
70
68
  axisLine: {
71
69
  show: false
72
70
  },
73
71
  axisPointer: {
74
72
  lineStyle: {
73
+ type: 'solid',
75
74
  color: gray600
76
75
  },
77
76
  label: {
@@ -131,6 +130,7 @@ const createTheme = (options = {}) => ({
131
130
  dataZoom: {
132
131
  borderColor: 'transparent',
133
132
  filterMode: 'none',
133
+ brushSelect: false,
134
134
  dataBackground: {
135
135
  lineStyle: {
136
136
  width: 2,
@@ -139,14 +139,18 @@ const createTheme = (options = {}) => ({
139
139
  },
140
140
  // render unfilled zoom-graph if the series is a line chart without area styles
141
141
  // more details: https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/2364#note_666637306
142
- areaStyle: isLineChartWithoutArea(options) ? null : {
142
+ areaStyle: isLineChartWithoutArea(options) ? {} // Use empty object instead of null, see https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/2185#note_707711029 for more context
143
+ : {
143
144
  color: gray50,
144
145
  opacity: 1
145
146
  }
146
147
  },
147
148
  fillerColor: hexToRgba(gray200, 0.23),
148
149
  handleIcon: scrollHandleSvgPath,
149
- handleColor: gray500,
150
+ handleStyle: {
151
+ borderColor: 'transparent',
152
+ color: gray500
153
+ },
150
154
  handleSize: '50%',
151
155
  labelFormatter: () => null,
152
156
  textStyle: {
@@ -157,14 +161,16 @@ const createTheme = (options = {}) => ({
157
161
  top: '-5',
158
162
  left: 'center',
159
163
  itemSize: 14,
160
- iconStyle: {
161
- color: gray200,
162
- borderWidth: 0,
163
- emphasis: {
164
+ emphasis: {
165
+ iconStyle: {
164
166
  borderWidth: 0,
165
167
  color: gray700
166
168
  }
167
169
  },
170
+ iconStyle: {
171
+ color: gray200,
172
+ borderWidth: 0
173
+ },
168
174
  itemGap: 8,
169
175
  feature: {
170
176
  dataZoom: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "32.32.0",
3
+ "version": "32.35.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -61,7 +61,7 @@
61
61
  "bootstrap-vue": "2.20.1",
62
62
  "copy-to-clipboard": "^3.0.8",
63
63
  "dompurify": "^2.3.3",
64
- "echarts": "^4.9.0",
64
+ "echarts": "^5.2.1",
65
65
  "highlight.js": "^10.6.0",
66
66
  "js-beautify": "^1.8.8",
67
67
  "lodash": "^4.17.20",
@@ -84,7 +84,7 @@
84
84
  "@babel/preset-env": "^7.10.2",
85
85
  "@gitlab/eslint-plugin": "9.4.0",
86
86
  "@gitlab/stylelint-config": "2.6.0",
87
- "@gitlab/svgs": "1.218.0",
87
+ "@gitlab/svgs": "1.220.0",
88
88
  "@rollup/plugin-commonjs": "^11.1.0",
89
89
  "@rollup/plugin-node-resolve": "^7.1.3",
90
90
  "@rollup/plugin-replace": "^2.3.2",
@@ -82,8 +82,8 @@ describe('Filtered search suggestion list component', () => {
82
82
  },
83
83
  template: `
84
84
  <div>
85
- <gl-filtered-search-suggestion value="1">1</gl-filtered-search-suggestion>
86
- <gl-filtered-search-suggestion value="2">2</gl-filtered-search-suggestion>
85
+ <gl-filtered-search-suggestion value="One">One</gl-filtered-search-suggestion>
86
+ <gl-filtered-search-suggestion value="Two">Two</gl-filtered-search-suggestion>
87
87
  </div>
88
88
  `,
89
89
  };
@@ -112,7 +112,7 @@ describe('Filtered search suggestion list component', () => {
112
112
  it('selects first suggestion', () => {
113
113
  wrapper.vm.nextItem();
114
114
  return wrapper.vm.$nextTick().then(() => {
115
- expect(wrapper.vm.getValue()).toBe('1');
115
+ expect(wrapper.vm.getValue()).toBe('One');
116
116
  });
117
117
  });
118
118
 
@@ -120,7 +120,7 @@ describe('Filtered search suggestion list component', () => {
120
120
  wrapper.vm.nextItem();
121
121
  wrapper.vm.nextItem();
122
122
  return wrapper.vm.$nextTick().then(() => {
123
- expect(wrapper.vm.getValue()).toBe('2');
123
+ expect(wrapper.vm.getValue()).toBe('Two');
124
124
  });
125
125
  });
126
126
 
@@ -146,7 +146,7 @@ describe('Filtered search suggestion list component', () => {
146
146
  wrapper.vm.prevItem();
147
147
  wrapper.vm.prevItem();
148
148
  return wrapper.vm.$nextTick().then(() => {
149
- expect(wrapper.vm.getValue()).toBe('2');
149
+ expect(wrapper.vm.getValue()).toBe('Two');
150
150
  });
151
151
  });
152
152
 
@@ -156,14 +156,21 @@ describe('Filtered search suggestion list component', () => {
156
156
  wrapper.vm.nextItem();
157
157
  wrapper.vm.nextItem();
158
158
  return wrapper.vm.$nextTick().then(() => {
159
- expect(wrapper.vm.getValue()).toBe('1');
159
+ expect(wrapper.vm.getValue()).toBe('One');
160
160
  });
161
161
  });
162
162
 
163
163
  it('highlights suggestion if initial-value is provided', () => {
164
- wrapper.setProps({ initialValue: '2' });
164
+ wrapper.setProps({ initialValue: 'Two' });
165
165
  return wrapper.vm.$nextTick().then(() => {
166
- expect(wrapper.find('.gl-filtered-search-suggestion-active').text()).toBe('2');
166
+ expect(wrapper.find('.gl-filtered-search-suggestion-active').text()).toBe('Two');
167
+ });
168
+ });
169
+
170
+ it('highlights suggestion if initial-value is provided, regardless of case sensitivity', async () => {
171
+ wrapper.setProps({ initialValue: 'two' });
172
+ return wrapper.vm.$nextTick().then(() => {
173
+ expect(wrapper.find('.gl-filtered-search-suggestion-active').text()).toBe('Two');
167
174
  });
168
175
  });
169
176
 
@@ -33,14 +33,23 @@ export default {
33
33
 
34
34
  watch: {
35
35
  initialValue(newValue) {
36
- this.activeIdx = this.registeredItems.findIndex((item) => item.value === newValue);
36
+ this.activeIdx = this.registeredItems.findIndex((item) =>
37
+ this.valuesMatch(item.value, newValue)
38
+ );
37
39
  },
38
40
  },
39
41
 
40
42
  methods: {
43
+ valuesMatch(firstValue, secondValue) {
44
+ if (!firstValue || !secondValue) return false;
45
+
46
+ return typeof firstValue === 'string'
47
+ ? firstValue.toLowerCase() === secondValue.toLowerCase()
48
+ : firstValue === secondValue;
49
+ },
41
50
  register(item) {
42
51
  this.registeredItems.push(item);
43
- if (item.value === this.initialValue) {
52
+ if (this.valuesMatch(item.value, this.initialValue)) {
44
53
  this.activeIdx = this.registeredItems.length - 1;
45
54
  }
46
55
  },
@@ -184,6 +184,9 @@ export default {
184
184
  xAxis: {
185
185
  axisPointer: {
186
186
  show: true,
187
+ lineStyle: {
188
+ type: 'solid',
189
+ },
187
190
  label: {
188
191
  formatter: this.onLabelChange,
189
192
  },
@@ -34,8 +34,8 @@ Object {
34
34
  },
35
35
  },
36
36
  "itemStyle": Object {
37
- "barBorderColor": "#5772ff",
38
- "barBorderWidth": 1,
37
+ "borderColor": "#5772ff",
38
+ "borderWidth": 1,
39
39
  "color": "rgba(87, 114, 255, 0.2)",
40
40
  },
41
41
  "name": "Office",
@@ -112,8 +112,8 @@ export default {
112
112
  stack: 'chart',
113
113
  itemStyle: {
114
114
  color: hexToRgba(barColor, 0.2),
115
- barBorderColor: barColor,
116
- barBorderWidth: 1,
115
+ borderColor: barColor,
116
+ borderWidth: 1,
117
117
  },
118
118
  emphasis: {
119
119
  itemStyle: {
@@ -1,5 +1,5 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
- import echarts from 'echarts';
2
+ import * as echarts from 'echarts';
3
3
  import Chart from './chart.vue';
4
4
  import createTheme from '~/utils/charts/theme';
5
5
 
@@ -35,6 +35,8 @@ describe('chart component', () => {
35
35
  themeName,
36
36
  {
37
37
  renderer: wrapper.props().renderer,
38
+ width: 300,
39
+ height: 400,
38
40
  }
39
41
  );
40
42
  });
@@ -1,6 +1,6 @@
1
1
  <script>
2
- import echarts from 'echarts';
3
- import { defaultHeight, validRenderers } from '../../../utils/charts/config';
2
+ import * as echarts from 'echarts';
3
+ import { defaultHeight, defaultWidth, validRenderers } from '../../../utils/charts/config';
4
4
  import createTheme, { themeName } from '../../../utils/charts/theme';
5
5
 
6
6
  export default {
@@ -66,25 +66,27 @@ export default {
66
66
  echarts.registerTheme(themeName, createTheme(this.options));
67
67
  }
68
68
  },
69
- mounted() {
70
- /* eslint-disable promise/catch-or-return, promise/always-return */
71
- this.$nextTick().then(() => {
72
- this.chart = echarts.init(this.$refs.chart, this.disableTheme ? null : themeName, {
73
- renderer: this.renderer,
74
- });
75
- if (this.groupId.length) {
76
- this.chart.group = this.groupId;
77
- echarts.connect(this.groupId);
78
- }
79
- this.chart.on('click', this.clickHandler);
80
- /**
81
- * Emitted after calling `echarts.init`
82
- */
83
- this.$emit('created', this.chart);
84
- this.draw();
85
- this.setChartSize();
69
+ async mounted() {
70
+ await this.$nextTick();
71
+
72
+ this.chart = echarts.init(this.$refs.chart, this.disableTheme ? null : themeName, {
73
+ renderer: this.renderer,
74
+ width: defaultWidth,
75
+ height: defaultHeight,
86
76
  });
87
- /* eslint-enable */
77
+
78
+ if (this.groupId.length) {
79
+ this.chart.group = this.groupId;
80
+ echarts.connect(this.groupId);
81
+ }
82
+
83
+ this.chart.on('click', this.clickHandler);
84
+ /**
85
+ * Emitted after calling `echarts.init`
86
+ */
87
+ this.$emit('created', this.chart);
88
+ this.draw();
89
+ this.setChartSize();
88
90
  },
89
91
  beforeDestroy() {
90
92
  this.chart.off('click', this.clickHandler);
@@ -50,8 +50,8 @@ Object {
50
50
  },
51
51
  },
52
52
  "itemStyle": Object {
53
- "barBorderColor": "#5772ff",
54
- "barBorderWidth": 1,
53
+ "borderColor": "#5772ff",
54
+ "borderWidth": 1,
55
55
  "color": "rgba(87, 114, 255, 0.2)",
56
56
  },
57
57
  "name": "Full",
@@ -240,8 +240,8 @@ Object {
240
240
  },
241
241
  },
242
242
  "itemStyle": Object {
243
- "barBorderColor": "#5772ff",
244
- "barBorderWidth": 1,
243
+ "borderColor": "#5772ff",
244
+ "borderWidth": 1,
245
245
  "color": "rgba(87, 114, 255, 0.2)",
246
246
  },
247
247
  "name": "Full",
@@ -271,8 +271,8 @@ Object {
271
271
  },
272
272
  },
273
273
  "itemStyle": Object {
274
- "barBorderColor": "#b24800",
275
- "barBorderWidth": 1,
274
+ "borderColor": "#b24800",
275
+ "borderWidth": 1,
276
276
  "color": "rgba(178, 72, 0, 0.2)",
277
277
  },
278
278
  "name": "Secondary 1",
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import echarts from 'echarts';
2
+ import * as echarts from 'echarts';
3
3
  import { gray200 } from '../../../../scss_to_js/scss_variables'; // eslint-disable-line import/no-unresolved
4
4
  import { defaultFontSize } from '../../../utils/charts/config';
5
5
  import {
@@ -34,8 +34,8 @@ Object {
34
34
  },
35
35
  },
36
36
  "itemStyle": Object {
37
- "barBorderColor": "#FFFHHH",
38
- "barBorderWidth": 1,
37
+ "borderColor": "#FFFHHH",
38
+ "borderWidth": 1,
39
39
  "color": "rgba(255, undefined, undefined, 0.2)",
40
40
  },
41
41
  "name": "Fun 1",
@@ -78,8 +78,8 @@ Object {
78
78
  },
79
79
  },
80
80
  "itemStyle": Object {
81
- "barBorderColor": "#FFFJJJ",
82
- "barBorderWidth": 1,
81
+ "borderColor": "#FFFJJJ",
82
+ "borderWidth": 1,
83
83
  "color": "rgba(255, undefined, undefined, 0.2)",
84
84
  },
85
85
  "name": "Fun 2",
@@ -122,8 +122,8 @@ Object {
122
122
  },
123
123
  },
124
124
  "itemStyle": Object {
125
- "barBorderColor": "#FFFIII",
126
- "barBorderWidth": 1,
125
+ "borderColor": "#FFFIII",
126
+ "borderWidth": 1,
127
127
  "color": "rgba(255, undefined, undefined, 0.2)",
128
128
  },
129
129
  "name": "Fun 3",
@@ -166,8 +166,8 @@ Object {
166
166
  },
167
167
  },
168
168
  "itemStyle": Object {
169
- "barBorderColor": "#FFFKKK",
170
- "barBorderWidth": 1,
169
+ "borderColor": "#FFFKKK",
170
+ "borderWidth": 1,
171
171
  "color": "rgba(255, undefined, undefined, 0.2)",
172
172
  },
173
173
  "name": "Fun 4",
@@ -290,8 +290,8 @@ Object {
290
290
  },
291
291
  },
292
292
  "itemStyle": Object {
293
- "barBorderColor": "#5772ff",
294
- "barBorderWidth": 1,
293
+ "borderColor": "#5772ff",
294
+ "borderWidth": 1,
295
295
  "color": "rgba(87, 114, 255, 0.2)",
296
296
  },
297
297
  "name": "Fun 1",
@@ -334,8 +334,8 @@ Object {
334
334
  },
335
335
  },
336
336
  "itemStyle": Object {
337
- "barBorderColor": "#b24800",
338
- "barBorderWidth": 1,
337
+ "borderColor": "#b24800",
338
+ "borderWidth": 1,
339
339
  "color": "rgba(178, 72, 0, 0.2)",
340
340
  },
341
341
  "name": "Fun 2",
@@ -378,8 +378,8 @@ Object {
378
378
  },
379
379
  },
380
380
  "itemStyle": Object {
381
- "barBorderColor": "#0094b6",
382
- "barBorderWidth": 1,
381
+ "borderColor": "#0094b6",
382
+ "borderWidth": 1,
383
383
  "color": "rgba(0, 148, 182, 0.2)",
384
384
  },
385
385
  "name": "Fun 3",
@@ -422,8 +422,8 @@ Object {
422
422
  },
423
423
  },
424
424
  "itemStyle": Object {
425
- "barBorderColor": "#366800",
426
- "barBorderWidth": 1,
425
+ "borderColor": "#366800",
426
+ "borderWidth": 1,
427
427
  "color": "rgba(54, 104, 0, 0.2)",
428
428
  },
429
429
  "name": "Fun 4",
@@ -651,8 +651,8 @@ Object {
651
651
  },
652
652
  },
653
653
  "itemStyle": Object {
654
- "barBorderColor": "#5772ff",
655
- "barBorderWidth": 1,
654
+ "borderColor": "#5772ff",
655
+ "borderWidth": 1,
656
656
  "color": "rgba(87, 114, 255, 0.2)",
657
657
  },
658
658
  "name": "Fun 1",
@@ -695,8 +695,8 @@ Object {
695
695
  },
696
696
  },
697
697
  "itemStyle": Object {
698
- "barBorderColor": "#b24800",
699
- "barBorderWidth": 1,
698
+ "borderColor": "#b24800",
699
+ "borderWidth": 1,
700
700
  "color": "rgba(178, 72, 0, 0.2)",
701
701
  },
702
702
  "name": "Fun 2",
@@ -739,8 +739,8 @@ Object {
739
739
  },
740
740
  },
741
741
  "itemStyle": Object {
742
- "barBorderColor": "#0094b6",
743
- "barBorderWidth": 1,
742
+ "borderColor": "#0094b6",
743
+ "borderWidth": 1,
744
744
  "color": "rgba(0, 148, 182, 0.2)",
745
745
  },
746
746
  "name": "Fun 3",
@@ -783,8 +783,8 @@ Object {
783
783
  },
784
784
  },
785
785
  "itemStyle": Object {
786
- "barBorderColor": "#366800",
787
- "barBorderWidth": 1,
786
+ "borderColor": "#366800",
787
+ "borderWidth": 1,
788
788
  "color": "rgba(54, 104, 0, 0.2)",
789
789
  },
790
790
  "name": "Fun 4",
@@ -827,8 +827,8 @@ Object {
827
827
  },
828
828
  },
829
829
  "itemStyle": Object {
830
- "barBorderColor": "#950943",
831
- "barBorderWidth": 1,
830
+ "borderColor": "#950943",
831
+ "borderWidth": 1,
832
832
  "color": "rgba(149, 9, 67, 0.2)",
833
833
  },
834
834
  "name": "Secondary 1",
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import echarts from 'echarts';
2
+ import * as echarts from 'echarts';
3
3
  import { uid } from '../../../utils/utils';
4
4
  import GlPopover from '../../base/popover/popover.vue';
5
5
 
@@ -12,5 +12,8 @@ export default {
12
12
  additionalInfo: 'Ellipsis position',
13
13
  enum: 'truncateOptions',
14
14
  },
15
+ withTooltip: {
16
+ additionalInfo: 'Display the full text in a tooltip only if it is being truncated',
17
+ },
15
18
  },
16
19
  };
@@ -1,6 +1,7 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
2
  import { POSITION } from './constants';
3
3
  import Truncate from './truncate.vue';
4
+ import { createMockDirective, getBinding } from '~helpers/vue_mock_directive';
4
5
 
5
6
  const removeSpecialChar = (text) => {
6
7
  return text.replace(/&lrm;|\u200E/gi, '');
@@ -18,6 +19,9 @@ describe('Truncate component', () => {
18
19
  const createComponent = (props) => {
19
20
  wrapper = shallowMount(Truncate, {
20
21
  propsData: { ...defaultProps, ...props },
22
+ directives: {
23
+ GlTooltip: createMockDirective(),
24
+ },
21
25
  });
22
26
  };
23
27
 
@@ -45,6 +49,10 @@ describe('Truncate component', () => {
45
49
  it('should have the default position', () => {
46
50
  expect(wrapper.props('position')).toBe('end');
47
51
  });
52
+
53
+ it('disables the tooltip by default', () => {
54
+ expect(getBinding(wrapper.element, 'gl-tooltip').value.disabled).toBe(true);
55
+ });
48
56
  });
49
57
 
50
58
  describe('start truncation', () => {
@@ -1,4 +1,4 @@
1
- import { withKnobs, text, select } from '@storybook/addon-knobs';
1
+ import { withKnobs, text, select, boolean } from '@storybook/addon-knobs';
2
2
  import { documentedStoriesOf } from '../../../../documentation/documented_stories';
3
3
  import { GlTruncate } from '../../../../index';
4
4
  import { POSITION } from './constants';
@@ -8,11 +8,12 @@ const components = {
8
8
  GlTruncate,
9
9
  };
10
10
 
11
- const template = '<gl-truncate :text="text" :position="position" />';
11
+ const template = '<gl-truncate :text="text" :position="position" :with-tooltip="withTooltip" />';
12
12
 
13
13
  function generateProps({
14
14
  longText = 'src/thisIs/AVeryLongFilePath/that/needs/to/be/smartly/truncated/from/the/middle/so/we/dont/lose/important/information/here.vue',
15
15
  position = 'middle',
16
+ withTooltip = false,
16
17
  } = {}) {
17
18
  return {
18
19
  text: {
@@ -23,6 +24,9 @@ function generateProps({
23
24
  type: String,
24
25
  default: select('position', Object.values(POSITION), position),
25
26
  },
27
+ withTooltip: {
28
+ default: boolean('withTooltip', withTooltip),
29
+ },
26
30
  };
27
31
  }
28
32