trade360-nodejs-sdk
Version:
LSports Trade360 SDK for Node.js
34 lines • 1.87 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const class_transformer_1 = require("class-transformer");
const keep_alive_1 = require("../../../../src/entities/core-entities/keep-alive/keep-alive");
const name_value_record_1 = require("../../../../src/entities/core-entities/common/name-value-record");
describe('KeepAlive', () => {
it('should deserialize a plain object into a KeepAlive instance', () => {
const plain = {
ActiveEvents: [1, 2, 3],
ExtraData: [{ Name: 'foo', Value: 'bar' }],
ProviderId: 42,
};
const keepAlive = (0, class_transformer_1.plainToInstance)(keep_alive_1.KeepAlive, plain, { excludeExtraneousValues: true });
expect(keepAlive).toBeInstanceOf(keep_alive_1.KeepAlive);
expect(Array.isArray(keepAlive.activeEvents)).toBe(true);
expect(keepAlive.activeEvents).toEqual([1, 2, 3]);
expect(Array.isArray(keepAlive.extraData)).toBe(true);
expect(keepAlive.extraData?.[0]).toBeInstanceOf(name_value_record_1.NameValueRecord);
expect(keepAlive.providerId).toBe(42);
});
it('should handle missing properties', () => {
const plain = {};
const keepAlive = (0, class_transformer_1.plainToInstance)(keep_alive_1.KeepAlive, plain, { excludeExtraneousValues: true });
expect(keepAlive.activeEvents).toBeUndefined();
expect(keepAlive.extraData).toBeUndefined();
expect(keepAlive.providerId).toBeUndefined();
});
it('should ignore extraneous properties', () => {
const plain = { ProviderId: 7, Extra: 'ignore me' };
const keepAlive = (0, class_transformer_1.plainToInstance)(keep_alive_1.KeepAlive, plain, { excludeExtraneousValues: true });
expect(keepAlive.Extra).toBeUndefined();
});
});
//# sourceMappingURL=keep-alive.spec.js.map