Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { describe, expect, it } from 'vitest';
import { avatar, formatDate, formatPrice, joinPrice } from '@/common/function';
describe('Common Helper Function Test', () => {
it("Format Avatar: Take the first letter of each word from the User's name ", () => {
let name: string = "Eko Sutrisno";
expect(avatar(name)).toBe("ES");
})
it("Format Date: Change the date format to DD/MM/yyyy", () => {
let date: string = "2022-12-11";
expect(formatDate(date)).toBe("11/12/2022")
})
it("Format Price: Change the number format using comma delimiters", () => {
let price: string = "20000000500";
expect(formatPrice(price)).toBe("20,000,000,500")
})
it("Join Price: Change the number format form comma delimiters to normal number", () => {
let price: string = "20,000,000,500";
expect(joinPrice(price)).toBe(20000000500)
})
}) |