27 lines
799 B
TypeScript
27 lines
799 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { TransactionId } from './TransactionId';
|
|
|
|
describe('TransactionId', () => {
|
|
it('should create a transaction id', () => {
|
|
const id = TransactionId.create('tx1');
|
|
expect(id.toString()).toBe('tx1');
|
|
});
|
|
|
|
it('should throw on empty id', () => {
|
|
expect(() => TransactionId.create('')).toThrow('Transaction ID cannot be empty');
|
|
});
|
|
|
|
it('should trim whitespace', () => {
|
|
const id = TransactionId.create(' tx1 ');
|
|
expect(id.toString()).toBe('tx1');
|
|
});
|
|
|
|
it('should check equality', () => {
|
|
const id1 = TransactionId.create('tx1');
|
|
const id2 = TransactionId.create('tx1');
|
|
const id3 = TransactionId.create('tx2');
|
|
|
|
expect(id1.equals(id2)).toBe(true);
|
|
expect(id1.equals(id3)).toBe(false);
|
|
});
|
|
}); |