From 6895780c09c0d2204ba3898b36b450208382dc3a Mon Sep 17 00:00:00 2001 From: Jtubau Date: Thu, 12 Dec 2024 16:26:01 +0100 Subject: [PATCH] feat: refs #7072 added test to computed fn total --- .../components/common/VnDiscount.spec.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/vitest/__tests__/components/common/VnDiscount.spec.js diff --git a/test/vitest/__tests__/components/common/VnDiscount.spec.js b/test/vitest/__tests__/components/common/VnDiscount.spec.js new file mode 100644 index 000000000..5d5be61ac --- /dev/null +++ b/test/vitest/__tests__/components/common/VnDiscount.spec.js @@ -0,0 +1,28 @@ +import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest'; +import { createWrapper } from 'app/test/vitest/helper'; +import VnDiscount from 'components/common/vnDiscount.vue'; + +describe('VnDiscount', () => { + let vm; + + beforeAll(() => { + vm = createWrapper(VnDiscount, { + props: { + data: {}, + price: 100, + quantity: 2, + discount: 10, + } + }).vm; + }); + + afterEach(() => { + vi.clearAllMocks(); + }); + + describe('total', () => { + it('should calculate total correctly', () => { + expect(vm.total).toBe(180); + }); + }); +}); \ No newline at end of file