UNPKG

einvoicing

Version:

A JavaScript library for creating and parsing electronic invoices compliant with the eInvoicing Directive, EN 16931, and popular extensions

41 lines 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var Entity_1 = require("./Entity"); var EntityId_1 = require("./EntityId"); var TestEntity = /** @class */ (function (_super) { tslib_1.__extends(TestEntity, _super); function TestEntity() { return _super !== null && _super.apply(this, arguments) || this; } TestEntity.create = function (props, id) { return new TestEntity(props, id); }; return TestEntity; }(Entity_1.Entity)); describe('Entity', function () { var entity; beforeAll(function () { entity = TestEntity.create({ name: 'test' }, 1); }); test('base', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { var entityNew, entity2, entity3; return tslib_1.__generator(this, function (_a) { entityNew = TestEntity.create({ name: 'test2' }); expect(entityNew.id.toString().length).toEqual(36); // random id entity2 = TestEntity.create({ name: 'test2' }, 1); expect(entity.equals(entity2)).toBeTruthy(); // same id expect(entity.equals(entity)).toBeTruthy(); // same instance expect(entity.equals(null)).toBeFalsy(); // null expect(entity.equals({ id: new EntityId_1.EntityId(1) })).toBeFalsy(); // not Entity expect(entity.id.toPrimitive()).toEqual(1); expect(entity.id.toString()).toEqual('6061cf31-edcb-5d22-9adc-927af7c186fa'); entity3 = TestEntity.create({ name: 'test2' }, entity.id); expect(entity.equals(entity3)).toBeTruthy(); // same id expect(entity3.id.toPrimitive()).toEqual(1); expect(entity3.id.toString()).toEqual('6061cf31-edcb-5d22-9adc-927af7c186fa'); return [2 /*return*/]; }); }); }); }); //# sourceMappingURL=Entity.spec.js.map