Skip to content

Commit 583c4a3

Browse files
Antoine de Chevignéclaude
andcommitted
fix: resolve remaining locale and timeout issues in tests
- Mock Date.prototype.toLocaleDateString for consistent date formatting - Increase timeout for ContractReadMethod test (dynamic import is slow) - Update DateRangeSelector snapshot with consistent US date format - Write missing ContractReadMethod snapshot Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2472d4b commit 583c4a3

File tree

4 files changed

+66
-6
lines changed

4 files changed

+66
-6
lines changed

tests/setup.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,22 @@ import FromWei from '@/filters/FromWei';
1313
import dt from '@/filters/dt';
1414
import { vi } from 'vitest';
1515

16-
// Mock toLocaleString to use consistent en-US locale for snapshot testing
17-
const originalToLocaleString = Number.prototype.toLocaleString;
16+
// Mock toLocaleString methods to use consistent en-US locale for snapshot testing
17+
const originalNumberToLocaleString = Number.prototype.toLocaleString;
1818
Number.prototype.toLocaleString = function(locales, options) {
19-
return originalToLocaleString.call(this, 'en-US', options);
19+
return originalNumberToLocaleString.call(this, 'en-US', options);
2020
};
2121

2222
const originalDateToLocaleString = Date.prototype.toLocaleString;
2323
Date.prototype.toLocaleString = function(locales, options) {
2424
return originalDateToLocaleString.call(this, 'en-US', options);
2525
};
2626

27+
const originalDateToLocaleDateString = Date.prototype.toLocaleDateString;
28+
Date.prototype.toLocaleDateString = function(locales, options) {
29+
return originalDateToLocaleDateString.call(this, 'en-US', options);
30+
};
31+
2732
const ethernal = {
2833
colors: {
2934
primary: '#3D95CE',

tests/unit/components/ContractReadMethod.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('ContractReadMethod.vue', () => {
8383
vi.resetModules();
8484
});
8585

86-
it('Should display the UI to interact with a method', async () => {
86+
it('Should display the UI to interact with a method', { timeout: 15000 }, async () => {
8787
const props = {
8888
method: mockERC20Contract.abi[0],
8989
contract: mockERC20Contract,

tests/unit/components/__snapshots__/ContractReadMethod.spec.js.snap

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,61 @@ exports[`ContractReadMethod.vue > Should display a generic error message if the
5555
</div>"
5656
`;
5757
58+
exports[`ContractReadMethod.vue > Should display the UI to interact with a method 1`] = `
59+
"<div active="true" options="[object Object]">
60+
<div class="pb-1 font-weight-bold">isApprovedForAll</div>
61+
<div class="v-input v-input--horizontal v-input--center-affix v-input--density-compact v-theme--light v-locale--is-ltr v-text-field py-1 col-3" style="width: 50%;">
62+
<!---->
63+
<div class="v-input__control">
64+
<div class="v-field v-field--center-affix v-field--variant-outlined v-theme--light v-locale--is-ltr">
65+
<div class="v-field__overlay"></div>
66+
<div class="v-field__loader">
67+
<div class="v-progress-linear v-theme--light v-locale--is-ltr" style="top: 0px; height: 0px; --v-progress-linear-height: 2px;" role="progressbar" aria-hidden="true" aria-valuemin="0" aria-valuemax="100">
68+
<!---->
69+
<div class="v-progress-linear__background"></div>
70+
<div class="v-progress-linear__buffer" style="width: 0%;"></div>
71+
<transition-stub name="fade-transition" appear="false" persisted="false" css="true">
72+
<div class="v-progress-linear__indeterminate">
73+
<div class="v-progress-linear__indeterminate long"></div>
74+
<div class="v-progress-linear__indeterminate short"></div>
75+
</div>
76+
</transition-stub>
77+
<!---->
78+
</div>
79+
</div>
80+
<!---->
81+
<div class="v-field__field" data-no-activator="">
82+
<!----><label class="v-label v-field-label" for="input-0">
83+
<!---->address owner
84+
</label>
85+
<!----><input size="1" type="text" id="input-0" aria-describedby="input-0-messages" class="v-field__input">
86+
<!---->
87+
</div>
88+
<!---->
89+
<!---->
90+
<div class="v-field__outline">
91+
<div class="v-field__outline__start"></div>
92+
<div class="v-field__outline__notch"><label class="v-label v-field-label v-field-label--floating" aria-hidden="true" for="input-0">
93+
<!---->address owner
94+
</label></div>
95+
<div class="v-field__outline__end"></div>
96+
<!---->
97+
</div>
98+
</div>
99+
</div>
100+
<!---->
101+
<!---->
102+
</div>
103+
<div>=&gt; bool</div>
104+
<div id="call" style="display: none;"></div>
105+
<div id="call" class="bg-grey-lighten-3 pa-2" style="display: none;"></div><button type="button" class="v-btn v-btn--elevated v-theme--light v-btn--density-default v-btn--size-default v-btn--variant-elevated mt-1" id="query"><span class="v-btn__overlay"></span><span class="v-btn__underlay"></span>
106+
<!----><span class="v-btn__content" data-no-activator="">Query</span>
107+
<!---->
108+
<!---->
109+
</button>
110+
</div>"
111+
`;
112+
58113
exports[`ContractReadMethod.vue > Should display the error message if one is returned 1`] = `
59114
"<div active="true" options="[object Object]">
60115
<div class="pb-1 font-weight-bold">isApprovedForAll</div>

tests/unit/components/__snapshots__/DateRangeSelector.spec.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ exports[`DateRangeSelector.vue > Should emit range when selecting custom dates 1
351351
<div class="v-chip__prepend"><i class="mdi-calendar mdi v-icon notranslate v-theme--light v-icon--size-default v-icon--start" aria-hidden="true"></i>
352352
<!---->
353353
</div>
354-
<div class="v-chip__content" data-no-activator=""><span>01/01/2024 to 31/01/2024</span></div>
354+
<div class="v-chip__content" data-no-activator=""><span>1/1/2024 to 1/31/2024</span></div>
355355
<!---->
356356
<!----></span>
357357
</div>
@@ -379,7 +379,7 @@ exports[`DateRangeSelector.vue > Should emit range when selecting custom dates 1
379379
<!---->
380380
<div class="v-sheet v-theme--light v-picker v-date-picker v-date-picker--month">
381381
<div class="bg-primary">
382-
<div class="v-picker-title"><span class="text-subtitle-2">01/01/2024 to 31/01/2024</span><button type="button" class="v-btn v-btn--icon v-theme--light text-white v-btn--density-default v-btn--size-small v-btn--variant-text" style="position: absolute; right: 0px; top: 0px;"><span class="v-btn__overlay"></span><span class="v-btn__underlay"></span>
382+
<div class="v-picker-title"><span class="text-subtitle-2">1/1/2024 to 1/31/2024</span><button type="button" class="v-btn v-btn--icon v-theme--light text-white v-btn--density-default v-btn--size-small v-btn--variant-text" style="position: absolute; right: 0px; top: 0px;"><span class="v-btn__overlay"></span><span class="v-btn__underlay"></span>
383383
<!----><span class="v-btn__content" data-no-activator=""><i class="mdi-close mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i></span>
384384
<!---->
385385
<!---->

0 commit comments

Comments
 (0)