Skip to content

Commit 03c8db4

Browse files
committed
fix: removed dynamic style tag from html for snapshots
- Updated TypeScript configuration to include path mapping for easier imports. - Modified multiple component tests to remove dynamic style attributes from snapshots, ensuring consistency and accuracy in test results. - Adjusted snapshots for BooleanControl, ButtonControl, ColorControl, Folder, NumberControl, SelectControl, TextControl, TresLeches, and VectorControl to reflect the latest implementation changes.
1 parent 896cb45 commit 03c8db4

19 files changed

+50
-39
lines changed

src/components/BooleanControl.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ describe('boolean Control', async () => {
2828
})
2929
})
3030
it('should render a boolean control', async () => {
31-
expect(wrapper.html()).toMatchSnapshot()
31+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
3232
expect(wrapper.find('input').attributes('type')).toBe('checkbox')
3333
})
3434
it('should render a boolean control with a label', async () => {
35-
expect(wrapper.html()).toMatchSnapshot()
35+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
3636
expect(wrapper.find('label').text()).toBe('test')
3737
})
3838
it('should change the value of the control when the input changes', async () => {

src/components/ButtonControl.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ describe('button Controls', () => {
2323
mountComponent(() => {
2424
useControls({ acceptBtn: { type: 'button', label: 'Accept' } })
2525
})
26-
expect(wrapper.html()).toMatchSnapshot()
26+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
2727
expect(wrapper.find('button').exists()).toBe(true)
2828
})
2929

3030
it('should render a button with a label', () => {
3131
mountComponent(() => {
3232
useControls({ acceptBtn: { type: 'button', label: 'Accept' } })
3333
})
34-
expect(wrapper.html()).toMatchSnapshot()
34+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
3535
expect(wrapper.find('button').text()).toBe('Accept')
3636
})
3737

@@ -51,47 +51,47 @@ describe('button Controls', () => {
5151
mountComponent(() => {
5252
useControls({ acceptBtn: { type: 'button', label: 'Accept', icon: 'i-carbon-checkmark' } })
5353
})
54-
expect(wrapper.html()).toMatchSnapshot()
54+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
5555
expect(wrapper.find('i.i-carbon-checkmark').exists()).toBe(true)
5656
})
5757

5858
it('should render a small button', () => {
5959
mountComponent(() => {
6060
useControls({ acceptBtn: { type: 'button', label: 'Accept', size: 'sm' } })
6161
})
62-
expect(wrapper.html()).toMatchSnapshot()
62+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
6363
expect(wrapper.find('button').classes()).toContain('leches-btn-sm')
6464
})
6565

6666
it('should render a large button', () => {
6767
mountComponent(() => {
6868
useControls({ acceptBtn: { type: 'button', label: 'Accept', size: 'lg' } })
6969
})
70-
expect(wrapper.html()).toMatchSnapshot()
70+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
7171
expect(wrapper.find('button').classes()).toContain('leches-btn-lg')
7272
})
7373

7474
it('should render a block size button', () => {
7575
mountComponent(() => {
7676
useControls({ acceptBtn: { type: 'button', label: 'Accept', size: 'block' } })
7777
})
78-
expect(wrapper.html()).toMatchSnapshot()
78+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
7979
expect(wrapper.find('button').classes()).toContain('leches-btn-block')
8080
})
8181

8282
it('should render a primary button variant by default', () => {
8383
mountComponent(() => {
8484
useControls({ acceptBtn: { type: 'button', label: 'Accept' } })
8585
})
86-
expect(wrapper.html()).toMatchSnapshot()
86+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
8787
expect(wrapper.find('button').classes()).toContain('leches-btn-primary')
8888
})
8989

9090
it('should render a secondary button variant', () => {
9191
mountComponent(() => {
9292
useControls({ acceptBtn: { type: 'button', label: 'Accept', variant: 'secondary' } })
9393
})
94-
expect(wrapper.html()).toMatchSnapshot()
94+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
9595
expect(wrapper.find('button').classes()).toContain('leches-btn-secondary')
9696
})
9797
})

src/components/ColorControl.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('color Control', async () => {
2828
})
2929
})
3030
it('should render a color control', async () => {
31-
expect(wrapper.html()).toMatchSnapshot()
31+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
3232
expect(wrapper.find('input').attributes('type')).toBe('color')
3333
})
3434
it('should render a color control with a label', async () => {

src/components/Folder.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('folder Controls', () => {
5050
const { position } = useControls('camera', { position: new Vector3(3, 2, 4) })
5151
return { position }
5252
})
53-
expect(wrapper.html()).toMatchSnapshot()
53+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
5454
expect(wrapper.find('button[data-folder="camera"]').exists()).toBe(true)
5555
expect(wrapper.find('input[id="cameraPosition-x"]').exists()).toBe(true)
5656
expect(wrapper.find('input[id="cameraPosition-y"]').exists()).toBe(true)

src/components/NumberControl.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('number Control', async () => {
3030
})
3131
})
3232
it('should render a number control', async () => {
33-
expect(wrapper.html()).toMatchSnapshot()
33+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
3434
expect(wrapper.find('input').attributes('type')).toBe('number')
3535
})
3636
it('should render a number control with a label', async () => {

src/components/SelectControl.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('dropdown Control', async () => {
4040
})
4141
})
4242
it('should render a select control', async () => {
43-
expect(wrapper.html()).toMatchSnapshot()
43+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
4444
expect(wrapper.find('select').exists())
4545
})
4646
it('should render a select control with a label', async () => {

src/components/TextControl.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('text Control', () => {
2929
})
3030

3131
it('should render a text control', () => {
32-
expect(wrapper.html()).toMatchSnapshot()
32+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
3333
expect(wrapper.find('input').attributes('type')).toBe('text')
3434
})
3535

src/components/TresLeches.test.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
import { mount } from '@vue/test-utils'
2-
import { TresLeches } from '/@/'
3-
import { expect, it } from 'vitest'
2+
import { TresLeches } from '../index'
3+
import { beforeEach, describe, expect, it, vi } from 'vitest'
44
import { dispose } from '../composables/useControls'
55

6-
afterEach(() => {
6+
beforeEach(() => {
77
dispose()
8+
// Mock the useMotion composable
9+
vi.mock('@vueuse/motion', () => ({
10+
useMotion: () => ({
11+
apply: vi.fn(),
12+
}),
13+
}))
814
})
915

10-
describe('tresLeches', async () => {
16+
describe('tresLeches', () => {
1117
it('should mount', async () => {
1218
const wrapper = mount(TresLeches, {
13-
/* attachTo: document.body, */
1419
props: {
1520
uuid: 'test',
1621
},
22+
attachTo: document.body,
1723
})
18-
expect(wrapper.html()).toMatchSnapshot()
24+
// Remove dynamic style attributes before snapshot
25+
const html = wrapper.html().replace(/style="[^"]*"/, '')
26+
expect(html).toMatchSnapshot()
1927
expect(wrapper.find('div').attributes('id')).toBe('tres-leches-pane-test')
2028
})
2129
})

src/components/VectorControl.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('vector Control', async () => {
5353
})
5454
})
5555
it('should render multiple numeric inputs', async () => {
56-
expect(wrapper.html()).toMatchSnapshot()
56+
expect(wrapper.html().replace(/style="[^"]*"/, '')).toMatchSnapshot()
5757
expect(wrapper.findAll('input[type="number"]').length).toBeGreaterThan(1)
5858
})
5959
it('should render a number control with a label', async () => {

src/components/__snapshots__/BooleanControl.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`boolean Control > should render a boolean control 1`] = `
4-
"<div id="tres-leches-pane-default" class="tl-fixed tl-top-4 tl-z-24 tl-bg-white tl-shadow-xl tl-p-1 tl-font-sans tl-text-xs tl-overflow-hidden tl-rounded-lg" style="top: 10px; width: 44.20507903623789px; height: 48.0634311877231px; right: 16px; opacity: 0.05555555555555556; transform: translate3d(0px,93.99537602289712px,0px);">
4+
"<div id="tres-leches-pane-default" class="tl-fixed tl-top-4 tl-z-24 tl-bg-white tl-shadow-xl tl-p-1 tl-font-sans tl-text-xs tl-overflow-hidden tl-rounded-lg" >
55
<header class="tl-flex tl-justify-between tl-items-center tl-text-gray-200 tl-text-xs">
66
<div class="w-1/3"></div>
77
<div class="tl-cursor-grabbing"><i class="i-ic-baseline-drag-indicator"></i><i class="i-ic-baseline-drag-indicator"></i><i class="i-ic-baseline-drag-indicator"></i></div>
@@ -27,7 +27,7 @@ exports[`boolean Control > should render a boolean control 1`] = `
2727
`;
2828
2929
exports[`boolean Control > should render a boolean control with a label 1`] = `
30-
"<div id="tres-leches-pane-default" class="tl-fixed tl-top-4 tl-z-24 tl-bg-white tl-shadow-xl tl-p-1 tl-font-sans tl-text-xs tl-overflow-hidden tl-rounded-lg" style="top: 10px; width: 50.37618296199835px; height: 55.70384557199793px; right: 16px; opacity: 0.06643236000000002; transform: translate3d(0px,91.66721371472505px,0px);">
30+
"<div id="tres-leches-pane-default" class="tl-fixed tl-top-4 tl-z-24 tl-bg-white tl-shadow-xl tl-p-1 tl-font-sans tl-text-xs tl-overflow-hidden tl-rounded-lg" >
3131
<header class="tl-flex tl-justify-between tl-items-center tl-text-gray-200 tl-text-xs">
3232
<div class="w-1/3"></div>
3333
<div class="tl-cursor-grabbing"><i class="i-ic-baseline-drag-indicator"></i><i class="i-ic-baseline-drag-indicator"></i><i class="i-ic-baseline-drag-indicator"></i></div>

0 commit comments

Comments
 (0)