90 lines
3.3 KiB
TypeScript
90 lines
3.3 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { CheckoutConfirmation } from '../../../../packages/domain/value-objects/CheckoutConfirmation';
|
|
|
|
describe('CheckoutConfirmation Value Object', () => {
|
|
describe('create', () => {
|
|
it('should create confirmed decision', () => {
|
|
const confirmation = CheckoutConfirmation.create('confirmed');
|
|
expect(confirmation.value).toBe('confirmed');
|
|
});
|
|
|
|
it('should create cancelled decision', () => {
|
|
const confirmation = CheckoutConfirmation.create('cancelled');
|
|
expect(confirmation.value).toBe('cancelled');
|
|
});
|
|
|
|
it('should create timeout decision', () => {
|
|
const confirmation = CheckoutConfirmation.create('timeout');
|
|
expect(confirmation.value).toBe('timeout');
|
|
});
|
|
|
|
it('should throw error for invalid decision', () => {
|
|
expect(() => CheckoutConfirmation.create('invalid' as any)).toThrow('Invalid checkout confirmation decision');
|
|
});
|
|
});
|
|
|
|
describe('isConfirmed', () => {
|
|
it('should return true for confirmed decision', () => {
|
|
const confirmation = CheckoutConfirmation.create('confirmed');
|
|
expect(confirmation.isConfirmed()).toBe(true);
|
|
});
|
|
|
|
it('should return false for cancelled decision', () => {
|
|
const confirmation = CheckoutConfirmation.create('cancelled');
|
|
expect(confirmation.isConfirmed()).toBe(false);
|
|
});
|
|
|
|
it('should return false for timeout decision', () => {
|
|
const confirmation = CheckoutConfirmation.create('timeout');
|
|
expect(confirmation.isConfirmed()).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('isCancelled', () => {
|
|
it('should return true for cancelled decision', () => {
|
|
const confirmation = CheckoutConfirmation.create('cancelled');
|
|
expect(confirmation.isCancelled()).toBe(true);
|
|
});
|
|
|
|
it('should return false for confirmed decision', () => {
|
|
const confirmation = CheckoutConfirmation.create('confirmed');
|
|
expect(confirmation.isCancelled()).toBe(false);
|
|
});
|
|
|
|
it('should return false for timeout decision', () => {
|
|
const confirmation = CheckoutConfirmation.create('timeout');
|
|
expect(confirmation.isCancelled()).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('isTimeout', () => {
|
|
it('should return true for timeout decision', () => {
|
|
const confirmation = CheckoutConfirmation.create('timeout');
|
|
expect(confirmation.isTimeout()).toBe(true);
|
|
});
|
|
|
|
it('should return false for confirmed decision', () => {
|
|
const confirmation = CheckoutConfirmation.create('confirmed');
|
|
expect(confirmation.isTimeout()).toBe(false);
|
|
});
|
|
|
|
it('should return false for cancelled decision', () => {
|
|
const confirmation = CheckoutConfirmation.create('cancelled');
|
|
expect(confirmation.isTimeout()).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('equals', () => {
|
|
it('should return true for equal confirmations', () => {
|
|
const confirmation1 = CheckoutConfirmation.create('confirmed');
|
|
const confirmation2 = CheckoutConfirmation.create('confirmed');
|
|
expect(confirmation1.equals(confirmation2)).toBe(true);
|
|
});
|
|
|
|
it('should return false for different confirmations', () => {
|
|
const confirmation1 = CheckoutConfirmation.create('confirmed');
|
|
const confirmation2 = CheckoutConfirmation.create('cancelled');
|
|
expect(confirmation1.equals(confirmation2)).toBe(false);
|
|
});
|
|
});
|
|
}); |