forked from verdnatura/salix-front
refs #5402 added test
This commit is contained in:
parent
b674bc4d41
commit
502a4208b8
|
@ -0,0 +1,58 @@
|
|||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnSmsDialog from 'components/common/VnSmsDialog.vue';
|
||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
|
||||
describe('VnSmsDialog', () => {
|
||||
let vm;
|
||||
const orderId = 1;
|
||||
const shipped = new Date();
|
||||
const phone = '012345678';
|
||||
const promise = (response) => {return response;};
|
||||
const template = 'minAmount';
|
||||
const locale = 'en';
|
||||
|
||||
beforeAll(() => {
|
||||
vm = createWrapper(VnSmsDialog, {
|
||||
propsData: {
|
||||
data: {
|
||||
orderId,
|
||||
shipped
|
||||
},
|
||||
template,
|
||||
locale,
|
||||
phone,
|
||||
promise
|
||||
}
|
||||
}).vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('updateMessage()', () => {
|
||||
it('should update the message value with the correct template and parameters', () => {
|
||||
vm.updateMessage();
|
||||
|
||||
expect(vm.message).toEqual(`A minimum amount of 50€ (VAT excluded) is required for your order ${orderId} of ${shipped} to receive it without additional shipping costs.`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('send()', async () => {
|
||||
it('should send the message', async () => {
|
||||
vi.spyOn(vm.props, 'promise');
|
||||
vm.message = 'Example message';
|
||||
const response = {
|
||||
orderId,
|
||||
shipped,
|
||||
destination: phone,
|
||||
message: vm.message
|
||||
};
|
||||
await vm.send();
|
||||
|
||||
expect(vm.isLoading).toEqual(false);
|
||||
expect(vm.props.promise).toHaveBeenCalledWith(response);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue