entity-id.spec.ts raw

   1  import { IdentityId, PermissionId, RelayId, NwcConnectionId, CashuMintId } from './index';
   2  
   3  describe('EntityId Value Objects', () => {
   4    describe('IdentityId', () => {
   5      it('should generate unique IDs', () => {
   6        const id1 = IdentityId.generate();
   7        const id2 = IdentityId.generate();
   8  
   9        expect(id1.toString()).not.toEqual(id2.toString());
  10      });
  11  
  12      it('should create from existing string value', () => {
  13        const value = 'test-identity-id-123';
  14        const id = IdentityId.from(value);
  15  
  16        expect(id.toString()).toEqual(value);
  17      });
  18  
  19      it('should be equal when values match', () => {
  20        const value = 'same-id';
  21        const id1 = IdentityId.from(value);
  22        const id2 = IdentityId.from(value);
  23  
  24        expect(id1.equals(id2)).toBe(true);
  25      });
  26  
  27      it('should not be equal when values differ', () => {
  28        const id1 = IdentityId.from('id-1');
  29        const id2 = IdentityId.from('id-2');
  30  
  31        expect(id1.equals(id2)).toBe(false);
  32      });
  33    });
  34  
  35    describe('PermissionId', () => {
  36      it('should generate unique IDs', () => {
  37        const id1 = PermissionId.generate();
  38        const id2 = PermissionId.generate();
  39  
  40        expect(id1.toString()).not.toEqual(id2.toString());
  41      });
  42  
  43      it('should create from existing string value', () => {
  44        const value = 'test-permission-id-456';
  45        const id = PermissionId.from(value);
  46  
  47        expect(id.toString()).toEqual(value);
  48      });
  49    });
  50  
  51    describe('RelayId', () => {
  52      it('should generate unique IDs', () => {
  53        const id1 = RelayId.generate();
  54        const id2 = RelayId.generate();
  55  
  56        expect(id1.toString()).not.toEqual(id2.toString());
  57      });
  58  
  59      it('should create from existing string value', () => {
  60        const value = 'test-relay-id-789';
  61        const id = RelayId.from(value);
  62  
  63        expect(id.toString()).toEqual(value);
  64      });
  65    });
  66  
  67    describe('NwcConnectionId', () => {
  68      it('should generate unique IDs', () => {
  69        const id1 = NwcConnectionId.generate();
  70        const id2 = NwcConnectionId.generate();
  71  
  72        expect(id1.toString()).not.toEqual(id2.toString());
  73      });
  74    });
  75  
  76    describe('CashuMintId', () => {
  77      it('should generate unique IDs', () => {
  78        const id1 = CashuMintId.generate();
  79        const id2 = CashuMintId.generate();
  80  
  81        expect(id1.toString()).not.toEqual(id2.toString());
  82      });
  83    });
  84  });
  85