@icij/murmur-next 4.0.0 → 4.0.3
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/README.md +15 -19
- package/dist/lib/components/AccordionStep.vue.d.ts +79 -0
- package/dist/lib/components/AccordionWrapper.vue.d.ts +33 -0
- package/dist/lib/components/ActiveTextTruncate.vue.d.ts +101 -0
- package/dist/lib/components/AdvancedLinkForm.vue.d.ts +168 -0
- package/dist/lib/components/Brand.vue.d.ts +55 -0
- package/dist/lib/components/BrandExpansion.vue.d.ts +105 -0
- package/dist/lib/components/ConfirmButton.vue.d.ts +158 -0
- package/dist/lib/components/ContentPlaceholder.vue.d.ts +44 -0
- package/dist/lib/components/CustomPagination.vue.d.ts +130 -0
- package/dist/lib/components/DigitsInput.vue.d.ts +66 -0
- package/dist/lib/components/DonateForm.vue.d.ts +46 -0
- package/dist/lib/components/EmbedForm.vue.d.ts +121 -0
- package/dist/lib/components/EmbeddableFooter.vue.d.ts +103 -0
- package/dist/lib/components/FollowUsPopover.vue.d.ts +16 -0
- package/dist/lib/components/GenericFooter.vue.d.ts +47 -0
- package/dist/lib/components/GenericHeader.vue.d.ts +928 -0
- package/dist/lib/components/HapticCopy.vue.d.ts +156 -0
- package/dist/lib/components/ImddbHeader.vue.d.ts +960 -0
- package/dist/lib/components/OrdinalLegend.vue.d.ts +87 -0
- package/dist/lib/components/RangePicker.vue.d.ts +196 -0
- package/dist/lib/components/ResponsiveIframe.vue.d.ts +45 -0
- package/dist/lib/components/ScaleLegend.vue.d.ts +101 -0
- package/dist/lib/components/SecretInput.vue.d.ts +99 -0
- package/dist/lib/components/SelectableDropdown.vue.d.ts +210 -0
- package/dist/lib/components/SharingOptions.vue.d.ts +153 -0
- package/dist/lib/components/SharingOptionsLink.vue.d.ts +200 -0
- package/dist/lib/components/SignUpForm.vue.d.ts +141 -0
- package/dist/lib/components/SlideUpDown.vue.d.ts +74 -0
- package/dist/lib/components/TexturedDeck.vue.d.ts +89 -0
- package/dist/lib/components/TinyPagination.vue.d.ts +188 -0
- package/dist/lib/composables/chart.d.ts +48 -0
- package/dist/lib/composables/resizeObserver.d.ts +22 -0
- package/dist/lib/composables/sendEmail.d.ts +6 -0
- package/dist/lib/config.d.ts +19 -0
- package/dist/lib/config.default.d.ts +34 -0
- package/dist/lib/datavisualisations/BarChart.vue.d.ts +234 -0
- package/dist/lib/datavisualisations/ColumnChart.vue.d.ts +404 -0
- package/dist/lib/datavisualisations/LineChart.vue.d.ts +200 -0
- package/dist/lib/datavisualisations/StackedBarChart.vue.d.ts +342 -0
- package/dist/lib/datavisualisations/StackedColumnChart.vue.d.ts +412 -0
- package/dist/lib/enums.d.ts +32 -0
- package/dist/lib/i18n.d.ts +4 -0
- package/dist/lib/keys.d.ts +2 -0
- package/dist/lib/main.d.ts +52 -0
- package/dist/lib/maps/ChoroplethMap.vue.d.ts +460 -0
- package/dist/lib/maps/ChoroplethMapAnnotation.vue.d.ts +188 -0
- package/dist/lib/maps/SymbolMap.vue.d.ts +276 -0
- package/dist/lib/murmur.css +1 -0
- package/dist/lib/murmur.js +44661 -0
- package/dist/lib/murmur.js.map +1 -0
- package/dist/lib/murmur.umd.cjs +837 -0
- package/dist/lib/murmur.umd.cjs.map +1 -0
- package/dist/lib/types.d.ts +44 -0
- package/dist/lib/utils/animation.d.ts +8 -0
- package/dist/lib/utils/assets.d.ts +2 -0
- package/dist/lib/utils/clipboard.d.ts +2 -0
- package/dist/lib/utils/iframe-resizer.d.ts +10 -0
- package/dist/lib/utils/placeholder.d.ts +12 -0
- package/dist/lib/utils/placeholderTypes.d.ts +18 -0
- package/dist/lib/utils/strings.d.ts +1 -0
- package/lib/components/AccordionStep.vue +53 -42
- package/lib/components/AccordionWrapper.vue +25 -24
- package/lib/components/ActiveTextTruncate.vue +44 -22
- package/lib/components/AdvancedLinkForm.vue +96 -46
- package/lib/components/Brand.vue +30 -23
- package/lib/components/BrandExpansion.vue +12 -3
- package/lib/components/ConfirmButton.vue +30 -26
- package/lib/components/ContentPlaceholder.vue +11 -7
- package/lib/components/CustomPagination.vue +50 -32
- package/lib/components/DigitsInput.vue +64 -60
- package/lib/components/DonateForm.vue +112 -83
- package/lib/components/EmbedForm.vue +37 -21
- package/lib/components/EmbeddableFooter.vue +14 -10
- package/lib/components/FollowUsPopover.vue +42 -40
- package/lib/components/GenericFooter.vue +98 -23
- package/lib/components/GenericHeader.vue +66 -29
- package/lib/components/HapticCopy.vue +41 -29
- package/lib/components/ImddbHeader.vue +113 -92
- package/lib/components/OrdinalLegend.vue +43 -20
- package/lib/components/RangePicker.vue +63 -42
- package/lib/components/ResponsiveIframe.vue +9 -2
- package/lib/components/ScaleLegend.vue +56 -18
- package/lib/components/SecretInput.vue +7 -8
- package/lib/components/SelectableDropdown.vue +119 -74
- package/lib/components/SharingOptions.vue +93 -36
- package/lib/components/SharingOptionsLink.vue +11 -5
- package/lib/components/SignUpForm.vue +44 -23
- package/lib/components/SlideUpDown.vue +7 -2
- package/lib/components/TexturedDeck.vue +24 -14
- package/lib/components/TinyPagination.vue +35 -22
- package/lib/composables/chart.ts +174 -157
- package/lib/composables/resizeObserver.ts +29 -29
- package/lib/composables/sendEmail.ts +53 -42
- package/lib/config.default.ts +17 -10
- package/lib/config.ts +34 -27
- package/lib/datavisualisations/BarChart.vue +48 -42
- package/lib/datavisualisations/ColumnChart.vue +133 -89
- package/lib/datavisualisations/LineChart.vue +79 -57
- package/lib/datavisualisations/StackedBarChart.vue +116 -68
- package/lib/datavisualisations/StackedColumnChart.vue +196 -115
- package/lib/enums.ts +25 -15
- package/lib/i18n.ts +3 -3
- package/lib/keys.ts +2 -2
- package/lib/main.ts +14 -10
- package/lib/maps/ChoroplethMap.vue +299 -160
- package/lib/maps/ChoroplethMapAnnotation.vue +29 -18
- package/lib/maps/SymbolMap.vue +194 -123
- package/lib/shims-bootstrap-vue.d.ts +1 -1
- package/lib/shims-vue.d.ts +3 -3
- package/lib/styles/functions.scss +10 -6
- package/lib/styles/lib.scss +2 -4
- package/lib/styles/mixins.scss +8 -8
- package/lib/styles/utilities.scss +1 -1
- package/lib/styles/variables.scss +24 -18
- package/lib/types.ts +26 -10
- package/lib/utils/animation.ts +4 -4
- package/lib/utils/assets.ts +31 -28
- package/lib/utils/clipboard.ts +16 -10
- package/lib/utils/iframe-resizer.ts +18 -13
- package/lib/utils/placeholder.ts +54 -23
- package/lib/utils/placeholderTypes.ts +3 -3
- package/package.json +21 -2
- package/.github/workflows/deploy-github-pages.yaml +0 -50
- package/.storybook/app.scss +0 -14
- package/.storybook/doc_variables.scss +0 -20
- package/.storybook/main.ts +0 -35
- package/.storybook/preview-head.html +0 -2
- package/.storybook/preview.ts +0 -32
- package/deploy.js +0 -15
- package/docs/components/ApiTable.vue +0 -171
- package/docs/components/App.vue +0 -146
- package/docs/components/CollapsibleBlock.vue +0 -122
- package/docs/components/DocsHeader.vue +0 -68
- package/docs/components/DocsMenu.vue +0 -201
- package/docs/components/DocsMenuSection.vue +0 -109
- package/docs/components/EditLink.vue +0 -49
- package/docs/components/OutboundLink.vue +0 -13
- package/docs/components/PalettePresenter.vue +0 -96
- package/docs/components/RepositoryLink.vue +0 -28
- package/docs/components/SampleCard.vue +0 -119
- package/docs/main.js +0 -42
- package/docs/pages/components/accordion/doc.md +0 -96
- package/docs/pages/components/active-text-truncate/doc.md +0 -44
- package/docs/pages/components/advanced-link-form/doc.md +0 -105
- package/docs/pages/components/brand/doc.md +0 -30
- package/docs/pages/components/brand-expansion/doc.md +0 -70
- package/docs/pages/components/confirm-button/doc.md +0 -91
- package/docs/pages/components/content-placeholder/doc.md +0 -16
- package/docs/pages/components/custom-pagination/doc.md +0 -61
- package/docs/pages/components/digits-input/doc.md +0 -28
- package/docs/pages/components/donate-form/doc.md +0 -20
- package/docs/pages/components/embed-form/doc.md +0 -22
- package/docs/pages/components/embeddable-footer/doc.md +0 -60
- package/docs/pages/components/follow-us-popover/doc.md +0 -5
- package/docs/pages/components/generic-footer/doc.md +0 -21
- package/docs/pages/components/generic-header/doc.md +0 -24
- package/docs/pages/components/haptic-copy/doc.md +0 -27
- package/docs/pages/components/imddb-header/doc.md +0 -23
- package/docs/pages/components/ordinal-legend/doc.md +0 -44
- package/docs/pages/components/range-picker/doc.md +0 -86
- package/docs/pages/components/responsive-iframe/doc.md +0 -13
- package/docs/pages/components/scale-legend/doc.md +0 -65
- package/docs/pages/components/secret-input/doc.md +0 -12
- package/docs/pages/components/selectable-dropdown/doc.md +0 -156
- package/docs/pages/components/sharing-options/doc.md +0 -13
- package/docs/pages/components/sharing-options-link/doc.md +0 -36
- package/docs/pages/components/sign-up-form/doc.md +0 -13
- package/docs/pages/components/slide-up-down/doc.md +0 -28
- package/docs/pages/components/textured-deck/doc.md +0 -78
- package/docs/pages/components/tiny-pagination/doc.md +0 -92
- package/docs/pages/datavisualisation/bars/doc.md +0 -110
- package/docs/pages/datavisualisation/columns/doc.md +0 -165
- package/docs/pages/datavisualisation/lines/doc.md +0 -139
- package/docs/pages/datavisualisation/stacked-bar/doc.md +0 -160
- package/docs/pages/datavisualisation/stacked-column/doc.md +0 -191
- package/docs/pages/getting-started/about-icij/doc.md +0 -13
- package/docs/pages/getting-started/custom-bootstrap/doc.md +0 -36
- package/docs/pages/getting-started/installation-guide/doc.md +0 -59
- package/docs/pages/getting-started/internationalization/doc.md +0 -74
- package/docs/pages/maps/choropleth-map/doc.md +0 -420
- package/docs/pages/maps/choropleth-map-annotation/doc.md +0 -373
- package/docs/pages/maps/symbol-map/doc.md +0 -203
- package/docs/pages/structure/breakpoints/doc.md +0 -3
- package/docs/pages/structure/grid/doc.md +0 -3
- package/docs/pages/utilities/assets/doc.md +0 -138
- package/docs/pages/utilities/config/doc.md +0 -52
- package/docs/pages/utilities/iframes/doc.md +0 -3
- package/docs/pages/visual/colors/doc.md +0 -31
- package/docs/pages/visual/iconography/doc.md +0 -56
- package/docs/pages/visual/states/doc.md +0 -77
- package/docs/pages/visual/themes/doc.md +0 -3
- package/docs/pages/visual/typography/doc.md +0 -71
- package/docs/routes.js +0 -25
- package/docs/store/index.js +0 -21
- package/docs/styles/app.scss +0 -36
- package/docs/styles/variables.scss +0 -20
- package/loaders/highlight-loader.js +0 -13
- package/loaders/markdown-loader.js +0 -91
- package/loaders/metadata-loader.js +0 -18
- package/loaders/sass-extract-loader.js +0 -14
- package/loaders/vue-docgen-loader.js +0 -14
- package/plugins/MdPluginTypes.ts +0 -10
- package/plugins/docs.ts +0 -50
- package/plugins/front-matter.ts +0 -36
- package/plugins/highlight.ts +0 -27
- package/plugins/markdown-it/api-table.ts +0 -25
- package/plugins/markdown-it/sample-card.ts +0 -31
- package/plugins/plugin-delete.ts +0 -47
- package/plugins/plugin-docgen.ts +0 -23
- package/plugins/sass-vars.ts +0 -25
- package/plugins/vue-docgen.ts +0 -29
- 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 +0 -3
- 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 +0 -1
- package/public/assets/topojson/paris-arrondissements.json +0 -1
- package/public/assets/topojson/world-countries-sans-antarctica.json +0 -1
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/site.webmanifest +0 -1
- package/stories/assets/code-brackets.svg +0 -1
- package/stories/assets/colors.svg +0 -1
- package/stories/assets/comments.svg +0 -1
- package/stories/assets/direction.svg +0 -1
- package/stories/assets/flow.svg +0 -1
- package/stories/assets/plugin.svg +0 -1
- package/stories/assets/repo.svg +0 -1
- package/stories/assets/stackalt.svg +0 -1
- package/stories/getting-started/about-icij.mdx +0 -14
- package/stories/getting-started/custom-bootstrap.mdx +0 -23
- package/stories/getting-started/installation-guide.mdx +0 -62
- package/stories/getting-started/internationalization.mdx +0 -63
- package/stories/murmur/components/AccordionStep.stories.ts +0 -33
- package/stories/murmur/components/AccordionWrapper.stories.ts +0 -69
- package/stories/murmur/components/ActiveTextTruncate.stories.ts +0 -32
- package/stories/murmur/components/AdvancedLinkForm.stories.ts +0 -77
- package/stories/murmur/components/Brand.stories.ts +0 -30
- package/stories/murmur/components/BrandExpansion.stories.ts +0 -41
- package/stories/murmur/components/ConfirmButton.stories.ts +0 -40
- package/stories/murmur/components/ContentPlaceholder.stories.ts +0 -41
- package/stories/murmur/components/CustomPagination.stories.ts +0 -42
- package/stories/murmur/components/DigitsInput.stories.ts +0 -29
- package/stories/murmur/components/DonateForm.stories.ts +0 -29
- package/stories/murmur/components/EmbedForm.stories.ts +0 -35
- package/stories/murmur/components/EmbeddableFooter.stories.ts +0 -59
- package/stories/murmur/components/FollowUsPopover.stories.ts +0 -24
- package/stories/murmur/components/GenericFooter.stories.ts +0 -27
- package/stories/murmur/components/GenericHeader.stories.ts +0 -27
- package/stories/murmur/components/HapticCopy.stories.ts +0 -40
- package/stories/murmur/components/ImddbHeader.stories.ts +0 -27
- package/stories/murmur/components/OrdinalLegend.stories.ts +0 -49
- package/stories/murmur/components/RangePicker.stories.ts +0 -98
- package/stories/murmur/components/ResponsiveIframe.stories.ts +0 -24
- package/stories/murmur/components/ScaleLegend.stories.ts +0 -65
- package/stories/murmur/components/SecretInput.stories.ts +0 -60
- package/stories/murmur/components/SelectableDropdown.stories.ts +0 -143
- package/stories/murmur/components/SharingOptions.stories.ts +0 -32
- package/stories/murmur/components/SharingOptionsLink.stories.ts +0 -53
- package/stories/murmur/components/SignUpForm.stories.ts +0 -51
- package/stories/murmur/components/SlideUpDown.stories.ts +0 -32
- package/stories/murmur/components/TexturedDeck.stories.ts +0 -83
- package/stories/murmur/components/TinyPagination.stories.ts +0 -65
- package/stories/murmur/datavisualisations/BarChart.stories.ts +0 -54
- package/stories/murmur/datavisualisations/ColumnChart.stories.ts +0 -88
- package/stories/murmur/datavisualisations/LineChart.stories.ts +0 -139
- package/stories/murmur/datavisualisations/StackedBarChart.stories.ts +0 -199
- package/stories/murmur/datavisualisations/StackedColumnChart.stories.ts +0 -136
- package/stories/murmur/decorators.ts +0 -108
- package/stories/murmur/maps/ChoroplethMap.stories.ts +0 -440
- package/stories/murmur/maps/ChoroplethMapAnnotation.stories.ts +0 -26
- package/stories/murmur/maps/SymbolMap.stories.ts +0 -24
- package/stories/murmur/utils.ts +0 -7
- package/tests/unit/components/AccordionStep.spec.ts +0 -157
- package/tests/unit/components/AccordionWrapper.spec.ts +0 -57
- package/tests/unit/components/ActiveTextTruncate.spec.js +0 -30
- package/tests/unit/components/AdvancedLinkForm.spec.js +0 -124
- package/tests/unit/components/Brand.spec.js +0 -50
- package/tests/unit/components/ContentPlaceholder.spec.js +0 -29
- package/tests/unit/components/CustomPagination.spec.js +0 -72
- package/tests/unit/components/DigitsInput.spec.ts +0 -157
- package/tests/unit/components/DonateForm.spec.js +0 -149
- package/tests/unit/components/EmbedForm.spec.js +0 -108
- package/tests/unit/components/EmbeddableFooter.spec.js +0 -11
- package/tests/unit/components/Fa.spec.js +0 -18
- package/tests/unit/components/FollowUsPopover.spec.js +0 -29
- package/tests/unit/components/GenericFooter.spec.js +0 -29
- package/tests/unit/components/GenericHeader.spec.js +0 -104
- package/tests/unit/components/HapticCopy.spec.js +0 -123
- package/tests/unit/components/ImddbHeader.spec.js +0 -96
- package/tests/unit/components/OrdinalLegend.spec.js +0 -120
- package/tests/unit/components/RangePicker.spec.ts +0 -87
- package/tests/unit/components/ResponsiveIframe.spec.js +0 -20
- package/tests/unit/components/ScaleLegend.spec.js +0 -139
- package/tests/unit/components/SecretInput.spec.js +0 -81
- package/tests/unit/components/SelectableDropdown.spec.js +0 -160
- package/tests/unit/components/SharingOptions.spec.js +0 -125
- package/tests/unit/components/SharingOptionsLink.spec.js +0 -184
- package/tests/unit/components/SignUpForm.spec.js +0 -145
- package/tests/unit/components/SlideUpDown.spec.js +0 -59
- package/tests/unit/components/TinyPagination.spec.js +0 -46
- package/tests/unit/config.spec.js +0 -136
- package/tests/unit/datavisualisations/BarChart.spec.js +0 -63
- package/tests/unit/datavisualisations/ColumnChart.spec.js +0 -344
- package/tests/unit/datavisualisations/LineChart.spec.js +0 -155
- package/tests/unit/datavisualisations/StackedBarChart.spec.js +0 -294
- package/tests/unit/datavisualisations/StackedColumnChart.spec.js +0 -443
- package/tests/unit/i18n.spec.ts +0 -19
- package/tests/unit/main.spec.js +0 -82
- package/tests/unit/maps/ChoroplethMap.spec.js +0 -214
- package/tests/unit/maps/ChoroplethMapAnnotation.spec.ts +0 -186
- package/tests/unit/maps/SymbolMap.spec.js +0 -92
- package/tests/unit/require.spec.js +0 -22
- package/tests/unit/setup.js +0 -13
- package/tests/unit/utils/assets.spec.js +0 -61
- package/tests/unit/utils/clipboard.spec.js +0 -18
- package/tests/unit/utils/iframe-resizer.spec.js +0 -71
- package/tsconfig.json +0 -35
- package/vite.config.ts +0 -79
- package/vitest.config.ts +0 -19
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import {shallowMount, mount, flushPromises} from '@vue/test-utils'
|
|
2
|
-
import SelectableDropdown from '@/components/SelectableDropdown.vue'
|
|
3
|
-
|
|
4
|
-
const KEY_UP_CODE = 38
|
|
5
|
-
const KEY_DOWN_CODE = 40
|
|
6
|
-
const KEY_MAP = {}
|
|
7
|
-
|
|
8
|
-
// Wrapper the addEventListener to trigger events
|
|
9
|
-
window.addEventListener = vi.fn((event, cb) => {
|
|
10
|
-
KEY_MAP[event] = cb
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
describe('SelectableDropdown.vue', () => {
|
|
14
|
-
beforeAll(()=>{
|
|
15
|
-
// Removes warning about IntersectionObserver used in vue virtual scroller
|
|
16
|
-
// but not implemented in jsdom
|
|
17
|
-
const mockIntersectionObserver = vi.fn();
|
|
18
|
-
mockIntersectionObserver.mockReturnValue({
|
|
19
|
-
observe: () => null,
|
|
20
|
-
unobserve: () => null,
|
|
21
|
-
disconnect: () => null
|
|
22
|
-
});
|
|
23
|
-
window.IntersectionObserver = mockIntersectionObserver;
|
|
24
|
-
})
|
|
25
|
-
afterAll(()=> {
|
|
26
|
-
window.IntersectionObserver.mockClear()
|
|
27
|
-
})
|
|
28
|
-
it('is a Vue instance', () => {
|
|
29
|
-
const wrapper = mount(SelectableDropdown)
|
|
30
|
-
expect(wrapper.vm).toBeTruthy()
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('has a list of items', async () => {
|
|
34
|
-
const propsData = { items: ['Lesotho', 'Senegal', 'Djibouti'] , hide:false}
|
|
35
|
-
const wrapper = mount(SelectableDropdown, { propsData } )
|
|
36
|
-
await flushPromises()
|
|
37
|
-
expect(wrapper.findAll('.dropdown-item')).toHaveLength(3)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('has a list of items written in upper case', async () => {
|
|
41
|
-
const propsData = { items: ['Lesotho', 'Senegal', 'Djibouti'], serializer: c => c.toUpperCase() }
|
|
42
|
-
const wrapper = mount(SelectableDropdown, { propsData })
|
|
43
|
-
await flushPromises()
|
|
44
|
-
|
|
45
|
-
expect(wrapper.findAll('.dropdown-item').at(0).text()).toBe('LESOTHO')
|
|
46
|
-
expect(wrapper.findAll('.dropdown-item').at(1).text()).toBe('SENEGAL')
|
|
47
|
-
expect(wrapper.findAll('.dropdown-item').at(2).text()).toBe('DJIBOUTI')
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('has a list a `list` class', () => {
|
|
51
|
-
const propsData = { items: ['Lesotho', 'Senegal', 'Djibouti'], listClass: 'list' }
|
|
52
|
-
const wrapper = mount(SelectableDropdown, { propsData })
|
|
53
|
-
expect(wrapper.find('.list').exists()).toBeTruthy()
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('has a list of items with a `item` class', async () => {
|
|
57
|
-
const propsData = { items: ['Lesotho', 'Senegal', 'Djibouti'], itemClass: 'item' }
|
|
58
|
-
const wrapper = mount(SelectableDropdown, { propsData })
|
|
59
|
-
await flushPromises()
|
|
60
|
-
|
|
61
|
-
expect(wrapper.findAll('.item').at(0).text()).toBe('Lesotho')
|
|
62
|
-
expect(wrapper.findAll('.item').at(1).text()).toBe('Senegal')
|
|
63
|
-
expect(wrapper.findAll('.item').at(2).text()).toBe('Djibouti')
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('updates active indexes when hitting arrow down', async () => {
|
|
67
|
-
const propsData = { items: ['Lesotho', 'Senegal', 'Djibouti'], modelValue: 'Lesotho' }
|
|
68
|
-
const wrapper = mount(SelectableDropdown, { propsData })
|
|
69
|
-
await flushPromises()
|
|
70
|
-
|
|
71
|
-
expect(wrapper.vm.activeItems).toContain('Lesotho')
|
|
72
|
-
KEY_MAP.keydown({ keyCode: KEY_DOWN_CODE })
|
|
73
|
-
expect(wrapper.vm.activeItems).toContain('Senegal')
|
|
74
|
-
KEY_MAP.keydown({ keyCode: KEY_DOWN_CODE })
|
|
75
|
-
expect(wrapper.vm.activeItems).toContain('Djibouti')
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it('updates active indexes when hitting arrow up', async () => {
|
|
79
|
-
const propsData = {items: ['Lesotho', 'Senegal', 'Djibouti'], modelValue: 'Djibouti'}
|
|
80
|
-
const wrapper = mount(SelectableDropdown, {propsData})
|
|
81
|
-
await flushPromises()
|
|
82
|
-
|
|
83
|
-
expect(wrapper.vm.activeItems).toContain('Djibouti')
|
|
84
|
-
KEY_MAP.keydown({keyCode: KEY_UP_CODE})
|
|
85
|
-
expect(wrapper.vm.activeItems).toContain('Senegal')
|
|
86
|
-
KEY_MAP.keydown({keyCode: KEY_UP_CODE})
|
|
87
|
-
expect(wrapper.vm.activeItems).toContain('Lesotho')
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
it('emits a `update:modelValue` event when a value is selected', async () => {
|
|
91
|
-
const propsData = { items: ['Lesotho', 'Senegal', 'Djibouti'], modelValue: 'Djibouti' }
|
|
92
|
-
const wrapper = mount(SelectableDropdown, { propsData })
|
|
93
|
-
await flushPromises()
|
|
94
|
-
|
|
95
|
-
expect(wrapper.emitted("update:modelValue")[0]).toContain('Djibouti')
|
|
96
|
-
|
|
97
|
-
await wrapper.find("#dropdown-item-lesotho").trigger("click")
|
|
98
|
-
expect(wrapper.emitted("update:modelValue")[1]).toContain('Lesotho')
|
|
99
|
-
|
|
100
|
-
await wrapper.find("#dropdown-item-senegal").trigger("click")
|
|
101
|
-
expect(wrapper.emitted("update:modelValue")[2]).toContain('Senegal')
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
it('emits a `click` event when user click on an item', async () => {
|
|
105
|
-
const propsData = { items: ['Lesotho', 'Senegal', 'Djibouti'] }
|
|
106
|
-
const wrapper = mount(SelectableDropdown, { propsData })
|
|
107
|
-
await flushPromises()
|
|
108
|
-
|
|
109
|
-
const findAll = wrapper.findAll('.dropdown-item');
|
|
110
|
-
await findAll.at(0).trigger('click') //TODO fix me
|
|
111
|
-
expect(wrapper.emitted("click")[0]).toContain('Lesotho')
|
|
112
|
-
await findAll.at(1).trigger('click') //TODO fix me
|
|
113
|
-
expect(wrapper.emitted("click")[1]).toContain('Senegal')
|
|
114
|
-
await findAll.at(0).trigger('click') //TODO fix me
|
|
115
|
-
expect(wrapper.emitted("click")[2]).toContain('Lesotho')
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
it('emits a `click` event when using `clickToSelectItem` method', () => {
|
|
119
|
-
const propsData = { items: ['Lesotho', 'Senegal', 'Djibouti'] }
|
|
120
|
-
const wrapper = mount(SelectableDropdown, { propsData })
|
|
121
|
-
|
|
122
|
-
wrapper.vm.clickToSelectItem('Lesotho')
|
|
123
|
-
expect(wrapper.emitted().click[0]).toContain('Lesotho')
|
|
124
|
-
wrapper.vm.clickToSelectItem('Senegal')
|
|
125
|
-
expect(wrapper.emitted().click[1]).toContain('Senegal')
|
|
126
|
-
wrapper.vm.clickToSelectItem('Lesotho')
|
|
127
|
-
expect(wrapper.emitted().click[2]).toContain('Lesotho')
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
describe('itemActivated', () => {
|
|
131
|
-
it('set item as activated for multiple and items is an array of string', () => {
|
|
132
|
-
const propsData = { items: ['Lesotho', 'Senegal', 'Djibouti'], modelValue: ['Lesotho'], multiple: true }
|
|
133
|
-
const wrapper = mount(SelectableDropdown, { propsData })
|
|
134
|
-
|
|
135
|
-
expect(wrapper.vm.itemActivated('Lesotho')).toBeTruthy()
|
|
136
|
-
expect(wrapper.vm.itemActivated('Senegal')).toBeFalsy()
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
it('set item as activated for multiple and items is an array of objects', () => {
|
|
140
|
-
const eq = (item, other) => item.label === other.label
|
|
141
|
-
const propsData = { items: [{ label: 'Lesotho' }, { label: 'Senegal' }, { label: 'Djibouti' }], modelValue: [{ label: 'Lesotho' }], multiple: true, eq }
|
|
142
|
-
const wrapper = mount(SelectableDropdown, { propsData })
|
|
143
|
-
|
|
144
|
-
expect(wrapper.vm.itemActivated({ label: 'Lesotho' })).toBeTruthy()
|
|
145
|
-
expect(wrapper.vm.itemActivated({ label: 'Senegal' })).toBeFalsy()
|
|
146
|
-
})
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
describe('Large number of selectable options', () => {
|
|
150
|
-
it('it displays only 7 items in the DOM on the 20 items given',async () => {
|
|
151
|
-
const twentyItems = Array.from(Array(20).keys())
|
|
152
|
-
const propsData = { items: twentyItems }
|
|
153
|
-
const wrapper = mount(SelectableDropdown, { propsData })
|
|
154
|
-
await flushPromises()
|
|
155
|
-
|
|
156
|
-
expect(wrapper.findAll('.dropdown-item')).toHaveLength(7)
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
})
|
|
160
|
-
})
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { mount, enableAutoUnmount,config } from '@vue/test-utils'
|
|
2
|
-
|
|
3
|
-
import SharingOptions from '@/components/SharingOptions'
|
|
4
|
-
import Murmur from "@/main";
|
|
5
|
-
|
|
6
|
-
describe('SharingOptions', () => {
|
|
7
|
-
|
|
8
|
-
const propsData = {
|
|
9
|
-
url: 'https://medicaldevices.icij.org/',
|
|
10
|
-
values: {
|
|
11
|
-
title: 'A title to share',
|
|
12
|
-
twitter_title: 'A tweet to share #vue',
|
|
13
|
-
facebook_description: 'A short description for facebook but not for the other network'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
enableAutoUnmount(afterEach)
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
// create teleport target
|
|
21
|
-
const el = document.createElement('div')
|
|
22
|
-
el.id = 'embedForm'
|
|
23
|
-
document.body.appendChild(el)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
afterEach(() => {
|
|
27
|
-
// clean up
|
|
28
|
-
document.body.outerHTML = ''
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('is a Vue instance', () => {
|
|
32
|
-
const wrapper = mount(SharingOptions, { propsData })
|
|
33
|
-
expect(wrapper.vm).toBeTruthy()
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('renders props.direction on the root element with the default value', () => {
|
|
37
|
-
const wrapper = mount(SharingOptions, { propsData })
|
|
38
|
-
expect(wrapper.element.style['flex-direction']).toBe('row')
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
it('renders props.direction on the root element with `row`', () => {
|
|
43
|
-
const direction = 'row'
|
|
44
|
-
const wrapper = mount(SharingOptions, {
|
|
45
|
-
propsData: { direction, ...propsData }
|
|
46
|
-
})
|
|
47
|
-
expect(wrapper.element.style['flex-direction']).toBe(direction)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('renders props.direction on the root element with `row-reverse`', () => {
|
|
51
|
-
const direction = 'row-reverse'
|
|
52
|
-
const wrapper = mount(SharingOptions, {
|
|
53
|
-
propsData: { direction, ...propsData }
|
|
54
|
-
})
|
|
55
|
-
expect(wrapper.element.style['flex-direction']).toBe(direction)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it('renders props.direction on the root element with `column`', () => {
|
|
59
|
-
const direction = 'column'
|
|
60
|
-
const wrapper = mount(SharingOptions, {
|
|
61
|
-
propsData: { direction, ...propsData }
|
|
62
|
-
})
|
|
63
|
-
expect(wrapper.element.style['flex-direction']).toBe(direction)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('renders props.direction on the root element with `column-reverse`', () => {
|
|
67
|
-
const direction = 'column-reverse'
|
|
68
|
-
const wrapper = mount(SharingOptions, {
|
|
69
|
-
propsData: { direction, ...propsData }
|
|
70
|
-
})
|
|
71
|
-
expect(wrapper.element.style['flex-direction']).toBe(direction)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('renders the embed button by default', () => {
|
|
75
|
-
const wrapper = mount(SharingOptions, { propsData })
|
|
76
|
-
expect(wrapper.find('.sharing-options__link--embed').element.style.display).not.toBe('none')
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
it('hides the embed button when props.noEmbed is passed', () => {
|
|
80
|
-
const noEmbed = true
|
|
81
|
-
const wrapper = mount(SharingOptions, {
|
|
82
|
-
propsData: { noEmbed, ...propsData }
|
|
83
|
-
})
|
|
84
|
-
expect(wrapper.find('.sharing-options__link--embed').element.style.display).toBe('none')
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
it('hides the embed button when props.noEmbed is passed', () => {
|
|
88
|
-
const noEmbed = true
|
|
89
|
-
const wrapper = mount(SharingOptions, {
|
|
90
|
-
propsData: { noEmbed, ...propsData }
|
|
91
|
-
})
|
|
92
|
-
expect(wrapper.find('.sharing-options__link--embed').element.style.display).toBe('none')
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('uses a generic title', () => {
|
|
96
|
-
const wrapper = mount(SharingOptions, { propsData })
|
|
97
|
-
expect(wrapper.vm.valuesFor('facebook').title).toBe('A title to share')
|
|
98
|
-
expect(wrapper.vm.valuesFor('other').title).toBe('A title to share')
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
it('uses a dedicated title for Twitter', () => {
|
|
102
|
-
const wrapper = mount(SharingOptions, { propsData })
|
|
103
|
-
expect(wrapper.vm.valuesFor('twitter').title).toBe('A tweet to share #vue')
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
it('uses a dedicated description for Facebook', () => {
|
|
107
|
-
const wrapper = mount(SharingOptions, { propsData })
|
|
108
|
-
expect(wrapper.vm.valuesFor('facebook').description).toBe('A short description for facebook but not for the other network')
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
it('toggles the embed form', async () => {
|
|
112
|
-
const wrapper = mount(SharingOptions, { propsData, global:{ stubs: { teleport: true , HapticCopy:true}} })
|
|
113
|
-
|
|
114
|
-
const $modal = wrapper.find('#embedForm')
|
|
115
|
-
expect($modal.isVisible()).toBe(false)
|
|
116
|
-
await wrapper.find(".sharing-options__link--embed a").trigger("click")
|
|
117
|
-
expect($modal.isVisible()).toBe(true)
|
|
118
|
-
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
it('uses the current location is none is given', () => {
|
|
122
|
-
const wrapper =mount(SharingOptions, { global })
|
|
123
|
-
expect(wrapper.vm.url).toBe('http://localhost:3000/')
|
|
124
|
-
})
|
|
125
|
-
})
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import {mount} from '@vue/test-utils'
|
|
2
|
-
|
|
3
|
-
import SharingOptionsLink, {$popup} from '@/components/SharingOptionsLink'
|
|
4
|
-
|
|
5
|
-
function mockPopupParent () {
|
|
6
|
-
return {
|
|
7
|
-
open: vi.fn().mockImplementation(() => {
|
|
8
|
-
return {
|
|
9
|
-
focus: vi.fn(),
|
|
10
|
-
close: vi.fn()
|
|
11
|
-
}
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
vi.useFakeTimers()
|
|
17
|
-
|
|
18
|
-
describe('SharingOptionsLink', () => {
|
|
19
|
-
|
|
20
|
-
const propsData = { network: 'twitter' }
|
|
21
|
-
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
vi.clearAllMocks()
|
|
24
|
-
vi.restoreAllMocks()
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it('should be a Vue instance', () => {
|
|
28
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
29
|
-
expect(wrapper.vm).toBeTruthy()
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('should generate the component with `a` tag', () => {
|
|
33
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
34
|
-
expect(wrapper.element.tagName).toBe('A')
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('should generate the component with `button` tag', () => {
|
|
38
|
-
const propsData = { network: 'twitter', tag: 'button' }
|
|
39
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
40
|
-
expect(wrapper.element.tagName).toBe('BUTTON')
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('should validate prop against platforms names', () => {
|
|
44
|
-
const validator = SharingOptionsLink.props.network.validator
|
|
45
|
-
expect(validator('foo')).toBe(false)
|
|
46
|
-
expect(validator('email')).toBe(true)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('should give a different `base` for Twitter', () => {
|
|
50
|
-
const propsData = { network: 'twitter' }
|
|
51
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
52
|
-
expect(wrapper.vm.base).toBe('https://twitter.com/intent/tweet?')
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('should give a different `base` for Facebook', () => {
|
|
56
|
-
const propsData = { network: 'facebook' }
|
|
57
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
58
|
-
expect(wrapper.vm.base).toBe('https://www.facebook.com/sharer.php?')
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it('should give a different `base` for Linkedin', () => {
|
|
62
|
-
const propsData = { network: 'linkedin' }
|
|
63
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
64
|
-
expect(wrapper.vm.base).toBe('https://www.linkedin.com/sharing/share-offsite/?')
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
it('should have a popup', () => {
|
|
68
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
69
|
-
expect(wrapper.vm.hasPopup()).toBeTruthy()
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
it('shouldn\'t have a popup when network is `email`', () => {
|
|
73
|
-
const propsData = { network: 'email' }
|
|
74
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
75
|
-
expect(wrapper.vm.hasPopup()).toBeFalsy()
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it('should create a query with the correct `url` param', () => {
|
|
79
|
-
const propsData = { network: 'twitter', url: 'https://icij.org' }
|
|
80
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
81
|
-
expect(wrapper.vm.query.url).toBe(propsData.url)
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
it('should create a query with the correct `u` param', () => {
|
|
85
|
-
const propsData = { network: 'facebook', url: 'https://icij.org' }
|
|
86
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
87
|
-
expect(wrapper.vm.query.u).toBe(propsData.url)
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
it('should create a query with the correct `text` param', () => {
|
|
91
|
-
const propsData = { network: 'twitter', title: 'Foo' }
|
|
92
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
93
|
-
expect(wrapper.vm.query.text).toBe(propsData.title)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it('should create a query with the correct `title` param', () => {
|
|
97
|
-
const propsData = { network: 'facebook', title: 'Foo' }
|
|
98
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
99
|
-
expect(wrapper.vm.query.title).toBe(propsData.title)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('should create a query with the correct `summary` param', () => {
|
|
103
|
-
const propsData = { network: 'linkedin', description: 'Foo' }
|
|
104
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
105
|
-
expect(wrapper.vm.query.summary).toBe(propsData.description)
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
it('should have correct `args` for Twitter', () => {
|
|
109
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
110
|
-
expect(wrapper.vm.args).toHaveProperty('url')
|
|
111
|
-
expect(wrapper.vm.args).toHaveProperty('text')
|
|
112
|
-
expect(wrapper.vm.args).toHaveProperty('via')
|
|
113
|
-
expect(wrapper.vm.args).toHaveProperty('hashtags')
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
it('should have correct `args` for Facebook', () => {
|
|
117
|
-
const propsData = { network: 'facebook' }
|
|
118
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
119
|
-
expect(wrapper.vm.args).toHaveProperty('u')
|
|
120
|
-
expect(wrapper.vm.args).toHaveProperty('title')
|
|
121
|
-
expect(wrapper.vm.args).toHaveProperty('description')
|
|
122
|
-
expect(wrapper.vm.args).toHaveProperty('hashtag')
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it('should create open a popup when clicking on the component', async () => {
|
|
126
|
-
const propsData = { network: 'twitter', title: 'Foo' }
|
|
127
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
128
|
-
// Create two spies that must be called when clicking
|
|
129
|
-
const spyOpenPopup = vi.spyOn(wrapper.vm, 'openPopup').mockImplementation(() => null)
|
|
130
|
-
const spyCleanExistingPopup = vi.spyOn(wrapper.vm, 'cleanExistingPopupInstance').mockImplementation(() => null)
|
|
131
|
-
await wrapper.trigger('click')
|
|
132
|
-
expect(spyOpenPopup).toBeCalled()
|
|
133
|
-
expect(spyCleanExistingPopup).toBeCalled()
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
it('should clear the interval and close existing popup when clicking on the component', () => {
|
|
137
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
138
|
-
$popup.instance = { close: vi.fn(), focus: vi.fn() }
|
|
139
|
-
$popup.interval = setInterval(() => null)
|
|
140
|
-
wrapper.vm.cleanExistingPopupInstance()
|
|
141
|
-
expect($popup.interval).toBe(undefined)
|
|
142
|
-
expect($popup.instance.close).toBeCalled()
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
it('should share popup between components', () => {
|
|
146
|
-
$popup.instance = { close: vi.fn(), focus: vi.fn() }
|
|
147
|
-
$popup.interval = setInterval(() => null)
|
|
148
|
-
const wrapperA = mount(SharingOptionsLink, { propsData })
|
|
149
|
-
const wrapperB = mount(SharingOptionsLink, { propsData })
|
|
150
|
-
wrapperA.vm.cleanExistingPopupInstance()
|
|
151
|
-
expect($popup.interval).toBe(undefined)
|
|
152
|
-
expect($popup.instance.close).toBeCalled()
|
|
153
|
-
wrapperB.vm.cleanExistingPopupInstance()
|
|
154
|
-
expect($popup.interval).toBe(undefined)
|
|
155
|
-
expect($popup.instance.close).toBeCalled()
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
it('should open a popup wgen clicking on the component', async () => {
|
|
159
|
-
// Return a fake popup instance
|
|
160
|
-
$popup.parent = mockPopupParent()
|
|
161
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
162
|
-
expect($popup.parent.open).not.toBeCalled()
|
|
163
|
-
await wrapper.trigger('click')
|
|
164
|
-
expect($popup.parent.open).toBeCalled()
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
it('should clear the popup instance once it been closed', async () => {
|
|
168
|
-
// Return a fake popup instance
|
|
169
|
-
$popup.parent = mockPopupParent()
|
|
170
|
-
const wrapper = mount(SharingOptionsLink, { propsData })
|
|
171
|
-
wrapper.vm.cleanExistingPopupInstance()
|
|
172
|
-
await wrapper.trigger('click')
|
|
173
|
-
expect($popup.instance).not.toBe(null)
|
|
174
|
-
expect($popup.interval).not.toBe(undefined)
|
|
175
|
-
// Close the popup
|
|
176
|
-
$popup.instance.closed = true
|
|
177
|
-
// Wait for the interval to be called
|
|
178
|
-
vi.advanceTimersByTime(1000)
|
|
179
|
-
// And check again!
|
|
180
|
-
expect($popup.instance).toBe(null)
|
|
181
|
-
expect($popup.interval).toBe(undefined)
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
})
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { mount } from '@vue/test-utils'
|
|
2
|
-
import SignUpForm from '@/components/SignUpForm'
|
|
3
|
-
import Murmur from '@/main'
|
|
4
|
-
const mockSend = vi.fn().mockResolvedValue({})
|
|
5
|
-
vi.mock('@/composables/sendEmail', () => ({
|
|
6
|
-
useSendEmail () {
|
|
7
|
-
return {
|
|
8
|
-
send: mockSend,
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
}))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
describe('SignUpForm', () => {
|
|
16
|
-
|
|
17
|
-
it('is a Vue instance', () => {
|
|
18
|
-
const wrapper = mount(SignUpForm)
|
|
19
|
-
expect(wrapper.vm).toBeTruthy()
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('renders the label by default', () => {
|
|
23
|
-
const wrapper = mount(SignUpForm)
|
|
24
|
-
expect(wrapper.find('label').exists()).toBeTruthy()
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it('disables the label when props.noLabel is passed', () => {
|
|
28
|
-
const noLabel = true
|
|
29
|
-
const wrapper = mount(SignUpForm, {
|
|
30
|
-
propsData: { noLabel }
|
|
31
|
-
})
|
|
32
|
-
expect(wrapper.find('label').exists()).toBeFalsy()
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('doesn\'t render the form horizontally by default', () => {
|
|
36
|
-
const wrapper = mount(SignUpForm)
|
|
37
|
-
expect(wrapper.classes('sign-up-form--horizontal')).toBeFalsy()
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('renders the form horizontally when props.horizontal is passed', () => {
|
|
41
|
-
const horizontal = true
|
|
42
|
-
const wrapper = mount(SignUpForm, {
|
|
43
|
-
propsData: { horizontal }
|
|
44
|
-
})
|
|
45
|
-
expect(wrapper.classes('sign-up-form--horizontal')).toBeTruthy()
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('uses a default tracker when none is given', () => {
|
|
49
|
-
const wrapper = mount(SignUpForm)
|
|
50
|
-
const tracker = Murmur.config.get('signup-form.tracker')
|
|
51
|
-
expect(wrapper.vm.tracker).toBe(tracker)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('uses a custom tracker when props.tracker is passed', () => {
|
|
55
|
-
const tracker = 'YOLO'
|
|
56
|
-
const wrapper = mount(SignUpForm, {
|
|
57
|
-
propsData: { tracker }
|
|
58
|
-
})
|
|
59
|
-
expect(wrapper.vm.tracker).toBe(tracker)
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it('sends the email when submitting the form', async () => {
|
|
63
|
-
|
|
64
|
-
const wrapper = mount(SignUpForm)
|
|
65
|
-
|
|
66
|
-
await wrapper.find('form').trigger('submit.prevent')
|
|
67
|
-
await wrapper.vm.$nextTick()
|
|
68
|
-
|
|
69
|
-
expect(wrapper.emitted('submit')[0][0]).toBeDefined()
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
it('sends the email when submitting the form and display the confirmation', async () => {
|
|
73
|
-
const msg = '☮️'
|
|
74
|
-
mockSend.mockResolvedValueOnce({result:"success",msg})
|
|
75
|
-
const wrapper = mount(SignUpForm)
|
|
76
|
-
|
|
77
|
-
await wrapper.vm.subscribe()
|
|
78
|
-
expect(wrapper.vm.successMessage).toBe(msg)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
it('sends the email and drops it when the result is a success', async () => {
|
|
82
|
-
const msg = '☮️'
|
|
83
|
-
|
|
84
|
-
mockSend.mockResolvedValueOnce({result:"success",msg})
|
|
85
|
-
|
|
86
|
-
const wrapper = mount(SignUpForm)
|
|
87
|
-
wrapper.vm.email = 'data@icij.org'
|
|
88
|
-
await wrapper.vm.subscribe()
|
|
89
|
-
expect(wrapper.vm.email).toBe('')
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
it('sends the email when submitting the form and display the error', async () => {
|
|
93
|
-
const msg = '❎'
|
|
94
|
-
mockSend.mockRejectedValueOnce({result:"error",msg})
|
|
95
|
-
|
|
96
|
-
const wrapper = mount(SignUpForm)
|
|
97
|
-
await wrapper.vm.subscribe()
|
|
98
|
-
expect(wrapper.vm.errorMessage).toBe(msg)
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
it('sends the email but doesn\'t drop it when the result is an error', async () => {
|
|
102
|
-
const msg = '❎'
|
|
103
|
-
mockSend.mockRejectedValueOnce({result:"error",msg})
|
|
104
|
-
const wrapper = mount(SignUpForm)
|
|
105
|
-
wrapper.vm.email = 'data@icij.org'
|
|
106
|
-
await wrapper.vm.subscribe()
|
|
107
|
-
expect(wrapper.vm.email).toBe('data@icij.org')
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
it('sends the email when submitting the form and display the error, with a rejected promise', async () => {
|
|
111
|
-
const msg = '❎'
|
|
112
|
-
mockSend.mockRejectedValueOnce({result:"error",msg})
|
|
113
|
-
const wrapper = mount(SignUpForm)
|
|
114
|
-
await wrapper.vm.subscribe()
|
|
115
|
-
expect(wrapper.vm.errorMessage).toBe(msg)
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
it('sends the email and transform the error message', async () => {
|
|
119
|
-
mockSend.mockRejectedValueOnce({ msg: '0 -❎' })
|
|
120
|
-
|
|
121
|
-
const wrapper = mount(SignUpForm)
|
|
122
|
-
await wrapper.vm.subscribe()
|
|
123
|
-
expect(wrapper.vm.errorMessage).toBe('❎')
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
it('sends the email and show a default error message', async () => {
|
|
127
|
-
mockSend.mockRejectedValueOnce({})
|
|
128
|
-
const wrapper = mount(SignUpForm)
|
|
129
|
-
await wrapper.vm.subscribe()
|
|
130
|
-
expect(wrapper.vm.errorMessage).toBe('Something\'s wrong')
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
it('changes the color variant of the button ', async () => {
|
|
134
|
-
const wrapper = mount(SignUpForm)
|
|
135
|
-
// variant is primary
|
|
136
|
-
let element = wrapper.find('.sign-up-form__fieldset__group__addon.btn-primary')
|
|
137
|
-
expect(element.exists()).toBeTruthy()
|
|
138
|
-
|
|
139
|
-
//variant is secondary
|
|
140
|
-
const propsData={ variant:'secondary'}
|
|
141
|
-
await wrapper.setProps(propsData)
|
|
142
|
-
element = wrapper.find('.sign-up-form__fieldset__group__addon.btn-secondary')
|
|
143
|
-
expect(element.exists()).toBeTruthy()
|
|
144
|
-
})
|
|
145
|
-
})
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { mount } from '@vue/test-utils'
|
|
2
|
-
import SlideUpDown from '@/components/SlideUpDown'
|
|
3
|
-
|
|
4
|
-
describe('SlideUpDown', () => {
|
|
5
|
-
|
|
6
|
-
it('is a Vue instance', () => {
|
|
7
|
-
const wrapper = mount(SlideUpDown)
|
|
8
|
-
expect(wrapper.vm).toBeTruthy()
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('renders the component as a `div` by default', () => {
|
|
12
|
-
const wrapper = mount(SlideUpDown)
|
|
13
|
-
expect(wrapper.element.nodeName).toBe('DIV')
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('renders the component as a `span` when props.tag is passed', () => {
|
|
17
|
-
const tag = 'SPAN'
|
|
18
|
-
const wrapper = mount(SlideUpDown, {
|
|
19
|
-
propsData: { tag }
|
|
20
|
-
})
|
|
21
|
-
expect(wrapper.element.nodeName).toBe(tag)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('is visible by default', () => {
|
|
25
|
-
const wrapper = mount(SlideUpDown)
|
|
26
|
-
expect(wrapper.element.style.height).toBe('auto')
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('isn\'t visible if props.active is passed as `false`', async () => {
|
|
30
|
-
const active = false
|
|
31
|
-
const wrapper = mount(SlideUpDown, {
|
|
32
|
-
propsData: { active }
|
|
33
|
-
})
|
|
34
|
-
wrapper.vm.mounted = true
|
|
35
|
-
await wrapper.vm.$nextTick()
|
|
36
|
-
expect(wrapper.element.style.height).toBe('0px')
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('calls `cleanLayout` after the transition', async () => {
|
|
40
|
-
const wrapper = mount(SlideUpDown)
|
|
41
|
-
wrapper.vm.cleanLayout = vi.fn()
|
|
42
|
-
expect(wrapper.vm.cleanLayout.mock.calls.length).toBe(0)
|
|
43
|
-
await wrapper.setProps({active:false})
|
|
44
|
-
await new Promise(done => {
|
|
45
|
-
setTimeout(() => {
|
|
46
|
-
expect(wrapper.vm.cleanLayout.mock.calls.length).toBe(1)
|
|
47
|
-
done()
|
|
48
|
-
}, wrapper.vm.duration)
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('calls `cleanLayout` which change the state from `pre` to `active`', async () => {
|
|
53
|
-
const wrapper = mount(SlideUpDown)
|
|
54
|
-
const defered = wrapper.vm.triggerSlide()
|
|
55
|
-
expect(wrapper.vm.state).toBe('pre')
|
|
56
|
-
await defered
|
|
57
|
-
expect(wrapper.vm.state).toBe('active')
|
|
58
|
-
})
|
|
59
|
-
})
|