1- import { describe , it , expect } from 'vitest' ;
1+ import { describe , it , expect , vi } from 'vitest' ;
22import MoneyInput from '../../../src/components/misc/MoneyInput.vue' ;
33import { mount } from '@vue/test-utils' ;
4+
5+ vi . mock ( 'vue-i18n' , ( ) => ( {
6+ useI18n : ( ) => ( {
7+ t : ( key : string ) => {
8+ if ( key === 'languageCode' ) return 'de-DE' ;
9+ return key ;
10+ } ,
11+ } ) ,
12+ } ) ) ;
13+
414describe ( 'Test MoneyInput' , ( ) => {
515 it ( 'should input number and convert to money' , async ( ) => {
616 const wrapper = mount ( MoneyInput , {
@@ -11,13 +21,13 @@ describe('Test MoneyInput', () => {
1121
1222 const input = wrapper . get ( 'input' ) ;
1323
14- expect ( ( input . element as HTMLInputElement ) . value ) . toBe ( '1.234,57' ) ;
24+ expect ( ( input . element as HTMLInputElement ) . value ) . toBe ( '1.234,57\u00A0€ ' ) ;
1525
1626 await input . trigger ( 'focus' ) ;
1727 expect ( ( input . element as HTMLInputElement ) . value ) . toBe ( '1234.567' ) ;
1828
1929 await input . trigger ( 'blur' ) ;
20- expect ( ( input . element as HTMLInputElement ) . value ) . toBe ( '1.234,57' ) ;
30+ expect ( ( input . element as HTMLInputElement ) . value ) . toBe ( '1.234,57\u00A0€ ' ) ;
2131 } ) ;
2232
2333 it ( 'should input number with 30 cents and convert to money' , async ( ) => {
@@ -36,7 +46,7 @@ describe('Test MoneyInput', () => {
3646 expect ( ( input . element as HTMLInputElement ) . value ) . toBe ( '12.3' ) ;
3747
3848 await input . trigger ( 'blur' ) ;
39- expect ( ( input . element as HTMLInputElement ) . value ) . toBe ( '12,30' ) ;
49+ expect ( ( input . element as HTMLInputElement ) . value ) . toBe ( '12,30\u00A0€ ' ) ;
4050 } ) ;
4151
4252 it ( 'should input negative number and not convert to money' , async ( ) => {
@@ -56,6 +66,6 @@ describe('Test MoneyInput', () => {
5666 expect ( ( input . element as HTMLInputElement ) . value ) . toBe ( '1234.5' ) ;
5767
5868 await input . trigger ( 'blur' ) ;
59- expect ( ( input . element as HTMLInputElement ) . value ) . toBe ( '1.234,50' ) ;
69+ expect ( ( input . element as HTMLInputElement ) . value ) . toBe ( '1.234,50\u00A0€ ' ) ;
6070 } ) ;
6171} ) ;
0 commit comments