diff --git a/test/vitest/__tests__/components/common/VnLinkPhone.spec.js b/test/vitest/__tests__/components/common/VnLinkPhone.spec.js
index e460ab2fc..1505e32f7 100644
--- a/test/vitest/__tests__/components/common/VnLinkPhone.spec.js
+++ b/test/vitest/__tests__/components/common/VnLinkPhone.spec.js
@@ -1,29 +1,39 @@
-import { describe, it, expect } from 'vitest';
+import { describe, it, expect, beforeAll, vi } from 'vitest';
+import { axios } from 'app/test/vitest/helper';
import parsePhone from 'src/filters/parsePhone';
describe('parsePhone filter', () => {
- it("adds prefix +34 if it doesn't have one", () => {
- const resultado = parsePhone('123456789', '34');
- expect(resultado).toBe('34123456789');
+ beforeAll(async () => {
+ vi.spyOn(axios, 'get').mockReturnValue({ data: { prefix: '34' } });
});
- it('maintains prefix +34 if it is already correct', () => {
- const resultado = parsePhone('+34123456789', '34');
- expect(resultado).toBe('34123456789');
+ it('no phone', async () => {
+ const phone = await parsePhone(null, '34');
+ expect(phone).toBe(undefined);
});
- it('converts prefix 0034 to +34', () => {
- const resultado = parsePhone('0034123456789', '34');
- expect(resultado).toBe('34123456789');
+ it("adds prefix +34 if it doesn't have one", async () => {
+ const phone = await parsePhone('123456789', '34');
+ expect(phone).toBe('34123456789');
});
- it('converts prefix 34 without symbol to +34', () => {
- const resultado = parsePhone('34123456789', '34');
- expect(resultado).toBe('34123456789');
+ it('maintains prefix +34 if it is already correct', async () => {
+ const phone = await parsePhone('+34123456789', '34');
+ expect(phone).toBe('34123456789');
});
- it('replaces incorrect prefix with the correct one', () => {
- const resultado = parsePhone('+44123456789', '34');
- expect(resultado).toBe('44123456789');
+ it('converts prefix 0034 to +34', async () => {
+ const phone = await parsePhone('0034123456789', '34');
+ expect(phone).toBe('34123456789');
+ });
+
+ it('converts prefix 34 without symbol to +34', async () => {
+ const phone = await parsePhone('34123456789', '34');
+ expect(phone).toBe('34123456789');
+ });
+
+ it('replaces incorrect prefix with the correct one', async () => {
+ const phone = await parsePhone('+44123456789', '34');
+ expect(phone).toBe('44123456789');
});
});