@ludeo/cloud-common 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/infra/ludeo-event.validation.spec.d.ts +1 -0
- package/dist/infra/ludeo-event.validation.spec.js +58 -0
- package/dist/infra/ludeo-event.validation.spec.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/v2/contexts/cloud-session-context.validation.spec.d.ts +1 -0
- package/dist/v2/contexts/cloud-session-context.validation.spec.js +163 -0
- package/dist/v2/contexts/cloud-session-context.validation.spec.js.map +1 -0
- package/jest.config.ts +12 -0
- package/package.json +8 -3
- package/src/infra/ludeo-event.validation.spec.ts +70 -0
- package/src/v2/contexts/cloud-session-context.validation.spec.ts +190 -0
- package/tsconfig.json +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const class_validator_1 = require("class-validator");
|
|
4
|
+
const ludeo_event_1 = require("./ludeo-event");
|
|
5
|
+
describe("LudeoEvent Validation", () => {
|
|
6
|
+
it("should succeed with valid data", async () => {
|
|
7
|
+
const event = new ludeo_event_1.LudeoEvent("TestEvent");
|
|
8
|
+
const errors = await (0, class_validator_1.validate)(event);
|
|
9
|
+
expect(errors.length).toBe(0);
|
|
10
|
+
});
|
|
11
|
+
it("should fail if eventId is not a valid UUID", async () => {
|
|
12
|
+
const event = new ludeo_event_1.LudeoEvent("TestEvent");
|
|
13
|
+
event.eventId = "invalid-uuid";
|
|
14
|
+
const errors = await (0, class_validator_1.validate)(event);
|
|
15
|
+
expect(errors.length).toBe(1);
|
|
16
|
+
expect(errors[0].constraints).toHaveProperty("isUuid");
|
|
17
|
+
});
|
|
18
|
+
it("should fail if eventName is empty", async () => {
|
|
19
|
+
const event = new ludeo_event_1.LudeoEvent("");
|
|
20
|
+
const errors = await (0, class_validator_1.validate)(event);
|
|
21
|
+
expect(errors.length).toBe(1);
|
|
22
|
+
expect(errors[0].constraints).toHaveProperty("isNotEmpty");
|
|
23
|
+
});
|
|
24
|
+
it("should fail if eventName is not a string", async () => {
|
|
25
|
+
const event = new ludeo_event_1.LudeoEvent("TestEvent");
|
|
26
|
+
event.eventName = 12345;
|
|
27
|
+
const errors = await (0, class_validator_1.validate)(event);
|
|
28
|
+
expect(errors.length).toBe(1);
|
|
29
|
+
expect(errors[0].constraints).toHaveProperty("isString");
|
|
30
|
+
});
|
|
31
|
+
it("should fail if timestamp is not an integer", async () => {
|
|
32
|
+
const event = new ludeo_event_1.LudeoEvent("TestEvent");
|
|
33
|
+
event.timestamp = "not-an-integer";
|
|
34
|
+
const errors = await (0, class_validator_1.validate)(event);
|
|
35
|
+
expect(errors.length).toBe(1);
|
|
36
|
+
expect(errors[0].constraints).toHaveProperty("isInt");
|
|
37
|
+
});
|
|
38
|
+
it("should fail if timestamp is missing", async () => {
|
|
39
|
+
const event = new ludeo_event_1.LudeoEvent("TestEvent");
|
|
40
|
+
delete event.timestamp;
|
|
41
|
+
const errors = await (0, class_validator_1.validate)(event);
|
|
42
|
+
expect(errors.length).toBe(1);
|
|
43
|
+
expect(errors[0].constraints).toHaveProperty("isInt");
|
|
44
|
+
});
|
|
45
|
+
it("should fail if eventVersion is not 3.0", async () => {
|
|
46
|
+
const event = new ludeo_event_1.LudeoEvent("TestEvent");
|
|
47
|
+
const errors = await (0, class_validator_1.validate)(event);
|
|
48
|
+
expect(errors.length).toBe(0);
|
|
49
|
+
expect(event.eventVersion).toBe("3.0");
|
|
50
|
+
});
|
|
51
|
+
it("should fail if missing eventVersion", async () => {
|
|
52
|
+
const event = new ludeo_event_1.LudeoEvent("TestEvent");
|
|
53
|
+
delete event.eventVersion;
|
|
54
|
+
const errors = await (0, class_validator_1.validate)(event);
|
|
55
|
+
expect(errors.length).toBe(1);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=ludeo-event.validation.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ludeo-event.validation.spec.js","sourceRoot":"","sources":["../../src/infra/ludeo-event.validation.spec.ts"],"names":[],"mappings":";;AAAA,qDAA2C;AAC3C,+CAA2C;AAE3C,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;QAC9C,MAAM,KAAK,GAAG,IAAI,wBAAU,CAAC,WAAW,CAAC,CAAC;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAQ,EAAC,KAAK,CAAC,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QAC1D,MAAM,KAAK,GAAG,IAAI,wBAAU,CAAC,WAAW,CAAC,CAAC;QAC1C,KAAK,CAAC,OAAO,GAAG,cAAc,CAAC;QAE/B,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAQ,EAAC,KAAK,CAAC,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,KAAK,GAAG,IAAI,wBAAU,CAAC,EAAE,CAAC,CAAC;QAEjC,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAQ,EAAC,KAAK,CAAC,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9B,MAAM,CAAC,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