@icij/murmur-next 4.0.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.
- package/.github/workflows/deploy-github-pages.yaml +50 -0
- package/.storybook/app.scss +14 -0
- package/.storybook/doc_variables.scss +20 -0
- package/.storybook/main.ts +35 -0
- package/.storybook/preview-head.html +2 -0
- package/.storybook/preview.ts +32 -0
- package/README.md +71 -0
- package/deploy.js +15 -0
- package/docs/components/ApiTable.vue +171 -0
- package/docs/components/App.vue +146 -0
- package/docs/components/CollapsibleBlock.vue +122 -0
- package/docs/components/DocsHeader.vue +68 -0
- package/docs/components/DocsMenu.vue +201 -0
- package/docs/components/DocsMenuSection.vue +109 -0
- package/docs/components/EditLink.vue +49 -0
- package/docs/components/OutboundLink.vue +13 -0
- package/docs/components/PalettePresenter.vue +96 -0
- package/docs/components/RepositoryLink.vue +28 -0
- package/docs/components/SampleCard.vue +119 -0
- package/docs/main.js +42 -0
- package/docs/pages/components/accordion/doc.md +96 -0
- package/docs/pages/components/active-text-truncate/doc.md +44 -0
- package/docs/pages/components/advanced-link-form/doc.md +105 -0
- package/docs/pages/components/brand/doc.md +30 -0
- package/docs/pages/components/brand-expansion/doc.md +70 -0
- package/docs/pages/components/confirm-button/doc.md +91 -0
- package/docs/pages/components/content-placeholder/doc.md +16 -0
- package/docs/pages/components/custom-pagination/doc.md +61 -0
- package/docs/pages/components/digits-input/doc.md +28 -0
- package/docs/pages/components/donate-form/doc.md +20 -0
- package/docs/pages/components/embed-form/doc.md +22 -0
- package/docs/pages/components/embeddable-footer/doc.md +60 -0
- package/docs/pages/components/follow-us-popover/doc.md +5 -0
- package/docs/pages/components/generic-footer/doc.md +21 -0
- package/docs/pages/components/generic-header/doc.md +24 -0
- package/docs/pages/components/haptic-copy/doc.md +27 -0
- package/docs/pages/components/imddb-header/doc.md +23 -0
- package/docs/pages/components/ordinal-legend/doc.md +44 -0
- package/docs/pages/components/range-picker/doc.md +86 -0
- package/docs/pages/components/responsive-iframe/doc.md +13 -0
- package/docs/pages/components/scale-legend/doc.md +65 -0
- package/docs/pages/components/secret-input/doc.md +12 -0
- package/docs/pages/components/selectable-dropdown/doc.md +156 -0
- package/docs/pages/components/sharing-options/doc.md +13 -0
- package/docs/pages/components/sharing-options-link/doc.md +36 -0
- package/docs/pages/components/sign-up-form/doc.md +13 -0
- package/docs/pages/components/slide-up-down/doc.md +28 -0
- package/docs/pages/components/textured-deck/doc.md +78 -0
- package/docs/pages/components/tiny-pagination/doc.md +92 -0
- package/docs/pages/datavisualisation/bars/doc.md +110 -0
- package/docs/pages/datavisualisation/columns/doc.md +165 -0
- package/docs/pages/datavisualisation/lines/doc.md +139 -0
- package/docs/pages/datavisualisation/stacked-bar/doc.md +160 -0
- package/docs/pages/datavisualisation/stacked-column/doc.md +191 -0
- package/docs/pages/getting-started/about-icij/doc.md +13 -0
- package/docs/pages/getting-started/custom-bootstrap/doc.md +36 -0
- package/docs/pages/getting-started/installation-guide/doc.md +59 -0
- package/docs/pages/getting-started/internationalization/doc.md +74 -0
- package/docs/pages/maps/choropleth-map/doc.md +420 -0
- package/docs/pages/maps/choropleth-map-annotation/doc.md +373 -0
- package/docs/pages/maps/symbol-map/doc.md +203 -0
- package/docs/pages/structure/breakpoints/doc.md +3 -0
- package/docs/pages/structure/grid/doc.md +3 -0
- package/docs/pages/utilities/assets/doc.md +138 -0
- package/docs/pages/utilities/config/doc.md +52 -0
- package/docs/pages/utilities/iframes/doc.md +3 -0
- package/docs/pages/visual/colors/doc.md +31 -0
- package/docs/pages/visual/iconography/doc.md +56 -0
- package/docs/pages/visual/states/doc.md +77 -0
- package/docs/pages/visual/themes/doc.md +3 -0
- package/docs/pages/visual/typography/doc.md +71 -0
- package/docs/routes.js +25 -0
- package/docs/store/index.js +21 -0
- package/docs/styles/app.scss +36 -0
- package/docs/styles/variables.scss +20 -0
- package/lib/assets/images/icij-full-white.svg +6 -0
- package/lib/assets/images/icij-full.svg +6 -0
- package/lib/assets/images/icij.png +0 -0
- package/lib/assets/images/icij.svg +46 -0
- package/lib/assets/images/icij@2x.png +0 -0
- package/lib/assets/images/murmur-dark.png +0 -0
- package/lib/assets/images/murmur-dark.svg +79 -0
- package/lib/assets/images/murmur-white.png +0 -0
- package/lib/assets/images/murmur-white.svg +68 -0
- package/lib/components/AccordionStep.vue +128 -0
- package/lib/components/AccordionWrapper.vue +138 -0
- package/lib/components/ActiveTextTruncate.vue +258 -0
- package/lib/components/AdvancedLinkForm.vue +273 -0
- package/lib/components/Brand.vue +150 -0
- package/lib/components/BrandExpansion.vue +237 -0
- package/lib/components/ConfirmButton.vue +204 -0
- package/lib/components/ContentPlaceholder.vue +100 -0
- package/lib/components/CustomPagination.vue +225 -0
- package/lib/components/DigitsInput.vue +180 -0
- package/lib/components/DonateForm.vue +367 -0
- package/lib/components/EmbedForm.vue +173 -0
- package/lib/components/EmbeddableFooter.vue +201 -0
- package/lib/components/Fa.js +3 -0
- package/lib/components/FollowUsPopover.vue +117 -0
- package/lib/components/GenericFooter.vue +218 -0
- package/lib/components/GenericHeader.vue +259 -0
- package/lib/components/HapticCopy.vue +256 -0
- package/lib/components/ImddbHeader.vue +336 -0
- package/lib/components/OrdinalLegend.vue +164 -0
- package/lib/components/RangePicker.vue +430 -0
- package/lib/components/ResponsiveIframe.vue +48 -0
- package/lib/components/ScaleLegend.vue +230 -0
- package/lib/components/SecretInput.vue +132 -0
- package/lib/components/SelectableDropdown.vue +368 -0
- package/lib/components/SharingOptions.vue +230 -0
- package/lib/components/SharingOptionsLink.vue +259 -0
- package/lib/components/SignUpForm.vue +181 -0
- package/lib/components/SlideUpDown.vue +131 -0
- package/lib/components/TexturedDeck.vue +101 -0
- package/lib/components/TinyPagination.vue +268 -0
- package/lib/components/index.js +31 -0
- package/lib/composables/chart.ts +182 -0
- package/lib/composables/resizeObserver.ts +37 -0
- package/lib/composables/sendEmail.ts +50 -0
- package/lib/config.default.ts +33 -0
- package/lib/config.ts +70 -0
- package/lib/d3-geo-projection.d.ts +1 -0
- package/lib/datavisualisations/BarChart.vue +275 -0
- package/lib/datavisualisations/ColumnChart.vue +527 -0
- package/lib/datavisualisations/LineChart.vue +274 -0
- package/lib/datavisualisations/StackedBarChart.vue +614 -0
- package/lib/datavisualisations/StackedColumnChart.vue +640 -0
- package/lib/datavisualisations/index.js +5 -0
- package/lib/enums.ts +25 -0
- package/lib/i18n.ts +16 -0
- package/lib/keys.ts +2 -0
- package/lib/locales/en.json +140 -0
- package/lib/locales/fr.json +117 -0
- package/lib/locales/locales/en.json +140 -0
- package/lib/locales/locales/fr.json +117 -0
- package/lib/main.ts +87 -0
- package/lib/maps/ChoroplethMap.vue +825 -0
- package/lib/maps/ChoroplethMapAnnotation.vue +336 -0
- package/lib/maps/SymbolMap.vue +628 -0
- package/lib/maps/index.js +3 -0
- package/lib/querystring-es3.d.ts +1 -0
- package/lib/shims-bootstrap-vue.d.ts +5 -0
- package/lib/shims-tsx.d.ts +11 -0
- package/lib/shims-vue.d.ts +14 -0
- package/lib/styles/functions.scss +20 -0
- package/lib/styles/lib.scss +19 -0
- package/lib/styles/mixins.scss +37 -0
- package/lib/styles/utilities.scss +18 -0
- package/lib/styles/variables.scss +94 -0
- package/lib/styles/variables_dark.scss +1 -0
- package/lib/types.ts +46 -0
- package/lib/utils/animation.ts +24 -0
- package/lib/utils/assets.ts +46 -0
- package/lib/utils/clipboard.ts +41 -0
- package/lib/utils/iframe-resizer.ts +49 -0
- package/lib/utils/placeholder.ts +66 -0
- package/lib/utils/placeholderTypes.ts +21 -0
- package/lib/utils/strings.ts +8 -0
- package/loaders/highlight-loader.js +13 -0
- package/loaders/markdown-loader.js +91 -0
- package/loaders/metadata-loader.js +18 -0
- package/loaders/sass-extract-loader.js +14 -0
- package/loaders/vue-docgen-loader.js +14 -0
- package/package.json +96 -0
- package/plugins/MdPluginTypes.ts +10 -0
- package/plugins/docs.ts +50 -0
- package/plugins/front-matter.ts +36 -0
- package/plugins/highlight.ts +27 -0
- package/plugins/markdown-it/api-table.ts +25 -0
- package/plugins/markdown-it/sample-card.ts +31 -0
- package/plugins/plugin-delete.ts +47 -0
- package/plugins/plugin-docgen.ts +23 -0
- package/plugins/sass-vars.ts +25 -0
- package/plugins/vue-docgen.ts +29 -0
- package/public/android-chrome-192x192.png +0 -0
- package/public/android-chrome-512x512.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/assets/img/arrow-bottom.svg +3 -0
- package/public/assets/img/texture-brick-black.jpg +0 -0
- package/public/assets/img/texture-brick.jpg +0 -0
- package/public/assets/img/texture-carbon-black.jpg +0 -0
- package/public/assets/img/texture-carbon.jpg +0 -0
- package/public/assets/img/texture-crack-black.jpg +0 -0
- package/public/assets/img/texture-crack.jpg +0 -0
- package/public/assets/img/texture-rock-black.jpg +0 -0
- package/public/assets/img/texture-rock.jpg +0 -0
- package/public/assets/img/texture-sand-black.jpg +0 -0
- package/public/assets/img/texture-sand.jpg +0 -0
- package/public/assets/img/texture-silk-black.jpg +0 -0
- package/public/assets/img/texture-silk.jpg +0 -0
- package/public/assets/topojson/france-departments.json +1 -0
- package/public/assets/topojson/paris-arrondissements.json +1 -0
- package/public/assets/topojson/world-countries-sans-antarctica.json +1 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/site.webmanifest +1 -0
- package/stories/assets/code-brackets.svg +1 -0
- package/stories/assets/colors.svg +1 -0
- package/stories/assets/comments.svg +1 -0
- package/stories/assets/direction.svg +1 -0
- package/stories/assets/flow.svg +1 -0
- package/stories/assets/plugin.svg +1 -0
- package/stories/assets/repo.svg +1 -0
- package/stories/assets/stackalt.svg +1 -0
- package/stories/getting-started/about-icij.mdx +14 -0
- package/stories/getting-started/custom-bootstrap.mdx +23 -0
- package/stories/getting-started/installation-guide.mdx +62 -0
- package/stories/getting-started/internationalization.mdx +63 -0
- package/stories/murmur/components/AccordionStep.stories.ts +33 -0
- package/stories/murmur/components/AccordionWrapper.stories.ts +69 -0
- package/stories/murmur/components/ActiveTextTruncate.stories.ts +32 -0
- package/stories/murmur/components/AdvancedLinkForm.stories.ts +77 -0
- package/stories/murmur/components/Brand.stories.ts +30 -0
- package/stories/murmur/components/BrandExpansion.stories.ts +41 -0
- package/stories/murmur/components/ConfirmButton.stories.ts +40 -0
- package/stories/murmur/components/ContentPlaceholder.stories.ts +41 -0
- package/stories/murmur/components/CustomPagination.stories.ts +42 -0
- package/stories/murmur/components/DigitsInput.stories.ts +29 -0
- package/stories/murmur/components/DonateForm.stories.ts +29 -0
- package/stories/murmur/components/EmbedForm.stories.ts +35 -0
- package/stories/murmur/components/EmbeddableFooter.stories.ts +59 -0
- package/stories/murmur/components/FollowUsPopover.stories.ts +24 -0
- package/stories/murmur/components/GenericFooter.stories.ts +27 -0
- package/stories/murmur/components/GenericHeader.stories.ts +27 -0
- package/stories/murmur/components/HapticCopy.stories.ts +40 -0
- package/stories/murmur/components/ImddbHeader.stories.ts +27 -0
- package/stories/murmur/components/OrdinalLegend.stories.ts +49 -0
- package/stories/murmur/components/RangePicker.stories.ts +98 -0
- package/stories/murmur/components/ResponsiveIframe.stories.ts +24 -0
- package/stories/murmur/components/ScaleLegend.stories.ts +65 -0
- package/stories/murmur/components/SecretInput.stories.ts +60 -0
- package/stories/murmur/components/SelectableDropdown.stories.ts +143 -0
- package/stories/murmur/components/SharingOptions.stories.ts +32 -0
- package/stories/murmur/components/SharingOptionsLink.stories.ts +53 -0
- package/stories/murmur/components/SignUpForm.stories.ts +51 -0
- package/stories/murmur/components/SlideUpDown.stories.ts +32 -0
- package/stories/murmur/components/TexturedDeck.stories.ts +83 -0
- package/stories/murmur/components/TinyPagination.stories.ts +65 -0
- package/stories/murmur/datavisualisations/BarChart.stories.ts +54 -0
- package/stories/murmur/datavisualisations/ColumnChart.stories.ts +88 -0
- package/stories/murmur/datavisualisations/LineChart.stories.ts +139 -0
- package/stories/murmur/datavisualisations/StackedBarChart.stories.ts +199 -0
- package/stories/murmur/datavisualisations/StackedColumnChart.stories.ts +136 -0
- package/stories/murmur/decorators.ts +108 -0
- package/stories/murmur/maps/ChoroplethMap.stories.ts +440 -0
- package/stories/murmur/maps/ChoroplethMapAnnotation.stories.ts +26 -0
- package/stories/murmur/maps/SymbolMap.stories.ts +24 -0
- package/stories/murmur/utils.ts +7 -0
- package/tests/unit/components/AccordionStep.spec.ts +157 -0
- package/tests/unit/components/AccordionWrapper.spec.ts +57 -0
- package/tests/unit/components/ActiveTextTruncate.spec.js +30 -0
- package/tests/unit/components/AdvancedLinkForm.spec.js +124 -0
- package/tests/unit/components/Brand.spec.js +50 -0
- package/tests/unit/components/ContentPlaceholder.spec.js +29 -0
- package/tests/unit/components/CustomPagination.spec.js +72 -0
- package/tests/unit/components/DigitsInput.spec.ts +157 -0
- package/tests/unit/components/DonateForm.spec.js +149 -0
- package/tests/unit/components/EmbedForm.spec.js +108 -0
- package/tests/unit/components/EmbeddableFooter.spec.js +11 -0
- package/tests/unit/components/Fa.spec.js +18 -0
- package/tests/unit/components/FollowUsPopover.spec.js +29 -0
- package/tests/unit/components/GenericFooter.spec.js +29 -0
- package/tests/unit/components/GenericHeader.spec.js +104 -0
- package/tests/unit/components/HapticCopy.spec.js +123 -0
- package/tests/unit/components/ImddbHeader.spec.js +96 -0
- package/tests/unit/components/OrdinalLegend.spec.js +120 -0
- package/tests/unit/components/RangePicker.spec.ts +87 -0
- package/tests/unit/components/ResponsiveIframe.spec.js +20 -0
- package/tests/unit/components/ScaleLegend.spec.js +139 -0
- package/tests/unit/components/SecretInput.spec.js +81 -0
- package/tests/unit/components/SelectableDropdown.spec.js +160 -0
- package/tests/unit/components/SharingOptions.spec.js +125 -0
- package/tests/unit/components/SharingOptionsLink.spec.js +184 -0
- package/tests/unit/components/SignUpForm.spec.js +145 -0
- package/tests/unit/components/SlideUpDown.spec.js +59 -0
- package/tests/unit/components/TinyPagination.spec.js +46 -0
- package/tests/unit/config.spec.js +136 -0
- package/tests/unit/datavisualisations/BarChart.spec.js +63 -0
- package/tests/unit/datavisualisations/ColumnChart.spec.js +344 -0
- package/tests/unit/datavisualisations/LineChart.spec.js +155 -0
- package/tests/unit/datavisualisations/StackedBarChart.spec.js +294 -0
- package/tests/unit/datavisualisations/StackedColumnChart.spec.js +443 -0
- package/tests/unit/i18n.spec.ts +19 -0
- package/tests/unit/main.spec.js +82 -0
- package/tests/unit/maps/ChoroplethMap.spec.js +214 -0
- package/tests/unit/maps/ChoroplethMapAnnotation.spec.ts +186 -0
- package/tests/unit/maps/SymbolMap.spec.js +92 -0
- package/tests/unit/require.spec.js +22 -0
- package/tests/unit/setup.js +13 -0
- package/tests/unit/utils/assets.spec.js +61 -0
- package/tests/unit/utils/clipboard.spec.js +18 -0
- package/tests/unit/utils/iframe-resizer.spec.js +71 -0
- package/tsconfig.json +35 -0
- package/vite.config.ts +79 -0
- package/vitest.config.ts +19 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { mount } from '@vue/test-utils'
|
|
2
|
+
import HapticCopy from '@/components/HapticCopy.vue'
|
|
3
|
+
import noop from 'lodash/noop'
|
|
4
|
+
|
|
5
|
+
describe('HapticCopy.vue', () => {
|
|
6
|
+
|
|
7
|
+
const propsData = { text: 'Lorem ipsum', noTooltip: true }
|
|
8
|
+
|
|
9
|
+
beforeAll(() => {
|
|
10
|
+
// Prevent multiple Bootstrap Vue warnings in tests
|
|
11
|
+
vi.spyOn(console, 'warn').mockImplementation(() => {})
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
afterAll(() => {
|
|
15
|
+
console.warn.mockClear()
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('is a Vue instance', () => {
|
|
19
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
20
|
+
expect(wrapper.vm).toBeTruthy()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('should generate a button', () => {
|
|
24
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
25
|
+
expect(wrapper.find('button').exists()).toBeTruthy()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('shouldn\'t hide the label', () => {
|
|
29
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
30
|
+
expect(wrapper.find('.haptic-copy__label').classes('sr-only')).toBeFalsy()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('should hide the label', () => {
|
|
34
|
+
const wrapper = mount(HapticCopy, {
|
|
35
|
+
propsData: {
|
|
36
|
+
...propsData,
|
|
37
|
+
hideLabel: true
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
expect(wrapper.find('.haptic-copy__label').classes('sr-only')).toBeTruthy()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('should use a custom label', () => {
|
|
44
|
+
const wrapper = mount(HapticCopy, {
|
|
45
|
+
propsData: {
|
|
46
|
+
...propsData,
|
|
47
|
+
label: 'Copy in the clipboard'
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
expect(wrapper.find('.haptic-copy__label').text()).toBe('Copy in the clipboard')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('should emit an `success` event after copying text', async () => {
|
|
54
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
55
|
+
await wrapper.vm.copy()
|
|
56
|
+
expect(wrapper.emitted().success).toBeTruthy()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('should emit an `attempt` event before copying text', async () => {
|
|
60
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
61
|
+
await wrapper.vm.copy()
|
|
62
|
+
expect(wrapper.emitted().attempt).toBeTruthy()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('should not fill the tooltip content with an error', async () => {
|
|
66
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
67
|
+
await wrapper.vm.copy()
|
|
68
|
+
expect(wrapper.vm.tooltipContent).not.toBe('Unable to copy the text')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('should fill the tooltip content with a success message', () => {
|
|
72
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
73
|
+
wrapper.vm.openTooltip()
|
|
74
|
+
expect(wrapper.vm.tooltipContent).toBe('Copied!')
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('should empty tooltip content', async () => {
|
|
78
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
79
|
+
await wrapper.vm.closeTooltip()
|
|
80
|
+
expect(wrapper.vm.tooltipContent).toBe('')
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('should have a method `nextTimeout` which returns a promise', () => {
|
|
84
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
85
|
+
const promise = wrapper.vm.nextTimeout(noop, 0)
|
|
86
|
+
expect(promise.then).toBeDefined()
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('should have a method `copy` which returns a promise', () => {
|
|
90
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
91
|
+
const promise = wrapper.vm.copy()
|
|
92
|
+
expect(promise.then).toBeDefined()
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('should have a method `openTooltip` which returns a promise', () => {
|
|
96
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
97
|
+
const promise = wrapper.vm.openTooltip()
|
|
98
|
+
expect(promise.then).toBeDefined()
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('should have a method `closeTooltip` which returns a promise', () => {
|
|
102
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
103
|
+
const promise = wrapper.vm.closeTooltip()
|
|
104
|
+
expect(promise.then).toBeDefined()
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('should change the tooltip content with locale message', () => {
|
|
108
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
109
|
+
wrapper.vm.openTooltip('haptic-copy.tooltip.succeed')
|
|
110
|
+
expect(wrapper.vm.tooltipContent).toBe('Copied!')
|
|
111
|
+
wrapper.vm.openTooltip('haptic-copy.tooltip.failed')
|
|
112
|
+
expect(wrapper.vm.tooltipContent).toBe('Unable to copy the text')
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('should change the tooltip content with arbitrary message', () => {
|
|
116
|
+
const wrapper = mount(HapticCopy, { propsData })
|
|
117
|
+
wrapper.vm.openTooltip('foo')
|
|
118
|
+
expect(wrapper.vm.tooltipContent).toBe('foo')
|
|
119
|
+
wrapper.vm.openTooltip('bar')
|
|
120
|
+
expect(wrapper.vm.tooltipContent).toBe('bar')
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
})
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { mount,shallowMount } from '@vue/test-utils'
|
|
2
|
+
import ImddbHeader from '@/components/ImddbHeader.vue'
|
|
3
|
+
|
|
4
|
+
describe('ImddbHeader.vue', () => {
|
|
5
|
+
//const global = {renderStubDefaultSlot: true}
|
|
6
|
+
it('is a Vue instance', () => {
|
|
7
|
+
const wrapper = shallowMount(ImddbHeader)
|
|
8
|
+
expect(wrapper.vm).toBeTruthy()
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('renders the header as a `headroom` component', () => {
|
|
12
|
+
const wrapper = shallowMount(ImddbHeader)
|
|
13
|
+
expect(wrapper.findComponent('headroom-stub').exists()).toBe(true)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('renders the header as a div', () => {
|
|
17
|
+
const noHeadroom = true
|
|
18
|
+
const wrapper = shallowMount(ImddbHeader, {
|
|
19
|
+
propsData: { noHeadroom }
|
|
20
|
+
})
|
|
21
|
+
expect(wrapper.find('#imddb-header').element.tagName).toBe('DIV')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('sets the header position to `fixed` by default', () => {
|
|
25
|
+
const wrapper = shallowMount(ImddbHeader)
|
|
26
|
+
expect(wrapper.find('#imddb-header').element.style.position).toBe('fixed')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('sets the header position to `relative`', () => {
|
|
30
|
+
const position = 'relative'
|
|
31
|
+
const wrapper = shallowMount(ImddbHeader, {
|
|
32
|
+
propsData: { position }
|
|
33
|
+
})
|
|
34
|
+
expect(wrapper.find('#imddb-header').element.style.position).toBe(position)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('sets the header position to `absolute`', () => {
|
|
38
|
+
const position = 'absolute'
|
|
39
|
+
const wrapper = shallowMount(ImddbHeader, {
|
|
40
|
+
propsData: { position }
|
|
41
|
+
})
|
|
42
|
+
expect(wrapper.find('#imddb-header').element.style.position).toBe(position)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('renders home link to the default value', () => {
|
|
46
|
+
const homeUrl = "http://localhost:3000/"
|
|
47
|
+
const wrapper = shallowMount(ImddbHeader, {global:{renderStubDefaultSlot: true}})
|
|
48
|
+
expect(wrapper.find('.imddb-header__brand').element.href).toBe(homeUrl)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('renders home link to https://icij.org/', () => {
|
|
52
|
+
const homeUrl = 'https://icij.org/'
|
|
53
|
+
const wrapper = shallowMount(ImddbHeader, {
|
|
54
|
+
propsData: { homeUrl }, global:{renderStubDefaultSlot: true}
|
|
55
|
+
})
|
|
56
|
+
expect(wrapper.find('.imddb-header__brand').element.href).toBe(homeUrl)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('renders home link to https://pirhoo.com/', () => {
|
|
60
|
+
const homeUrl = 'https://pirhoo.com/'
|
|
61
|
+
const wrapper = shallowMount(ImddbHeader, {
|
|
62
|
+
propsData: { homeUrl }, global:{renderStubDefaultSlot: true}
|
|
63
|
+
})
|
|
64
|
+
expect(wrapper.find('.imddb-header__brand').element.href).toBe(homeUrl)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('renders the navbar as `collapse` by default', () => {
|
|
68
|
+
const wrapper = shallowMount(ImddbHeader,{global:{renderStubDefaultSlot: true}})
|
|
69
|
+
expect(wrapper.find('.navbar-collapse').classes('collapse')).toBeTruthy()
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('toggles the navbar', async () => {
|
|
73
|
+
const wrapper = shallowMount(ImddbHeader, {global:{renderStubDefaultSlot: true}})
|
|
74
|
+
await wrapper.vm.$nextTick()
|
|
75
|
+
expect(wrapper.find('.navbar-collapse').classes('collapse')).toBeTruthy()
|
|
76
|
+
wrapper.vm.toggleNavbar()
|
|
77
|
+
await wrapper.vm.$nextTick()
|
|
78
|
+
expect(wrapper.find('.navbar-collapse').classes('collapse')).toBeFalsy()
|
|
79
|
+
wrapper.vm.toggleNavbar()
|
|
80
|
+
await wrapper.vm.$nextTick()
|
|
81
|
+
expect(wrapper.find('.navbar-collapse').classes('collapse')).toBeTruthy()
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('should show on mouseenter then hide popover\'',async () => {
|
|
85
|
+
const wrapper = mount(ImddbHeader,{global:{renderStubDefaultSlot: true},
|
|
86
|
+
stubs: { teleport: true, BPopover:true , FollowUsPopover:true}})
|
|
87
|
+
|
|
88
|
+
expect(wrapper.vm.showFollowUsPopover).toBe(false)
|
|
89
|
+
const popovertoggler = wrapper.find("#follow-icij")
|
|
90
|
+
await popovertoggler.trigger("mouseenter")
|
|
91
|
+
expect(wrapper.vm.showFollowUsPopover).toBe(true)
|
|
92
|
+
|
|
93
|
+
wrapper.vm.closeFollowUsPopover()
|
|
94
|
+
expect(wrapper.vm.showFollowUsPopover).toBe(false)
|
|
95
|
+
})
|
|
96
|
+
})
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils'
|
|
2
|
+
import OrdinalLegend from '@/components/OrdinalLegend.vue'
|
|
3
|
+
|
|
4
|
+
describe('OrdinalLegend.vue', () => {
|
|
5
|
+
let wrapper
|
|
6
|
+
|
|
7
|
+
describe('an horizontal legend', () => {
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
const propsData = {
|
|
10
|
+
data: [
|
|
11
|
+
{ id: 1, color: '#6e40aa', label: 'Paris, France' },
|
|
12
|
+
{ id: 2, color: '#ff5e63', label: 'Sydney, Australia' },
|
|
13
|
+
{ id: 3, color: '#aff05b', label: 'Washington DC, USA' }
|
|
14
|
+
],
|
|
15
|
+
horizontal: true
|
|
16
|
+
}
|
|
17
|
+
wrapper = shallowMount(OrdinalLegend, { propsData })
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('should be horizontal', () => {
|
|
21
|
+
expect(wrapper.classes('ordinal-legend--horizontal')).toBeTruthy()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('should start with Paris', () => {
|
|
25
|
+
expect(wrapper.findAll('.ordinal-legend__item__label').at(0).text()).toBe('Paris, France')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('should end with DC', () => {
|
|
29
|
+
expect(wrapper.findAll('.ordinal-legend__item__label').at(2).text()).toBe('Washington DC, USA')
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('should create 3 legend items', () => {
|
|
33
|
+
expect(wrapper.findAll('.ordinal-legend__item')).toHaveLength(3)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('should create a marker with the right color for Paris', () => {
|
|
37
|
+
const path = wrapper.findAll('.ordinal-legend__item__marker__path').at(0)
|
|
38
|
+
const { nodeValue: fill } = path.element.getAttributeNode('fill')
|
|
39
|
+
expect(fill).toBe('#6e40aa')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should create a marker with the right color for Sydney', () => {
|
|
43
|
+
const path = wrapper.findAll('.ordinal-legend__item__marker__path').at(1)
|
|
44
|
+
const { nodeValue: fill } = path.element.getAttributeNode('fill')
|
|
45
|
+
expect(fill).toBe('#ff5e63')
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
describe('a vertical legend with an highlight', () => {
|
|
51
|
+
beforeEach(() => {
|
|
52
|
+
const propsData = {
|
|
53
|
+
data: [
|
|
54
|
+
{ id: 1, color: '#6e40aa', label: 'Paris, France' },
|
|
55
|
+
{ id: 2, color: '#ff5e63', label: 'Sydney, Australia' },
|
|
56
|
+
{ id: 3, color: '#aff05b', label: 'Washington DC, USA' }
|
|
57
|
+
],
|
|
58
|
+
highlight: 2,
|
|
59
|
+
value: 1,
|
|
60
|
+
horizontal: false
|
|
61
|
+
}
|
|
62
|
+
wrapper = shallowMount(OrdinalLegend, { propsData })
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('should be not horizontal', () => {
|
|
66
|
+
expect(wrapper.classes('ordinal-legend--horizontal')).toBeFalsy()
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('should create 3 legend items', () => {
|
|
70
|
+
expect(wrapper.findAll('.ordinal-legend__item')).toHaveLength(3)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('should not highlight the first item', () => {
|
|
74
|
+
const item = wrapper.findAll('.ordinal-legend__item').at(0)
|
|
75
|
+
expect(item.classes('ordinal-legend__item--highlighted')).toBeFalsy()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('should highlight the second item', () => {
|
|
79
|
+
const item = wrapper.findAll('.ordinal-legend__item').at(1)
|
|
80
|
+
expect(item.classes('ordinal-legend__item--highlighted')).toBeTruthy()
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('should highlight the first item', () => {
|
|
84
|
+
const item = wrapper.findAll('.ordinal-legend__item').at(0)
|
|
85
|
+
expect(item.classes('ordinal-legend__item--selected')).toBeTruthy()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('should emit an highlight event when mouse over the first item', async () => {
|
|
89
|
+
const item = wrapper.findAll('.ordinal-legend__item a').at(0)
|
|
90
|
+
await item.trigger('mouseover')
|
|
91
|
+
expect(wrapper.emitted('update:highlight')).toBeTruthy()
|
|
92
|
+
expect(wrapper.emitted('update:highlight')).toHaveLength(1)
|
|
93
|
+
expect(wrapper.emitted('update:highlight')[0]).toEqual([1])
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it('should emit an highlight event when mouse over the last item', async () => {
|
|
97
|
+
const item = wrapper.findAll('.ordinal-legend__item a').at(2)
|
|
98
|
+
await item.trigger('mouseover')
|
|
99
|
+
expect(wrapper.emitted('update:highlight')).toBeTruthy()
|
|
100
|
+
expect(wrapper.emitted('update:highlight')).toHaveLength(1)
|
|
101
|
+
expect(wrapper.emitted('update:highlight')[0]).toEqual([3])
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('should emit an update event when mouse click the first item', async () => {
|
|
105
|
+
const item = wrapper.findAll('.ordinal-legend__item a').at(0)
|
|
106
|
+
await item.trigger('click')
|
|
107
|
+
expect(wrapper.emitted('update')).toBeTruthy()
|
|
108
|
+
expect(wrapper.emitted('update')).toHaveLength(1)
|
|
109
|
+
expect(wrapper.emitted('update')[0]).toEqual([1])
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('should emit an update event when mouse click the last item', async () => {
|
|
113
|
+
const item = wrapper.findAll('.ordinal-legend__item a').at(2)
|
|
114
|
+
await item.trigger('click')
|
|
115
|
+
expect(wrapper.emitted('update')).toBeTruthy()
|
|
116
|
+
expect(wrapper.emitted('update')).toHaveLength(1)
|
|
117
|
+
expect(wrapper.emitted('update')[0]).toEqual([3])
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
})
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {shallowMount} from '@vue/test-utils'
|
|
2
|
+
|
|
3
|
+
import RangePicker from '@/components/RangePicker.vue'
|
|
4
|
+
|
|
5
|
+
describe('RangePicker.vue', () => {
|
|
6
|
+
|
|
7
|
+
it('renders without crashing', () => {
|
|
8
|
+
const wrapper = shallowMount(RangePicker, {
|
|
9
|
+
propsData: {
|
|
10
|
+
range: [0.2, 0.8]
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
expect(wrapper.exists()).toBe(true)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('correctly initializes data with props', () => {
|
|
17
|
+
const wrapper = shallowMount(RangePicker, {
|
|
18
|
+
propsData: {
|
|
19
|
+
range: [0.2, 0.8]
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
expect(wrapper.vm.start).toBe(0.2)
|
|
23
|
+
expect(wrapper.vm.end).toBe(0.8)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('sets the correct class based on the variant prop', async () => {
|
|
27
|
+
const wrapper = shallowMount(RangePicker, {
|
|
28
|
+
propsData: { range: [0.1, 0.9], variant: 'secondary' }
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
expect(wrapper.classes()).toContain('range-picker--secondary')
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('sets the rounded class if rounded prop is true', async () => {
|
|
35
|
+
const wrapper = shallowMount(RangePicker, {
|
|
36
|
+
propsData: { range: [0.1, 0.9], rounded: true }
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
expect(wrapper.classes()).toContain('range-picker--rounded')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('sets the hover class if hover prop is true', async () => {
|
|
43
|
+
const wrapper = shallowMount(RangePicker, {
|
|
44
|
+
propsData: { range: [0.1, 0.9], hover: true }
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
expect(wrapper.classes()).toContain('range-picker--hover')
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('sets the disabled class if value prop is empty', async () => {
|
|
51
|
+
const wrapper = shallowMount(RangePicker, {
|
|
52
|
+
propsData: { range: [] }
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
expect(wrapper.classes()).toContain('range-picker--disabled')
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('hides the bounds if value prop is empty', async () => {
|
|
59
|
+
const wrapper = shallowMount(RangePicker, {
|
|
60
|
+
propsData: { range: [] }
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
expect(wrapper.find('.range-picker__bounds').isVisible()).toBeFalsy()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('does not allow bounds closer than minDistance', async () => {
|
|
67
|
+
const wrapper = shallowMount(RangePicker, {
|
|
68
|
+
propsData: { range: [0.1, 0.11], minDistance: 0.05 }
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
wrapper.vm.dragStartBound(0.06)
|
|
72
|
+
await wrapper.vm.$nextTick()
|
|
73
|
+
|
|
74
|
+
expect(wrapper.vm.start).not.toBe(0.06)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('snaps value based on snap prop', async () => {
|
|
78
|
+
const wrapper = shallowMount(RangePicker, {
|
|
79
|
+
propsData: { range: [0.1, 0.9], snap: 0.05 }
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
wrapper.vm.dragStartBound(0.12)
|
|
83
|
+
await wrapper.vm.$nextTick()
|
|
84
|
+
|
|
85
|
+
expect(wrapper.vm.start).toBe(0.10)
|
|
86
|
+
})
|
|
87
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils'
|
|
2
|
+
import ResponsiveIframe from '@/components/ResponsiveIframe'
|
|
3
|
+
|
|
4
|
+
describe('ResponsiveIframe', () => {
|
|
5
|
+
|
|
6
|
+
const propsData = {
|
|
7
|
+
url: 'https://projects.icij.org/the-implant-files/graphics/'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
it('is a Vue instance', () => {
|
|
11
|
+
const wrapper = shallowMount(ResponsiveIframe, { propsData })
|
|
12
|
+
expect(wrapper.vm).toBeTruthy()
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('creates a root div with a unique id', () => {
|
|
16
|
+
const first = shallowMount(ResponsiveIframe, { propsData })
|
|
17
|
+
const second = shallowMount(ResponsiveIframe, { propsData })
|
|
18
|
+
expect(first.element.id).not.toBe(second.element.id)
|
|
19
|
+
})
|
|
20
|
+
})
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils'
|
|
2
|
+
import { scaleThreshold } from 'd3-scale'
|
|
3
|
+
import ScaleLegend from '@/components/ScaleLegend.vue'
|
|
4
|
+
import { vi } from 'vitest'
|
|
5
|
+
|
|
6
|
+
describe('ScaleLegend.vue', () => {
|
|
7
|
+
let wrapper
|
|
8
|
+
// Common mocks on computed properties
|
|
9
|
+
const colorScaleContext = vi.fn(() => ({ fillRect: vi.fn() }))
|
|
10
|
+
const colorScaleBase64 = vi.fn()
|
|
11
|
+
const computed = { colorScaleBase64, colorScaleContext }
|
|
12
|
+
|
|
13
|
+
describe('with a the default scale function', () => {
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
const propsData = { min: 0, max: 150 }
|
|
17
|
+
wrapper = shallowMount(ScaleLegend, { propsData, computed })
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('should be a Vue instance', () => {
|
|
21
|
+
expect(wrapper.vm).toBeTruthy()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('should return 0% for no `cursorValue`', () => {
|
|
25
|
+
expect(wrapper.vm.cursorLeft).toBe('0%')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('should return 0% for 0 as `cursorValue`', async () => {
|
|
29
|
+
await wrapper.setProps({ cursorValue: 0 })
|
|
30
|
+
expect(wrapper.vm.cursorLeft).toBe('0%')
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('should return 100% for 150 as `cursorValue`', async () => {
|
|
34
|
+
await wrapper.setProps({ cursorValue: 150 })
|
|
35
|
+
expect(wrapper.vm.cursorLeft).toBe('100%')
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('should return have cursor for 150 as `cursorValue`', async () => {
|
|
39
|
+
await wrapper.setProps({ cursorValue: 150 })
|
|
40
|
+
expect(wrapper.vm.hasCursor).toBeTruthy()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('should return set a class for 150 as `cursorValue`', async () => {
|
|
44
|
+
await wrapper.setProps({ cursorValue: 150 })
|
|
45
|
+
expect(wrapper.classes('scale-legend--has-cursor')).toBeTruthy()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('should not have cursor for null as `cursorValue`', async () => {
|
|
49
|
+
await wrapper.setProps({ cursorValue: null })
|
|
50
|
+
expect(wrapper.vm.hasCursor).toBeFalsy()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('should return not set a class for null as `cursorValue`', async () => {
|
|
54
|
+
await wrapper.setProps({ cursorValue: null })
|
|
55
|
+
expect(wrapper.classes('scale-legend--has-cursor')).toBeFalsy()
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('should give around 100 for the width 100', () => {
|
|
59
|
+
const value = Math.round(wrapper.vm.widthScale(100))
|
|
60
|
+
expect(value).toBe(100)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('should give around 150 for the width 150', () => {
|
|
64
|
+
const value = Math.round(wrapper.vm.widthScale(150))
|
|
65
|
+
expect(value).toBe(150)
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe('with a threshold scale', () => {
|
|
70
|
+
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
// Create a scale with:
|
|
73
|
+
// * values from 0 to 10,000 in white
|
|
74
|
+
// * values from 10,000 to 20,000 in pink
|
|
75
|
+
// * values from 20,000 to 30,000 in red
|
|
76
|
+
const colorScale = scaleThreshold()
|
|
77
|
+
.domain([1e4, 2e4])
|
|
78
|
+
.range(["white", "pink", "red"])
|
|
79
|
+
// Create a scale for value between 0 and 30,000
|
|
80
|
+
const propsData = { min: 0, max: 3e4, width: 150, colorScale }
|
|
81
|
+
wrapper = shallowMount(ScaleLegend, { propsData, computed })
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('should be a Vue instance', () => {
|
|
85
|
+
expect(wrapper.vm).toBeTruthy()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('should get the correct colors', () => {
|
|
89
|
+
expect(wrapper.vm.colorScaleFunction(0)).toBe('white')
|
|
90
|
+
expect(wrapper.vm.colorScaleFunction(1e3)).toBe('white')
|
|
91
|
+
expect(wrapper.vm.colorScaleFunction(1e4)).toBe('pink')
|
|
92
|
+
expect(wrapper.vm.colorScaleFunction(1e5)).toBe('red')
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('should get white for the x value 0', () => {
|
|
96
|
+
expect(wrapper.vm.widthScaleColor(0)).toBe('white')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('should get white for the x value 25', () => {
|
|
100
|
+
expect(wrapper.vm.widthScaleColor(25)).toBe('white')
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('should get pink for the x value 99', () => {
|
|
104
|
+
expect(wrapper.vm.widthScaleColor(99)).toBe('pink')
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('should get pink for the x value 75', () => {
|
|
108
|
+
expect(wrapper.vm.widthScaleColor(75)).toBe('pink')
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('should get red for the x value 125', () => {
|
|
112
|
+
expect(wrapper.vm.widthScaleColor(125)).toBe('red')
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('should get red for the x value 150', () => {
|
|
116
|
+
expect(wrapper.vm.widthScaleColor(150)).toBe('red')
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('should return 33% for 10,000 as `cursorValue`', async () => {
|
|
120
|
+
await wrapper.setProps({ cursorValue: 1e4 })
|
|
121
|
+
expect(wrapper.vm.cursorLeft).toBe('33%')
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('should return 50% for 15,000 as `cursorValue`', async () => {
|
|
125
|
+
await wrapper.setProps({ cursorValue: 15e3 })
|
|
126
|
+
expect(wrapper.vm.cursorLeft).toBe('50%')
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
it('should return 67% for 20,000 as `cursorValue`', async () => {
|
|
130
|
+
await wrapper.setProps({ cursorValue: 2e4 })
|
|
131
|
+
expect(wrapper.vm.cursorLeft).toBe('67%')
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('should return 100% for 30,000 as `cursorValue`', async () => {
|
|
135
|
+
await wrapper.setProps({ cursorValue: 3e4 })
|
|
136
|
+
expect(wrapper.vm.cursorLeft).toBe('100%')
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
})
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { mount, shallowMount } from '@vue/test-utils'
|
|
2
|
+
import SecretInput from '@/components/SecretInput.vue'
|
|
3
|
+
|
|
4
|
+
describe('SecretInput.vue', () => {
|
|
5
|
+
// Stubs Bootstrap Vue components
|
|
6
|
+
const stubs = ['b-input-group-prepend', 'b-input-group-append', 'b-input-group', 'b-form-input', 'b-button', 'haptic-copy']
|
|
7
|
+
const global = {stubs, renderStubDefaultSlot:true}
|
|
8
|
+
it('should be a Vue instance', () => {
|
|
9
|
+
const wrapper = shallowMount(SecretInput, { global })
|
|
10
|
+
expect(wrapper.vm).toBeTruthy()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('changes visibility according to the "visible" prop', async () => {
|
|
14
|
+
const propsData = { value: 'a secret value' }
|
|
15
|
+
const wrapper = shallowMount(SecretInput, { global, propsData })
|
|
16
|
+
expect(wrapper.vm.inputType).toBe("password")
|
|
17
|
+
await wrapper.setProps({ visible: true })
|
|
18
|
+
expect(wrapper.vm.inputType).toBe("text")
|
|
19
|
+
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('sets initial visibility according to the "visible" prop', () => {
|
|
23
|
+
const propsData = { value: 'a secret value', visible: true }
|
|
24
|
+
const wrapper = shallowMount(SecretInput, { global, propsData })
|
|
25
|
+
expect(wrapper.vm.inputType).toBe("text")
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('emits "input" event when changing visibility', async () => {
|
|
29
|
+
const propsData = { value: 'a secret value' }
|
|
30
|
+
const wrapper = mount(SecretInput, { global, propsData })
|
|
31
|
+
await wrapper.find(".secret-input__toggler").trigger("click")
|
|
32
|
+
expect(wrapper.emitted("update:visible")).toBeTruthy()
|
|
33
|
+
expect(wrapper.emitted("update:visible")[0][0]).toBe(true)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('shows an eye icon when input is not visible', () => {
|
|
37
|
+
const propsData = { value: 'a secret value', visible: false }
|
|
38
|
+
const wrapper = shallowMount(SecretInput, { global, propsData })
|
|
39
|
+
expect(wrapper.vm.togglerIcon[1]).toBe('eye')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('shows an eye-slash icon when input is visible', () => {
|
|
43
|
+
const propsData = { value: 'a secret value', visible: true }
|
|
44
|
+
const wrapper = shallowMount(SecretInput, { global, propsData })
|
|
45
|
+
expect(wrapper.vm.togglerIcon[1]).toBe('eye-slash')
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('shows the toggler button by default', () => {
|
|
49
|
+
const wrapper = mount(SecretInput, {global})
|
|
50
|
+
expect(wrapper.find('.secret-input__toggler').exists()).toBeTruthy()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('hides the toggler button', () => {
|
|
54
|
+
const propsData = { value: 'a secret value', noToggler: true }
|
|
55
|
+
const wrapper = shallowMount(SecretInput, { global, propsData })
|
|
56
|
+
expect(wrapper.find('.secret-input__toggler').exists()).toBeFalsy()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('shows the haptic copy button by default', () => {
|
|
60
|
+
const wrapper = shallowMount(SecretInput, { global })
|
|
61
|
+
expect(wrapper.find('.secret-input__copy').exists()).toBeTruthy()
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('hides the haptic copy button', () => {
|
|
65
|
+
const propsData = { value: 'a secret value', noHapticCopy: true }
|
|
66
|
+
const wrapper = shallowMount(SecretInput, { global, propsData })
|
|
67
|
+
expect(wrapper.find('.secret-input__copy').exists()).toBeFalsy()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('uses haptic copy button primary variant by default', () => {
|
|
71
|
+
const wrapper = shallowMount(SecretInput, { global })
|
|
72
|
+
expect(wrapper.find('.secret-input__copy').classes('btn-primary')).toBeTruthy()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('changes haptic copy button variant', () => {
|
|
76
|
+
const propsData = { hapticCopyVariant: 'info' }
|
|
77
|
+
const wrapper = shallowMount(SecretInput, { global, propsData })
|
|
78
|
+
expect(wrapper.find('.secret-input__copy').classes('btn-primary')).toBeFalsy()
|
|
79
|
+
expect(wrapper.find('.secret-input__copy').classes('btn-info')).toBeTruthy()
|
|
80
|
+
})
|
|
81
|
+
})
|