28 lines
789 B
TypeScript
28 lines
789 B
TypeScript
import { uuidTransformer } from '@/utils/uuidTransformer';
|
|
import { NIL } from 'uuid';
|
|
|
|
describe('uuidTransformer util', () => {
|
|
const transformer = uuidTransformer;
|
|
beforeEach(() => {});
|
|
|
|
it('Should have a to member', () => {
|
|
expect(transformer.to).toBeDefined();
|
|
});
|
|
|
|
it('Should have a from member', () => {
|
|
expect(transformer.from).toBeDefined();
|
|
});
|
|
|
|
it('From method should return a nil uuid if null is passed', () => {
|
|
expect(transformer.from(null)).toBe(NIL);
|
|
});
|
|
|
|
it('From method should return a nil uuid if empty 16 length buffer is passed', () => {
|
|
expect(transformer.from(Buffer.alloc(16))).toBe(NIL);
|
|
});
|
|
|
|
it('To method should return a buffer matching the uuid', () => {
|
|
expect(transformer.to(NIL)).toEqual(Buffer.alloc(16));
|
|
});
|
|
});
|