@m3ui-vue/m3ui-vue 1.3.7 → 1.4.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/dist/API.md +1097 -26
- package/dist/{MButton-D5eJiDza.js → MButton-DQMTIlaV.js} +2 -2
- package/dist/{MButton-D5eJiDza.js.map → MButton-DQMTIlaV.js.map} +1 -1
- package/dist/{MDialog-WqB0jewp.js → MDialog-cdgapGfZ.js} +2 -2
- package/dist/{MDialog-WqB0jewp.js.map → MDialog-cdgapGfZ.js.map} +1 -1
- package/dist/{MListItem-Cf-C2Ru-.js → MListItem-ZkSGIIrb.js} +2 -2
- package/dist/{MListItem-Cf-C2Ru-.js.map → MListItem-ZkSGIIrb.js.map} +1 -1
- package/dist/{MLoadingIndicator-D4GzEZoH.js → MLoadingIndicator-U6_oGx8z.js} +2 -2
- package/dist/{MLoadingIndicator-D4GzEZoH.js.map → MLoadingIndicator-U6_oGx8z.js.map} +1 -1
- package/dist/{MSeekBar-B19xoWE3.js → MSeekBar-DTZVizZg.js} +2 -2
- package/dist/{MSeekBar-B19xoWE3.js.map → MSeekBar-DTZVizZg.js.map} +1 -1
- package/dist/{MSlider-9RoiuebS.js → MSlider-CqJkEYRZ.js} +2 -2
- package/dist/{MSlider-9RoiuebS.js.map → MSlider-CqJkEYRZ.js.map} +1 -1
- package/dist/{MSpinner-BNF8MN-L.js → MSpinner-Btgc-0nb.js} +2 -2
- package/dist/{MSpinner-BNF8MN-L.js.map → MSpinner-Btgc-0nb.js.map} +1 -1
- package/dist/{MTextField-CuG0T3qh.js → MTextField-B6M0gJEO.js} +2 -2
- package/dist/{MTextField-CuG0T3qh.js.map → MTextField-B6M0gJEO.js.map} +1 -1
- package/dist/{MTooltip-Bv7yxngk.js → MTooltip-Dspji4XG.js} +4 -4
- package/dist/{MTooltip-Bv7yxngk.js.map → MTooltip-Dspji4XG.js.map} +1 -1
- package/dist/api.json +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MAudioPlayer.vue.d.ts +2 -2
- package/dist/components/MAvailabilityCalendar.vue.d.ts +83 -0
- package/dist/components/MBadge.vue.d.ts +1 -1
- package/dist/components/MBeforeAfter.vue.d.ts +61 -0
- package/dist/components/MBodyMap.vue.d.ts +70 -0
- package/dist/components/MCandlestickChart.vue.d.ts +82 -0
- package/dist/components/MCertificate.vue.d.ts +76 -0
- package/dist/components/MCreditCardInput.vue.d.ts +75 -0
- package/dist/components/MFlow.vue.d.ts +13 -0
- package/dist/components/MMortgageCalculator.vue.d.ts +83 -0
- package/dist/components/MOdontogram.vue.d.ts +86 -0
- package/dist/components/MOrderBook.vue.d.ts +89 -0
- package/dist/components/MOrderTicket.vue.d.ts +91 -0
- package/dist/components/MPosKeypad.vue.d.ts +84 -0
- package/dist/components/MProductConfigurator.vue.d.ts +136 -0
- package/dist/components/MQuiz.vue.d.ts +102 -0
- package/dist/components/MReceipt.vue.d.ts +93 -0
- package/dist/components/MSeatMap.vue.d.ts +131 -0
- package/dist/components/MSeekBar.vue.d.ts +1 -1
- package/dist/components/MSlider.vue.d.ts +2 -2
- package/dist/components/MSplitter.vue.d.ts +1 -1
- package/dist/components/MTicket.vue.d.ts +83 -0
- package/dist/components/MTour.vue.d.ts +52 -2
- package/dist/components/MVideoPlayer.vue.d.ts +1 -1
- package/dist/components/MVitalsChart.vue.d.ts +73 -0
- package/dist/composables/_printElement.d.ts +9 -0
- package/dist/composables/cardBrand.d.ts +25 -0
- package/dist/composables/flowPaths.d.ts +11 -3
- package/dist/composables/mortgage.d.ts +37 -0
- package/dist/composables/useFlow.d.ts +4 -0
- package/dist/composables/useLocale.d.ts +131 -0
- package/dist/draw.js +2 -2
- package/dist/flow.d.ts +1 -1
- package/dist/flow.js +526 -434
- package/dist/flow.js.map +1 -1
- package/dist/{flowPaths-DzW-aiET.js → flowPaths-CcWOKY4Z.js} +5 -5
- package/dist/flowPaths-CcWOKY4Z.js.map +1 -0
- package/dist/gantt.js +2 -2
- package/dist/index.d.ts +35 -0
- package/dist/locales/index.js +924 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +8393 -3613
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +5 -5
- package/dist/media.js +4 -4
- package/dist/pdf.js +4 -4
- package/dist/rich-text-editor.js +4 -4
- package/dist/styles.css +1 -1
- package/dist/{useLocale-D2ucaY-l.js → useLocale-DLKJIRFi.js} +133 -2
- package/dist/useLocale-DLKJIRFi.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/MAvailabilityCalendar.test.ts +85 -0
- package/src/__tests__/MBeforeAfter.test.ts +79 -0
- package/src/__tests__/MBodyMap.test.ts +60 -0
- package/src/__tests__/MCandlestickChart.test.ts +66 -0
- package/src/__tests__/MCertificate.test.ts +32 -0
- package/src/__tests__/MCreditCardInput.test.ts +122 -0
- package/src/__tests__/MFlow.test.ts +69 -0
- package/src/__tests__/MMortgageCalculator.test.ts +49 -0
- package/src/__tests__/MOdontogram.test.ts +93 -0
- package/src/__tests__/MOrderBook.test.ts +66 -0
- package/src/__tests__/MOrderTicket.test.ts +68 -0
- package/src/__tests__/MPosKeypad.test.ts +116 -0
- package/src/__tests__/MProductConfigurator.test.ts +73 -0
- package/src/__tests__/MQuiz.test.ts +104 -0
- package/src/__tests__/MReceipt.test.ts +52 -0
- package/src/__tests__/MSeatMap.test.ts +76 -0
- package/src/__tests__/MTicket.test.ts +38 -0
- package/src/__tests__/MTour.test.ts +102 -0
- package/src/__tests__/MVitalsChart.test.ts +49 -0
- package/src/__tests__/mortgage.test.ts +25 -0
- package/src/__tests__/ssr.test.ts +11 -0
- package/src/components/MAvailabilityCalendar.vue +460 -0
- package/src/components/MBeforeAfter.vue +248 -0
- package/src/components/MBodyMap.vue +266 -0
- package/src/components/MCandlestickChart.vue +479 -0
- package/src/components/MCertificate.vue +351 -0
- package/src/components/MCreditCardInput.vue +351 -0
- package/src/components/MFlow.vue +117 -17
- package/src/components/MMortgageCalculator.vue +258 -0
- package/src/components/MOdontogram.vue +462 -0
- package/src/components/MOrderBook.vue +287 -0
- package/src/components/MOrderTicket.vue +217 -0
- package/src/components/MPosKeypad.vue +406 -0
- package/src/components/MProductConfigurator.vue +412 -0
- package/src/components/MQuiz.vue +531 -0
- package/src/components/MReceipt.vue +249 -0
- package/src/components/MSeatMap.vue +431 -0
- package/src/components/MTicket.vue +209 -0
- package/src/components/MTour.vue +145 -27
- package/src/components/MVitalsChart.vue +303 -0
- package/src/composables/_printElement.ts +36 -0
- package/src/composables/cardBrand.ts +104 -0
- package/src/composables/flowPaths.ts +16 -7
- package/src/composables/mortgage.ts +70 -0
- package/src/composables/useFlow.ts +4 -0
- package/src/composables/useLocale.ts +277 -0
- package/src/flow.ts +1 -1
- package/src/index.ts +35 -0
- package/src/locales/de.ts +131 -0
- package/src/locales/es.ts +131 -0
- package/src/locales/fr.ts +131 -0
- package/src/locales/ja.ts +131 -0
- package/src/locales/ko.ts +131 -0
- package/src/locales/pt.ts +131 -0
- package/src/locales/zh.ts +131 -0
- package/dist/flowPaths-DzW-aiET.js.map +0 -1
- package/dist/useLocale-D2ucaY-l.js.map +0 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import MAvailabilityCalendar from '../components/MAvailabilityCalendar.vue'
|
|
4
|
+
|
|
5
|
+
type Range = [string | null, string | null]
|
|
6
|
+
|
|
7
|
+
const base = {
|
|
8
|
+
min: '2026-12-01',
|
|
9
|
+
months: 1,
|
|
10
|
+
firstDayOfWeek: 1,
|
|
11
|
+
prices: (d: string) => (d.endsWith('-05') ? 200 : 100),
|
|
12
|
+
unavailable: ['2026-12-10', '2026-12-11'],
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function setup(extra: Record<string, unknown> = {}) {
|
|
16
|
+
const w = mount(MAvailabilityCalendar, {
|
|
17
|
+
props: {
|
|
18
|
+
...base,
|
|
19
|
+
modelValue: [null, null] as Range,
|
|
20
|
+
'onUpdate:modelValue': (v: Range) => w.setProps({ modelValue: v }),
|
|
21
|
+
...extra,
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
return w
|
|
25
|
+
}
|
|
26
|
+
const day = (w: ReturnType<typeof setup>, d: string) => w.find(`[data-date="2026-12-${d}"]`)
|
|
27
|
+
const state = (w: ReturnType<typeof setup>, d: string) => day(w, d).element.parentElement!.dataset.state
|
|
28
|
+
|
|
29
|
+
describe('MAvailabilityCalendar', () => {
|
|
30
|
+
it('lays out the month from the first day of the week', () => {
|
|
31
|
+
const w = setup()
|
|
32
|
+
// Dec 1 2026 is a Tuesday: one blank before it with Monday first
|
|
33
|
+
const cells = w.findAll('[role="gridcell"]')
|
|
34
|
+
expect(cells[0]!.find('button').exists()).toBe(false)
|
|
35
|
+
expect(cells[1]!.find('button').attributes('data-date')).toBe('2026-12-01')
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('picks a stay and sums the nights', async () => {
|
|
39
|
+
const w = setup()
|
|
40
|
+
await day(w, '04').trigger('click')
|
|
41
|
+
expect(w.props('modelValue')).toEqual(['2026-12-04', null])
|
|
42
|
+
await day(w, '07').trigger('click')
|
|
43
|
+
expect(w.props('modelValue')).toEqual(['2026-12-04', '2026-12-07'])
|
|
44
|
+
expect(w.emitted('change')![0]![0]).toEqual({ start: '2026-12-04', end: '2026-12-07', nights: 3, total: 400 })
|
|
45
|
+
expect(state(w, '05')).toBe('range')
|
|
46
|
+
expect(w.find('[data-summary]').text()).toContain('3 nights')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('lets a stay end on the morning a booked night starts, not run over it', async () => {
|
|
50
|
+
const w = setup()
|
|
51
|
+
await day(w, '08').trigger('click')
|
|
52
|
+
expect(state(w, '10')).toBe('checkout-only')
|
|
53
|
+
expect(state(w, '11')).toBe('booked')
|
|
54
|
+
expect(state(w, '13')).toBe('disabled')
|
|
55
|
+
await day(w, '13').trigger('click')
|
|
56
|
+
expect(w.props('modelValue')).toEqual(['2026-12-08', null])
|
|
57
|
+
await day(w, '10').trigger('click')
|
|
58
|
+
expect(w.props('modelValue')).toEqual(['2026-12-08', '2026-12-10'])
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('blocks booked nights and check-ins that cannot fit the minimum stay', async () => {
|
|
62
|
+
const w = setup({ minNights: 3 })
|
|
63
|
+
expect(state(w, '10')).toBe('booked')
|
|
64
|
+
expect(state(w, '08')).toBe('disabled')
|
|
65
|
+
expect(state(w, '07')).toBe('available')
|
|
66
|
+
await day(w, '07').trigger('click')
|
|
67
|
+
expect(state(w, '08')).toBe('disabled')
|
|
68
|
+
expect(state(w, '10')).toBe('checkout-only')
|
|
69
|
+
expect(w.text()).toContain('Minimum stay: 3 nights')
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('picking an earlier day restarts the stay', async () => {
|
|
73
|
+
const w = setup()
|
|
74
|
+
await day(w, '06').trigger('click')
|
|
75
|
+
await day(w, '03').trigger('click')
|
|
76
|
+
expect(w.props('modelValue')).toEqual(['2026-12-03', null])
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('moves focus with the arrow keys across months', async () => {
|
|
80
|
+
const w = setup({ modelValue: ['2026-12-31', null] as Range })
|
|
81
|
+
await day(w, '31').trigger('keydown', { key: 'ArrowRight' })
|
|
82
|
+
expect(w.find('[data-date="2027-01-01"]').exists()).toBe(true)
|
|
83
|
+
expect(w.find('h3').text()).toMatch(/january 2027/i)
|
|
84
|
+
})
|
|
85
|
+
})
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import MBeforeAfter from '../components/MBeforeAfter.vue'
|
|
4
|
+
|
|
5
|
+
function mockRect(el: Element, width = 200, height = 100) {
|
|
6
|
+
el.getBoundingClientRect = () =>
|
|
7
|
+
({ left: 0, top: 0, right: width, bottom: height, width, height, x: 0, y: 0 }) as DOMRect
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function pointer(type: string, init: Partial<PointerEventInit>) {
|
|
11
|
+
return new PointerEvent(type, { bubbles: true, pointerId: 1, button: 0, pointerType: 'mouse', ...init })
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe('MBeforeAfter', () => {
|
|
15
|
+
it('clips the before layer at the position', () => {
|
|
16
|
+
const w = mount(MBeforeAfter, { props: { modelValue: 30, before: 'a.jpg', after: 'b.jpg' } })
|
|
17
|
+
const clipped = w.findAll('div').find((d) => d.attributes('style')?.includes('clip-path'))
|
|
18
|
+
expect(clipped?.attributes('style')).toContain('inset(0 70% 0 0)')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('moves the split to the pointer and follows the drag', async () => {
|
|
22
|
+
const w = mount(MBeforeAfter, { props: { before: 'a.jpg', after: 'b.jpg' } })
|
|
23
|
+
mockRect(w.element)
|
|
24
|
+
w.element.dispatchEvent(pointer('pointerdown', { clientX: 50 }))
|
|
25
|
+
w.element.dispatchEvent(pointer('pointermove', { clientX: 150 }))
|
|
26
|
+
w.element.dispatchEvent(pointer('pointerup', { clientX: 150 }))
|
|
27
|
+
expect(w.emitted('update:modelValue')).toEqual([[25], [75]])
|
|
28
|
+
expect(w.emitted('change')).toEqual([[75]])
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('uses the vertical axis', async () => {
|
|
32
|
+
const w = mount(MBeforeAfter, { props: { orientation: 'vertical' } })
|
|
33
|
+
mockRect(w.element)
|
|
34
|
+
w.element.dispatchEvent(pointer('pointerdown', { clientY: 20 }))
|
|
35
|
+
expect(w.emitted('update:modelValue')?.[0]).toEqual([20])
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('follows a hovering mouse only with hover', async () => {
|
|
39
|
+
const w = mount(MBeforeAfter)
|
|
40
|
+
mockRect(w.element)
|
|
41
|
+
w.element.dispatchEvent(pointer('pointermove', { clientX: 40 }))
|
|
42
|
+
expect(w.emitted('update:modelValue')).toBeUndefined()
|
|
43
|
+
await w.setProps({ hover: true })
|
|
44
|
+
w.element.dispatchEvent(pointer('pointermove', { clientX: 40 }))
|
|
45
|
+
expect(w.emitted('update:modelValue')?.[0]).toEqual([20])
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('steps with the keyboard and clamps', async () => {
|
|
49
|
+
const w = mount(MBeforeAfter, { props: { modelValue: 50 } })
|
|
50
|
+
const slider = w.find('[role="slider"]')
|
|
51
|
+
await slider.trigger('keydown', { key: 'ArrowRight' })
|
|
52
|
+
await w.setProps({ modelValue: 51 })
|
|
53
|
+
await slider.trigger('keydown', { key: 'PageDown' })
|
|
54
|
+
await w.setProps({ modelValue: 41 })
|
|
55
|
+
await slider.trigger('keydown', { key: 'End' })
|
|
56
|
+
expect(w.emitted('update:modelValue')).toEqual([[51], [41], [100]])
|
|
57
|
+
expect(slider.attributes('aria-valuenow')).toBe('100')
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('ignores input when disabled', async () => {
|
|
61
|
+
const w = mount(MBeforeAfter, { props: { disabled: true } })
|
|
62
|
+
mockRect(w.element)
|
|
63
|
+
w.element.dispatchEvent(pointer('pointerdown', { clientX: 10 }))
|
|
64
|
+
await w.find('[role="slider"]').trigger('keydown', { key: 'Home' })
|
|
65
|
+
expect(w.emitted('update:modelValue')).toBeUndefined()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('hides a label given as an empty string', () => {
|
|
69
|
+
const w = mount(MBeforeAfter, { props: { beforeLabel: '', afterLabel: 'Now' } })
|
|
70
|
+
expect(w.text()).not.toContain('Before')
|
|
71
|
+
expect(w.text()).toContain('Now')
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('has no position utility on its root', () => {
|
|
75
|
+
const w = mount(MBeforeAfter)
|
|
76
|
+
expect(w.classes()).not.toContain('relative')
|
|
77
|
+
expect(w.classes()).toContain('m3-before-after')
|
|
78
|
+
})
|
|
79
|
+
})
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import MBodyMap from '../components/MBodyMap.vue'
|
|
4
|
+
import type { BodyMapValue } from '../components/MBodyMap.vue'
|
|
5
|
+
|
|
6
|
+
function setup(extra: Record<string, unknown> = {}) {
|
|
7
|
+
const w = mount(MBodyMap, {
|
|
8
|
+
props: { modelValue: {} as BodyMapValue, 'onUpdate:modelValue': (v: BodyMapValue) => w.setProps({ modelValue: v }), ...extra },
|
|
9
|
+
})
|
|
10
|
+
return w
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
describe('MBodyMap', () => {
|
|
14
|
+
it('draws front and back with the patient’s sides', () => {
|
|
15
|
+
const w = setup()
|
|
16
|
+
expect(w.findAll('[data-view="front"] [data-region]')).toHaveLength(22)
|
|
17
|
+
expect(w.findAll('[data-view="back"] [data-region]')).toHaveLength(23)
|
|
18
|
+
// On the front view, the patient's right shoulder is on the viewer's left
|
|
19
|
+
const right = w.find('[data-region="shoulder-right"]')
|
|
20
|
+
expect(Number(right.attributes('cx'))).toBeLessThan(100)
|
|
21
|
+
expect(right.attributes('aria-label')).toBe('Shoulder, right')
|
|
22
|
+
// On the back view it is on the viewer's right
|
|
23
|
+
expect(Number(w.find('[data-region="back-shoulder-right"]').attributes('cx'))).toBeGreaterThan(100)
|
|
24
|
+
expect(w.find('[data-region="back-shoulder-right"]').attributes('aria-label')).toBe('Shoulder, right (back)')
|
|
25
|
+
expect(w.find('[data-region="back-lower-back"]').attributes('aria-label')).toBe('Lower back')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('toggles a region with one level', async () => {
|
|
29
|
+
const w = setup()
|
|
30
|
+
await w.find('[data-region="knee-left"]').trigger('click')
|
|
31
|
+
expect(w.props('modelValue')).toEqual({ 'knee-left': 1 })
|
|
32
|
+
expect(w.emitted('select')![0]![0]).toMatchObject({ id: 'knee-left', level: 1, view: 'front' })
|
|
33
|
+
await w.find('[data-region="knee-left"]').trigger('click')
|
|
34
|
+
expect(w.props('modelValue')).toEqual({})
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('cycles through levels and sets one with the number keys', async () => {
|
|
38
|
+
const w = setup({ levels: 3, levelLabels: ['Mild', 'Moderate', 'Severe'] })
|
|
39
|
+
const head = () => w.find('[data-region="head"]')
|
|
40
|
+
await head().trigger('click')
|
|
41
|
+
await head().trigger('click')
|
|
42
|
+
expect(w.props('modelValue')).toEqual({ head: 2 })
|
|
43
|
+
expect(head().attributes('aria-label')).toBe('Head: Moderate')
|
|
44
|
+
await head().trigger('keydown', { key: '3' })
|
|
45
|
+
expect(w.props('modelValue')).toEqual({ head: 3 })
|
|
46
|
+
await head().trigger('click')
|
|
47
|
+
expect(w.props('modelValue')).toEqual({})
|
|
48
|
+
expect(w.find('[data-legend]').text()).toContain('Severe')
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('respects readonly, disabled regions and a single view', async () => {
|
|
52
|
+
const w = setup({ view: 'back', disabledRegions: ['back-head'] })
|
|
53
|
+
expect(w.find('[data-view="front"]').exists()).toBe(false)
|
|
54
|
+
await w.find('[data-region="back-head"]').trigger('click')
|
|
55
|
+
expect(w.emitted('update:modelValue')).toBeUndefined()
|
|
56
|
+
await w.setProps({ readonly: true })
|
|
57
|
+
await w.find('[data-region="back-neck"]').trigger('click')
|
|
58
|
+
expect(w.emitted('update:modelValue')).toBeUndefined()
|
|
59
|
+
})
|
|
60
|
+
})
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import MCandlestickChart from '../components/MCandlestickChart.vue'
|
|
4
|
+
|
|
5
|
+
function series(n: number) {
|
|
6
|
+
return Array.from({ length: n }, (_, i) => {
|
|
7
|
+
const open = 100 + i
|
|
8
|
+
const close = i % 2 ? open - 2 : open + 3
|
|
9
|
+
return { time: Date.UTC(2026, 0, 1 + i), open, high: Math.max(open, close) + 1, low: Math.min(open, close) - 1, close, volume: 1000 + i }
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function rect(w: ReturnType<typeof mount>) {
|
|
14
|
+
;(w.element as HTMLElement).getBoundingClientRect = () => ({ left: 0, top: 0, right: 664, bottom: 320, width: 664, height: 320, x: 0, y: 0, toJSON() {} })
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe('MCandlestickChart', () => {
|
|
18
|
+
it('draws rising and falling candles in separate paths', () => {
|
|
19
|
+
const w = mount(MCandlestickChart, { props: { data: series(10) } })
|
|
20
|
+
expect(w.find('[data-candles="up"]').attributes('d')).toMatch(/^M/)
|
|
21
|
+
expect(w.find('[data-candles="down"]').attributes('d')).toMatch(/^M/)
|
|
22
|
+
// 5 up candles: a wick and a body each
|
|
23
|
+
expect((w.find('[data-candles="up"]').attributes('d')!.match(/V/g) ?? []).length).toBe(5)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('shows the last candle in the legend and the last price', () => {
|
|
27
|
+
const w = mount(MCandlestickChart, { props: { data: series(3) } })
|
|
28
|
+
// last candle: open 102, close 105
|
|
29
|
+
expect(w.find('[data-legend]').text()).toContain('Close 105.00')
|
|
30
|
+
expect(w.find('[data-last-price]').text()).toBe('105.00')
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('draws moving averages once there are enough candles', () => {
|
|
34
|
+
const w = mount(MCandlestickChart, { props: { data: series(30), movingAverages: [5, 50] } })
|
|
35
|
+
expect(w.find('[data-ma="5"]').attributes('d')).toMatch(/^M/)
|
|
36
|
+
expect(w.find('[data-ma="50"]').attributes('d')).toBe('')
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('moves the crosshair with the keyboard and emits hover', async () => {
|
|
40
|
+
const data = series(10)
|
|
41
|
+
const w = mount(MCandlestickChart, { props: { data } })
|
|
42
|
+
await w.trigger('keydown', { key: 'ArrowLeft' })
|
|
43
|
+
expect(w.emitted('hover')![0]![0]).toEqual(data[8])
|
|
44
|
+
expect(w.find('[data-legend]').text()).toContain('Close 111.00')
|
|
45
|
+
await w.trigger('keydown', { key: 'Escape' })
|
|
46
|
+
expect(w.emitted('hover')!.at(-1)![0]).toBeNull()
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('pans with a drag', async () => {
|
|
50
|
+
const w = mount(MCandlestickChart, { props: { data: series(200), visible: 20 }, attachTo: document.body })
|
|
51
|
+
rect(w)
|
|
52
|
+
const before = w.find('[data-candles="up"]').attributes('d')
|
|
53
|
+
await w.trigger('pointerdown', { pointerId: 1, clientX: 300, clientY: 100, button: 0, pointerType: 'mouse' })
|
|
54
|
+
await w.trigger('pointermove', { pointerId: 1, clientX: 500, clientY: 100, pointerType: 'mouse' })
|
|
55
|
+
await w.trigger('pointerup', { pointerId: 1, pointerType: 'mouse' })
|
|
56
|
+
expect(w.find('[data-candles="up"]').attributes('d')).not.toBe(before)
|
|
57
|
+
w.unmount()
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('follows new candles while the latest is in view', async () => {
|
|
61
|
+
const w = mount(MCandlestickChart, { props: { data: series(10) } })
|
|
62
|
+
await w.setProps({ data: series(11) })
|
|
63
|
+
expect(w.find('[data-last-price]').text()).toBe('113.00')
|
|
64
|
+
expect(w.find('[data-legend]').text()).toContain('Close 113.00')
|
|
65
|
+
})
|
|
66
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import MCertificate from '../components/MCertificate.vue'
|
|
4
|
+
|
|
5
|
+
describe('MCertificate', () => {
|
|
6
|
+
it('renders the recipient with locale defaults', () => {
|
|
7
|
+
const w = mount(MCertificate, { props: { recipient: 'Ana Gómez', description: 'has completed Vue 3 Fundamentals', date: new Date(2026, 10, 17), code: 'M3-2026-0042' } })
|
|
8
|
+
expect(w.find('[data-title]').text()).toBe('Certificate of completion')
|
|
9
|
+
expect(w.text()).toContain('This certifies that')
|
|
10
|
+
expect(w.find('[data-recipient]').text()).toBe('Ana Gómez')
|
|
11
|
+
expect(w.text()).toContain('November 17, 2026')
|
|
12
|
+
expect(w.find('[data-code]').text()).toBe('Certificate ID: M3-2026-0042')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('draws signatures, with an image when given', () => {
|
|
16
|
+
const w = mount(MCertificate, {
|
|
17
|
+
props: { recipient: 'A', signatures: [{ name: 'Leo Paz', role: 'Director', image: 'data:image/png;base64,x' }, { name: 'Mía Ruiz' }] },
|
|
18
|
+
})
|
|
19
|
+
const sigs = w.findAll('[data-signature]')
|
|
20
|
+
expect(sigs).toHaveLength(2)
|
|
21
|
+
expect(sigs[0]!.find('img').attributes('src')).toBe('data:image/png;base64,x')
|
|
22
|
+
expect(sigs[0]!.text()).toContain('Director')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('switches variant, orientation, color and seal', async () => {
|
|
26
|
+
const w = mount(MCertificate, { props: { recipient: 'A', variant: 'modern', orientation: 'portrait', color: 'tertiary', seal: false } })
|
|
27
|
+
expect(w.attributes('data-variant')).toBe('modern')
|
|
28
|
+
expect(w.attributes('style')).toContain('210 / 297')
|
|
29
|
+
expect(w.attributes('style')).toContain('var(--color-tertiary)')
|
|
30
|
+
expect(w.find('.m3-certificate__seal').exists()).toBe(false)
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import MCreditCardInput from '../components/MCreditCardInput.vue'
|
|
4
|
+
import { detectCardBrand, formatCardNumber, isValidCardNumber, isValidExpiry, luhnCheck } from '../composables/cardBrand'
|
|
5
|
+
|
|
6
|
+
const empty = { number: '', expiry: '', cvc: '' }
|
|
7
|
+
|
|
8
|
+
describe('card helpers', () => {
|
|
9
|
+
it('detects networks', () => {
|
|
10
|
+
expect(detectCardBrand('4242').brand).toBe('visa')
|
|
11
|
+
expect(detectCardBrand('5555 5555').brand).toBe('mastercard')
|
|
12
|
+
expect(detectCardBrand('2223').brand).toBe('mastercard')
|
|
13
|
+
expect(detectCardBrand('3782').brand).toBe('amex')
|
|
14
|
+
expect(detectCardBrand('6011').brand).toBe('discover')
|
|
15
|
+
expect(detectCardBrand('3530').brand).toBe('jcb')
|
|
16
|
+
expect(detectCardBrand('589562').brand).toBe('naranja')
|
|
17
|
+
expect(detectCardBrand('9999').brand).toBe('unknown')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('checks Luhn and lengths', () => {
|
|
21
|
+
expect(luhnCheck('4242424242424242')).toBe(true)
|
|
22
|
+
expect(luhnCheck('4242424242424241')).toBe(false)
|
|
23
|
+
expect(isValidCardNumber('4242 4242 4242 4242')).toBe(true)
|
|
24
|
+
expect(isValidCardNumber('424242424242')).toBe(false)
|
|
25
|
+
expect(isValidCardNumber('378282246310005')).toBe(true)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('groups numbers the way the network prints them', () => {
|
|
29
|
+
expect(formatCardNumber('4242424242424242')).toBe('4242 4242 4242 4242')
|
|
30
|
+
expect(formatCardNumber('378282246310005')).toBe('3782 822463 10005')
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('accepts only future expiries', () => {
|
|
34
|
+
const now = new Date(2026, 10, 17)
|
|
35
|
+
expect(isValidExpiry('11/26', now)).toBe(true)
|
|
36
|
+
expect(isValidExpiry('10/26', now)).toBe(false)
|
|
37
|
+
expect(isValidExpiry('13/27', now)).toBe(false)
|
|
38
|
+
expect(isValidExpiry('1/27', now)).toBe(false)
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
describe('MCreditCardInput', () => {
|
|
43
|
+
function inputs(w: ReturnType<typeof mount>) {
|
|
44
|
+
return w.findAll('input')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
it('keeps digits only in the value and shows them grouped', async () => {
|
|
48
|
+
const w = mount(MCreditCardInput, { props: { modelValue: empty } })
|
|
49
|
+
await inputs(w)[0]!.setValue('4242-4242 4242a4242')
|
|
50
|
+
const v = w.emitted('update:modelValue')!.at(-1)![0] as typeof empty
|
|
51
|
+
expect(v.number).toBe('4242424242424242')
|
|
52
|
+
await w.setProps({ modelValue: v })
|
|
53
|
+
expect((inputs(w)[0]!.element as HTMLInputElement).value).toBe('4242 4242 4242 4242')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('caps the number at the network length', async () => {
|
|
57
|
+
const w = mount(MCreditCardInput, { props: { modelValue: empty } })
|
|
58
|
+
await inputs(w)[0]!.setValue('37828224631000599')
|
|
59
|
+
expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).number).toBe('378282246310005')
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('stops a Visa or an unknown network at 16 digits', async () => {
|
|
63
|
+
const w = mount(MCreditCardInput, { props: { modelValue: empty } })
|
|
64
|
+
await inputs(w)[0]!.setValue('4242424242424242123')
|
|
65
|
+
expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).number).toBe('4242424242424242')
|
|
66
|
+
await inputs(w)[0]!.setValue('9999999999999999123')
|
|
67
|
+
expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).number).toBe('9999999999999999')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('formats the expiry and pads a single-digit month', async () => {
|
|
71
|
+
const w = mount(MCreditCardInput, { props: { modelValue: empty } })
|
|
72
|
+
await inputs(w)[1]!.setValue('4')
|
|
73
|
+
expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).expiry).toBe('04')
|
|
74
|
+
await inputs(w)[1]!.setValue('1229')
|
|
75
|
+
expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).expiry).toBe('12/29')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('limits the security code to the network length', async () => {
|
|
79
|
+
const w = mount(MCreditCardInput, { props: { modelValue: { ...empty, number: '4242' } } })
|
|
80
|
+
await inputs(w)[2]!.setValue('12345')
|
|
81
|
+
expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).cvc).toBe('123')
|
|
82
|
+
await w.setProps({ modelValue: { ...empty, number: '3782' } })
|
|
83
|
+
await inputs(w)[2]!.setValue('12345')
|
|
84
|
+
expect((w.emitted('update:modelValue')!.at(-1)![0] as typeof empty).cvc).toBe('1234')
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('shows an error only after a field is left', async () => {
|
|
88
|
+
const w = mount(MCreditCardInput, { props: { modelValue: { ...empty, number: '4242424242424241' } } })
|
|
89
|
+
expect(w.text()).not.toContain('Invalid card number')
|
|
90
|
+
await inputs(w)[0]!.trigger('focusout')
|
|
91
|
+
expect(w.text()).toContain('Invalid card number')
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('validate() marks every field and reports validity', async () => {
|
|
95
|
+
const w = mount(MCreditCardInput, { props: { modelValue: empty } })
|
|
96
|
+
expect((w.vm as any).validate()).toBe(false)
|
|
97
|
+
await w.vm.$nextTick()
|
|
98
|
+
expect(w.text()).toContain('Invalid or expired date')
|
|
99
|
+
await w.setProps({ modelValue: { number: '4242424242424242', expiry: '12/40', cvc: '123' } })
|
|
100
|
+
expect((w.vm as any).validate()).toBe(true)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('emits complete once every field is valid', async () => {
|
|
104
|
+
const w = mount(MCreditCardInput, { props: { modelValue: empty } })
|
|
105
|
+
await w.setProps({ modelValue: { number: '4242424242424242', expiry: '12/40', cvc: '123' } })
|
|
106
|
+
expect(w.emitted('complete')).toHaveLength(1)
|
|
107
|
+
expect(w.emitted('brand')?.[0]).toEqual(['visa'])
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('shows external errors', () => {
|
|
111
|
+
const w = mount(MCreditCardInput, { props: { modelValue: empty, errors: { number: 'Card declined' } } })
|
|
112
|
+
expect(w.text()).toContain('Card declined')
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('flips the preview while the security code is focused', async () => {
|
|
116
|
+
const w = mount(MCreditCardInput, { props: { modelValue: empty } })
|
|
117
|
+
await inputs(w)[2]!.trigger('focusin')
|
|
118
|
+
expect(w.find('.m3-cc-preview__inner').classes()).toContain('is-flipped')
|
|
119
|
+
await inputs(w)[2]!.trigger('focusout')
|
|
120
|
+
expect(w.find('.m3-cc-preview__inner').classes()).not.toContain('is-flipped')
|
|
121
|
+
})
|
|
122
|
+
})
|
|
@@ -214,6 +214,57 @@ describe('MFlow', () => {
|
|
|
214
214
|
expect(w.emitted('update:selection')!.at(-1)![0]).toEqual({ nodes: [c!.id, d!.id], edges: [edges.at(-1)!.id] })
|
|
215
215
|
})
|
|
216
216
|
|
|
217
|
+
it('pastes at the pointer on the grid with snapToGrid', async () => {
|
|
218
|
+
const w = await flow({ selection: { nodes: ['a'], edges: [] }, snapToGrid: true, gridSize: 20 })
|
|
219
|
+
await w.trigger('keydown', { key: 'c', ctrlKey: true })
|
|
220
|
+
// The pointer over the canvas at a spot off the grid: the copy lands a whole number of steps away
|
|
221
|
+
pointer(w.element, 'pointerenter', 0, 0)
|
|
222
|
+
pointer(w.element, 'pointermove', 133, 77)
|
|
223
|
+
w.vm.paste({ x: 133, y: 77 })
|
|
224
|
+
const nodes = w.emitted('update:nodes')!.at(-1)![0] as FlowNode[]
|
|
225
|
+
expect(nodes.at(-1)!.position).toEqual({ x: 140, y: 80 })
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
it('edgeSpacing moves overlapping parallel step runs from different sources apart, not ones from the same source', async () => {
|
|
229
|
+
const run = (w: ReturnType<typeof mount>, id: string) => {
|
|
230
|
+
const d = w.find(`[data-flow-edge="${id}"] .m3-flow-edge-line`).attributes('d')
|
|
231
|
+
// The vertical run: the x where the path turns down or up (the first corner's x)
|
|
232
|
+
return Number(d.match(/^M[\d.-]+,[\d.-]+ L([\d.-]+),/)![1])
|
|
233
|
+
}
|
|
234
|
+
const nodes = [N('a', 0, 0), N('c', 0, 100), N('b', 300, 200), N('d', 300, -100), N('e', 300, 300)]
|
|
235
|
+
const step = { type: 'smoothstep' as const, markerEnd: 'none' as const }
|
|
236
|
+
// a → b runs down x = 240 from 30 to 230, c → d up from 130 to -70: they overlap from 30 to 130
|
|
237
|
+
const edges: FlowEdge[] = [{ id: 'ab', source: 'a', target: 'b', ...step }, { id: 'cd', source: 'c', target: 'd', ...step }]
|
|
238
|
+
const off = await flow({ nodes, edges })
|
|
239
|
+
expect(run(off, 'ab') + 8).toBe(run(off, 'cd') + 8)
|
|
240
|
+
off.unmount()
|
|
241
|
+
const on = await flow({ nodes, edges, edgeSpacing: 10 })
|
|
242
|
+
const xs = [run(on, 'ab'), run(on, 'cd')].map((x) => x + 8).sort()
|
|
243
|
+
expect(xs[1]! - xs[0]!).toBe(10)
|
|
244
|
+
// getEdgePath gives what's drawn
|
|
245
|
+
expect((on.vm as unknown as { getEdgePath(id: string): string }).getEdgePath('cd')).toBe(on.find('[data-flow-edge="cd"] .m3-flow-edge-line').attributes('d'))
|
|
246
|
+
on.unmount()
|
|
247
|
+
// From the same source they may share it
|
|
248
|
+
const same = await flow({ nodes, edges: [{ id: 'ab', source: 'a', target: 'b', ...step }, { id: 'ae', source: 'a', target: 'e', ...step }], edgeSpacing: 10 })
|
|
249
|
+
expect(run(same, 'ab')).toBe(run(same, 'ae'))
|
|
250
|
+
same.unmount()
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
it('Ctrl+D duplicates the selection without touching the clipboard', async () => {
|
|
254
|
+
const w = await flow({ selection: { nodes: ['a'], edges: [] } })
|
|
255
|
+
await w.trigger('keydown', { key: 'c', ctrlKey: true })
|
|
256
|
+
await w.setProps({ selection: { nodes: ['a', 'b'], edges: [] } })
|
|
257
|
+
await w.trigger('keydown', { key: 'd', ctrlKey: true })
|
|
258
|
+
const nodes = w.emitted('update:nodes')!.at(-1)![0] as FlowNode[]
|
|
259
|
+
const edges = w.emitted('update:edges')!.at(-1)![0] as FlowEdge[]
|
|
260
|
+
expect(nodes).toHaveLength(4)
|
|
261
|
+
expect(nodes[2]!.position).toEqual({ x: 40, y: 40 })
|
|
262
|
+
expect(edges.at(-1)).toMatchObject({ source: nodes[2]!.id, target: nodes[3]!.id })
|
|
263
|
+
// The clipboard still holds only a
|
|
264
|
+
await w.trigger('keydown', { key: 'v', ctrlKey: true })
|
|
265
|
+
expect((w.emitted('update:nodes')!.at(-1)![0] as FlowNode[])).toHaveLength(5)
|
|
266
|
+
})
|
|
267
|
+
|
|
217
268
|
it('a selected edge\'s end can be dragged to another node', async () => {
|
|
218
269
|
const w = await flow({ nodes: [N('a', 0, 0), N('b', 300, 0), N('c', 300, 200)], selection: { nodes: [], edges: ['e1'] } })
|
|
219
270
|
const end = w.find('[data-flow-reconnect="target"]').element
|
|
@@ -440,6 +491,24 @@ describe('MFlow', () => {
|
|
|
440
491
|
expect(w.emitted('update:selection')!.at(-1)![0]).toEqual({ nodes: ['b'], edges: [] })
|
|
441
492
|
expect(w.emitted('update:edges')).toBeUndefined()
|
|
442
493
|
})
|
|
494
|
+
it('content in a node that focuses itself on pointerdown keeps its focus; the canvas still takes it elsewhere', async () => {
|
|
495
|
+
const w = mount(MFlow, {
|
|
496
|
+
props: { nodes: [N('a', 0, 0, { type: 'pad' })], edges: [], animate: false },
|
|
497
|
+
slots: { 'node-pad': `<template #node-pad><div class="pad" data-flow-nodrag tabindex="0"><button class="key" @pointerdown="$event.currentTarget.closest('.pad').focus()">Up</button></div></template>` },
|
|
498
|
+
attachTo: document.body,
|
|
499
|
+
})
|
|
500
|
+
await flushPromises()
|
|
501
|
+
const pad = w.find('.pad').element as HTMLElement
|
|
502
|
+
pointer(w.find('.key').element, 'pointerdown', 10, 10)
|
|
503
|
+
expect(document.activeElement).toBe(pad)
|
|
504
|
+
pointer(window, 'pointerup', 10, 10)
|
|
505
|
+
// On the node itself (not its own content) or the pane, the canvas takes the focus as before
|
|
506
|
+
pointer(node(w, 'a'), 'pointerdown', 5, 5)
|
|
507
|
+
pointer(window, 'pointerup', 5, 5)
|
|
508
|
+
expect(document.activeElement).not.toBe(pad)
|
|
509
|
+
expect(w.element.contains(document.activeElement)).toBe(true)
|
|
510
|
+
w.unmount()
|
|
511
|
+
})
|
|
443
512
|
it("a handle at position 'auto' leaves on the side facing the edge's other end", async () => {
|
|
444
513
|
const edges: FlowEdge[] = [{ id: 'e1', source: 'a', target: 'b', type: 'step', markerEnd: 'none' }]
|
|
445
514
|
const w = mount(MFlow, {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import MMortgageCalculator from '../components/MMortgageCalculator.vue'
|
|
4
|
+
import type { MortgageInput } from '../components/MMortgageCalculator.vue'
|
|
5
|
+
|
|
6
|
+
const input: MortgageInput = { price: 250_000, down: 50_000, rate: 6, years: 30 }
|
|
7
|
+
|
|
8
|
+
function setup(extra: Record<string, unknown> = {}) {
|
|
9
|
+
const w = mount(MMortgageCalculator, {
|
|
10
|
+
props: { modelValue: input, currency: 'USD', 'onUpdate:modelValue': (v: MortgageInput) => w.setProps({ modelValue: v }), ...extra },
|
|
11
|
+
})
|
|
12
|
+
return w
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe('MMortgageCalculator', () => {
|
|
16
|
+
it('shows the monthly payment of the loan', () => {
|
|
17
|
+
const w = setup()
|
|
18
|
+
expect(w.find('[data-loan]').text()).toBe('$200,000')
|
|
19
|
+
expect(w.find('[data-monthly]').text()).toBe('$1,199.10')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('changes the term from the chips', async () => {
|
|
23
|
+
const w = setup()
|
|
24
|
+
await w.find('[data-term="15"]').trigger('click')
|
|
25
|
+
expect(w.props('modelValue').years).toBe(15)
|
|
26
|
+
expect(w.find('[data-monthly]').text()).toBe('$1,687.71')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('adds monthly extras and shows the falling payments of the german system', () => {
|
|
30
|
+
const w = setup({ system: 'german', extras: [{ label: 'Insurance', amount: 50 }] })
|
|
31
|
+
// 200000 / 360 = 555.56 principal + 1000 interest + 50
|
|
32
|
+
expect(w.find('[data-monthly]').text()).toBe('$1,605.56')
|
|
33
|
+
expect(w.text()).toContain('Last payment')
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('folds the schedule by year', async () => {
|
|
37
|
+
const w = setup()
|
|
38
|
+
expect(w.find('[data-schedule]').exists()).toBe(false)
|
|
39
|
+
await w.find('[data-toggle-schedule]').trigger('click')
|
|
40
|
+
expect(w.findAll('[data-schedule] tbody tr')).toHaveLength(30)
|
|
41
|
+
expect(w.findAll('[data-schedule] tbody tr').at(-1)!.text()).toContain('$0')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('keeps the down payment within the price', async () => {
|
|
45
|
+
const w = setup()
|
|
46
|
+
await w.find('[data-field="price"] input').setValue('40000')
|
|
47
|
+
expect(w.props('modelValue')).toMatchObject({ price: 40_000, down: 40_000 })
|
|
48
|
+
})
|
|
49
|
+
})
|