@wix/motion-edm-autogen-transformations-core 1.3.0
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/cjs/__tests__/corvid-entity.spec.js +68 -0
- package/dist/cjs/__tests__/corvid-entity.spec.js.map +1 -0
- package/dist/cjs/__tests__/getArgumentCardinality.spec.js +58 -0
- package/dist/cjs/__tests__/getArgumentCardinality.spec.js.map +1 -0
- package/dist/cjs/__tests__/helpers.spec.js +90 -0
- package/dist/cjs/__tests__/helpers.spec.js.map +1 -0
- package/dist/cjs/__tests__/reduceTransformation.spec.js +478 -0
- package/dist/cjs/__tests__/reduceTransformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/custom-functions.spec.js +111 -0
- package/dist/cjs/__tests__/transformations/custom-functions.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/preset/create-transformation.spec.js +47 -0
- package/dist/cjs/__tests__/transformations/preset/create-transformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/preset/delete-transformation.spec.js +75 -0
- package/dist/cjs/__tests__/transformations/preset/delete-transformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/preset/get-transformation.spec.js +46 -0
- package/dist/cjs/__tests__/transformations/preset/get-transformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/preset/list-transformation.spec.js +28 -0
- package/dist/cjs/__tests__/transformations/preset/list-transformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/preset/query-transformation.spec.js +66 -0
- package/dist/cjs/__tests__/transformations/preset/query-transformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/transformations/preset/update-transformation.spec.js +90 -0
- package/dist/cjs/__tests__/transformations/preset/update-transformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/validations/validateRequestTransformation.spec.js +291 -0
- package/dist/cjs/__tests__/validations/validateRequestTransformation.spec.js.map +1 -0
- package/dist/cjs/__tests__/validations/validateResponseTransformation.spec.js +370 -0
- package/dist/cjs/__tests__/validations/validateResponseTransformation.spec.js.map +1 -0
- package/dist/cjs/index.js +102 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/corvid-entity/index.js +32 -0
- package/dist/cjs/lib/corvid-entity/index.js.map +1 -0
- package/dist/cjs/lib/getArgumentCardinality.js +34 -0
- package/dist/cjs/lib/getArgumentCardinality.js.map +1 -0
- package/dist/cjs/lib/helpers.js +111 -0
- package/dist/cjs/lib/helpers.js.map +1 -0
- package/dist/cjs/lib/transformations/common.js +24 -0
- package/dist/cjs/lib/transformations/common.js.map +1 -0
- package/dist/cjs/lib/transformations/constants.js +23 -0
- package/dist/cjs/lib/transformations/constants.js.map +1 -0
- package/dist/cjs/lib/transformations/custom-functions.js +46 -0
- package/dist/cjs/lib/transformations/custom-functions.js.map +1 -0
- package/dist/cjs/lib/transformations/preset/create.js +17 -0
- package/dist/cjs/lib/transformations/preset/create.js.map +1 -0
- package/dist/cjs/lib/transformations/preset/delete.js +42 -0
- package/dist/cjs/lib/transformations/preset/delete.js.map +1 -0
- package/dist/cjs/lib/transformations/preset/get.js +17 -0
- package/dist/cjs/lib/transformations/preset/get.js.map +1 -0
- package/dist/cjs/lib/transformations/preset/list.js +13 -0
- package/dist/cjs/lib/transformations/preset/list.js.map +1 -0
- package/dist/cjs/lib/transformations/preset/query.js +40 -0
- package/dist/cjs/lib/transformations/preset/query.js.map +1 -0
- package/dist/cjs/lib/transformations/preset/update.js +37 -0
- package/dist/cjs/lib/transformations/preset/update.js.map +1 -0
- package/dist/cjs/lib/transformations/reduceTransformation.js +180 -0
- package/dist/cjs/lib/transformations/reduceTransformation.js.map +1 -0
- package/dist/cjs/lib/transformations/validations/common.js +50 -0
- package/dist/cjs/lib/transformations/validations/common.js.map +1 -0
- package/dist/cjs/lib/transformations/validations/validateRequestTransformation.js +118 -0
- package/dist/cjs/lib/transformations/validations/validateRequestTransformation.js.map +1 -0
- package/dist/cjs/lib/transformations/validations/validateResponseTransformation.js +161 -0
- package/dist/cjs/lib/transformations/validations/validateResponseTransformation.js.map +1 -0
- package/dist/esm/__tests__/corvid-entity.spec.js +58 -0
- package/dist/esm/__tests__/corvid-entity.spec.js.map +1 -0
- package/dist/esm/__tests__/getArgumentCardinality.spec.js +42 -0
- package/dist/esm/__tests__/getArgumentCardinality.spec.js.map +1 -0
- package/dist/esm/__tests__/helpers.spec.js +61 -0
- package/dist/esm/__tests__/helpers.spec.js.map +1 -0
- package/dist/esm/__tests__/reduceTransformation.spec.js +416 -0
- package/dist/esm/__tests__/reduceTransformation.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/custom-functions.spec.js +87 -0
- package/dist/esm/__tests__/transformations/custom-functions.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/preset/create-transformation.spec.js +40 -0
- package/dist/esm/__tests__/transformations/preset/create-transformation.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/preset/delete-transformation.spec.js +65 -0
- package/dist/esm/__tests__/transformations/preset/delete-transformation.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/preset/get-transformation.spec.js +39 -0
- package/dist/esm/__tests__/transformations/preset/get-transformation.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/preset/list-transformation.spec.js +22 -0
- package/dist/esm/__tests__/transformations/preset/list-transformation.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/preset/query-transformation.spec.js +57 -0
- package/dist/esm/__tests__/transformations/preset/query-transformation.spec.js.map +1 -0
- package/dist/esm/__tests__/transformations/preset/update-transformation.spec.js +85 -0
- package/dist/esm/__tests__/transformations/preset/update-transformation.spec.js.map +1 -0
- package/dist/esm/__tests__/validations/validateRequestTransformation.spec.js +200 -0
- package/dist/esm/__tests__/validations/validateRequestTransformation.spec.js.map +1 -0
- package/dist/esm/__tests__/validations/validateResponseTransformation.spec.js +246 -0
- package/dist/esm/__tests__/validations/validateResponseTransformation.spec.js.map +1 -0
- package/dist/esm/index.js +47 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/corvid-entity/index.js +17 -0
- package/dist/esm/lib/corvid-entity/index.js.map +1 -0
- package/dist/esm/lib/getArgumentCardinality.js +30 -0
- package/dist/esm/lib/getArgumentCardinality.js.map +1 -0
- package/dist/esm/lib/helpers.js +56 -0
- package/dist/esm/lib/helpers.js.map +1 -0
- package/dist/esm/lib/transformations/common.js +17 -0
- package/dist/esm/lib/transformations/common.js.map +1 -0
- package/dist/esm/lib/transformations/constants.js +18 -0
- package/dist/esm/lib/transformations/constants.js.map +1 -0
- package/dist/esm/lib/transformations/custom-functions.js +34 -0
- package/dist/esm/lib/transformations/custom-functions.js.map +1 -0
- package/dist/esm/lib/transformations/preset/create.js +8 -0
- package/dist/esm/lib/transformations/preset/create.js.map +1 -0
- package/dist/esm/lib/transformations/preset/delete.js +25 -0
- package/dist/esm/lib/transformations/preset/delete.js.map +1 -0
- package/dist/esm/lib/transformations/preset/get.js +8 -0
- package/dist/esm/lib/transformations/preset/get.js.map +1 -0
- package/dist/esm/lib/transformations/preset/list.js +6 -0
- package/dist/esm/lib/transformations/preset/list.js.map +1 -0
- package/dist/esm/lib/transformations/preset/query.js +28 -0
- package/dist/esm/lib/transformations/preset/query.js.map +1 -0
- package/dist/esm/lib/transformations/preset/update.js +18 -0
- package/dist/esm/lib/transformations/preset/update.js.map +1 -0
- package/dist/esm/lib/transformations/reduceTransformation.js +122 -0
- package/dist/esm/lib/transformations/reduceTransformation.js.map +1 -0
- package/dist/esm/lib/transformations/validations/common.js +35 -0
- package/dist/esm/lib/transformations/validations/common.js.map +1 -0
- package/dist/esm/lib/transformations/validations/validateRequestTransformation.js +107 -0
- package/dist/esm/lib/transformations/validations/validateRequestTransformation.js.map +1 -0
- package/dist/esm/lib/transformations/validations/validateResponseTransformation.js +142 -0
- package/dist/esm/lib/transformations/validations/validateResponseTransformation.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/__tests__/corvid-entity.spec.d.ts +2 -0
- package/dist/types/__tests__/corvid-entity.spec.d.ts.map +1 -0
- package/dist/types/__tests__/getArgumentCardinality.spec.d.ts +2 -0
- package/dist/types/__tests__/getArgumentCardinality.spec.d.ts.map +1 -0
- package/dist/types/__tests__/helpers.spec.d.ts +2 -0
- package/dist/types/__tests__/helpers.spec.d.ts.map +1 -0
- package/dist/types/__tests__/reduceTransformation.spec.d.ts +2 -0
- package/dist/types/__tests__/reduceTransformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/custom-functions.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/custom-functions.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/preset/create-transformation.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/preset/create-transformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/preset/delete-transformation.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/preset/delete-transformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/preset/get-transformation.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/preset/get-transformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/preset/list-transformation.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/preset/list-transformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/preset/query-transformation.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/preset/query-transformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/transformations/preset/update-transformation.spec.d.ts +2 -0
- package/dist/types/__tests__/transformations/preset/update-transformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/validations/validateRequestTransformation.spec.d.ts +2 -0
- package/dist/types/__tests__/validations/validateRequestTransformation.spec.d.ts.map +1 -0
- package/dist/types/__tests__/validations/validateResponseTransformation.spec.d.ts +2 -0
- package/dist/types/__tests__/validations/validateResponseTransformation.spec.d.ts.map +1 -0
- package/dist/types/index.d.ts +55 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/corvid-entity/index.d.ts +13 -0
- package/dist/types/lib/corvid-entity/index.d.ts.map +1 -0
- package/dist/types/lib/getArgumentCardinality.d.ts +3 -0
- package/dist/types/lib/getArgumentCardinality.d.ts.map +1 -0
- package/dist/types/lib/helpers.d.ts +28 -0
- package/dist/types/lib/helpers.d.ts.map +1 -0
- package/dist/types/lib/transformations/common.d.ts +15 -0
- package/dist/types/lib/transformations/common.d.ts.map +1 -0
- package/dist/types/lib/transformations/constants.d.ts +18 -0
- package/dist/types/lib/transformations/constants.d.ts.map +1 -0
- package/dist/types/lib/transformations/custom-functions.d.ts +13 -0
- package/dist/types/lib/transformations/custom-functions.d.ts.map +1 -0
- package/dist/types/lib/transformations/preset/create.d.ts +6 -0
- package/dist/types/lib/transformations/preset/create.d.ts.map +1 -0
- package/dist/types/lib/transformations/preset/delete.d.ts +7 -0
- package/dist/types/lib/transformations/preset/delete.d.ts.map +1 -0
- package/dist/types/lib/transformations/preset/get.d.ts +6 -0
- package/dist/types/lib/transformations/preset/get.d.ts.map +1 -0
- package/dist/types/lib/transformations/preset/list.d.ts +4 -0
- package/dist/types/lib/transformations/preset/list.d.ts.map +1 -0
- package/dist/types/lib/transformations/preset/query.d.ts +20 -0
- package/dist/types/lib/transformations/preset/query.d.ts.map +1 -0
- package/dist/types/lib/transformations/preset/update.d.ts +8 -0
- package/dist/types/lib/transformations/preset/update.d.ts.map +1 -0
- package/dist/types/lib/transformations/reduceTransformation.d.ts +6 -0
- package/dist/types/lib/transformations/reduceTransformation.d.ts.map +1 -0
- package/dist/types/lib/transformations/validations/common.d.ts +13 -0
- package/dist/types/lib/transformations/validations/common.d.ts.map +1 -0
- package/dist/types/lib/transformations/validations/validateRequestTransformation.d.ts +6 -0
- package/dist/types/lib/transformations/validations/validateRequestTransformation.d.ts.map +1 -0
- package/dist/types/lib/transformations/validations/validateResponseTransformation.d.ts +6 -0
- package/dist/types/lib/transformations/validations/validateResponseTransformation.d.ts.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _motionRuntimeTestContext = require("@wix/motion-runtime-test-context");
|
|
4
|
+
|
|
5
|
+
var _ = require("..");
|
|
6
|
+
|
|
7
|
+
var _corvidEntity = require("../lib/corvid-entity");
|
|
8
|
+
|
|
9
|
+
const toCorvidName = _.corvidEntities.toCorvidName,
|
|
10
|
+
fromCorvidName = _.corvidEntities.fromCorvidName;
|
|
11
|
+
describe('corvid entities transformers', () => {
|
|
12
|
+
describe('toCorvidName', () => {
|
|
13
|
+
test.each`
|
|
14
|
+
name | expected
|
|
15
|
+
${'id'} | ${'_id'}
|
|
16
|
+
${'createdDate'} | ${'_createdDate'}
|
|
17
|
+
${'updatedDate'} | ${'_updatedDate'}
|
|
18
|
+
`('adjusts $name to $expected', ({
|
|
19
|
+
name,
|
|
20
|
+
expected
|
|
21
|
+
}) => {
|
|
22
|
+
expect(toCorvidName(name)).toStrictEqual(expected);
|
|
23
|
+
});
|
|
24
|
+
test('returns the given name when it should not be changed', () => {
|
|
25
|
+
const name = (0, _motionRuntimeTestContext.aString)();
|
|
26
|
+
expect(toCorvidName(name)).toStrictEqual(name);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe('fromCorvidName', () => {
|
|
30
|
+
test.each`
|
|
31
|
+
name | expected
|
|
32
|
+
${'_id'} | ${'id'}
|
|
33
|
+
${'_createdDate'} | ${'createdDate'}
|
|
34
|
+
${'_updatedDate'} | ${'updatedDate'}
|
|
35
|
+
`('adjusts $name to $expected', ({
|
|
36
|
+
name,
|
|
37
|
+
expected
|
|
38
|
+
}) => {
|
|
39
|
+
expect(fromCorvidName(name)).toStrictEqual(expected);
|
|
40
|
+
});
|
|
41
|
+
test('returns the given name when it should not be changed', () => {
|
|
42
|
+
const name = (0, _motionRuntimeTestContext.aString)();
|
|
43
|
+
expect(fromCorvidName(name)).toStrictEqual(name);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe('internal methods', () => {
|
|
47
|
+
const nonReservedName = (0, _motionRuntimeTestContext.aString)();
|
|
48
|
+
describe('isReservedCorvidFieldName', () => {
|
|
49
|
+
test('returns true if the provided name is a reserved Corvid field-name', () => {
|
|
50
|
+
const reservedCorvidName = (0, _motionRuntimeTestContext.aRandomItemFrom)(['_id', '_createdDate', '_updatedDate']);
|
|
51
|
+
expect((0, _corvidEntity.isReservedCorvidFieldName)(reservedCorvidName)).toBeTruthy();
|
|
52
|
+
});
|
|
53
|
+
test('returns false if the provided name is not a reserved common field-name', () => {
|
|
54
|
+
expect((0, _corvidEntity.isReservedCorvidFieldName)(nonReservedName)).toBeFalsy();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('isReservedCommonFieldName', () => {
|
|
58
|
+
test('returns true if the provided name is a reserved common field-name', () => {
|
|
59
|
+
const commonReservedName = (0, _motionRuntimeTestContext.aRandomItemFrom)(['id', 'createdDate', 'updatedDate']);
|
|
60
|
+
expect((0, _corvidEntity.isReservedCommonFieldName)(commonReservedName)).toBeTruthy();
|
|
61
|
+
});
|
|
62
|
+
test('returns false if the provided name is not a reserved common field-name', () => {
|
|
63
|
+
expect((0, _corvidEntity.isReservedCommonFieldName)(nonReservedName)).toBeFalsy();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=corvid-entity.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/corvid-entity.spec.ts"],"names":["toCorvidName","corvidEntities","fromCorvidName","describe","test","each","name","expected","expect","toStrictEqual","nonReservedName","reservedCorvidName","toBeTruthy","toBeFalsy","commonReservedName"],"mappings":";;AAAA;;AACA;;AACA;;AAKA,MAAQA,YAAR,GAAyCC,gBAAzC,CAAQD,YAAR;AAAA,MAAsBE,cAAtB,GAAyCD,gBAAzC,CAAsBC,cAAtB;AAEAC,QAAQ,CAAC,8BAAD,EAAiC,MAAM;AAC7CA,EAAAA,QAAQ,CAAC,cAAD,EAAiB,MAAM;AAC7BC,IAAAA,IAAI,CAACC,IAAK;AACd;AACA,QAAQ,IAAK,eAAc,KAAM;AACjC,QAAQ,aAAc,MAAK,cAAe;AAC1C,QAAQ,aAAc,MAAK,cAAe;AAC1C,KALI,CAKE,4BALF,EAKgC,CAAC;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAAD,KAAwB;AACtDC,MAAAA,MAAM,CAACR,YAAY,CAACM,IAAD,CAAb,CAAN,CAA2BG,aAA3B,CAAyCF,QAAzC;AACD,KAPD;AASAH,IAAAA,IAAI,CAAC,sDAAD,EAAyD,MAAM;AACjE,YAAME,IAAI,GAAG,wCAAb;AAEAE,MAAAA,MAAM,CAACR,YAAY,CAACM,IAAD,CAAb,CAAN,CAA2BG,aAA3B,CAAyCH,IAAzC;AACD,KAJG,CAAJ;AAKD,GAfO,CAAR;AAiBAH,EAAAA,QAAQ,CAAC,gBAAD,EAAmB,MAAM;AAC/BC,IAAAA,IAAI,CAACC,IAAK;AACd;AACA,QAAQ,KAAM,eAAc,IAAK;AACjC,QAAQ,cAAe,MAAK,aAAc;AAC1C,QAAQ,cAAe,MAAK,aAAc;AAC1C,KALI,CAKE,4BALF,EAKgC,CAAC;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAAD,KAAwB;AACtDC,MAAAA,MAAM,CAACN,cAAc,CAACI,IAAD,CAAf,CAAN,CAA6BG,aAA7B,CAA2CF,QAA3C;AACD,KAPD;AASAH,IAAAA,IAAI,CAAC,sDAAD,EAAyD,MAAM;AACjE,YAAME,IAAI,GAAG,wCAAb;AAEAE,MAAAA,MAAM,CAACN,cAAc,CAACI,IAAD,CAAf,CAAN,CAA6BG,aAA7B,CAA2CH,IAA3C;AACD,KAJG,CAAJ;AAKD,GAfO,CAAR;AAiBAH,EAAAA,QAAQ,CAAC,kBAAD,EAAqB,MAAM;AACjC,UAAMO,eAAe,GAAG,wCAAxB;AAEAP,IAAAA,QAAQ,CAAC,2BAAD,EAA8B,MAAM;AAC1CC,MAAAA,IAAI,CAAC,mEAAD,EAAsE,MAAM;AAC9E,cAAMO,kBAAkB,GAAG,+CAAgB,CACzC,KADyC,EAEzC,cAFyC,EAGzC,cAHyC,CAAhB,CAA3B;AAMAH,QAAAA,MAAM,CAAC,6CAA0BG,kBAA1B,CAAD,CAAN,CAAsDC,UAAtD;AACD,OARG,CAAJ;AAUAR,MAAAA,IAAI,CAAC,wEAAD,EAA2E,MAAM;AACnFI,QAAAA,MAAM,CAAC,6CAA0BE,eAA1B,CAAD,CAAN,CAAmDG,SAAnD;AACD,OAFG,CAAJ;AAGD,KAdO,CAAR;AAgBAV,IAAAA,QAAQ,CAAC,2BAAD,EAA8B,MAAM;AAC1CC,MAAAA,IAAI,CAAC,mEAAD,EAAsE,MAAM;AAC9E,cAAMU,kBAAkB,GAAG,+CAAgB,CACzC,IADyC,EAEzC,aAFyC,EAGzC,aAHyC,CAAhB,CAA3B;AAMAN,QAAAA,MAAM,CAAC,6CAA0BM,kBAA1B,CAAD,CAAN,CAAsDF,UAAtD;AACD,OARG,CAAJ;AAUAR,MAAAA,IAAI,CAAC,wEAAD,EAA2E,MAAM;AACnFI,QAAAA,MAAM,CAAC,6CAA0BE,eAA1B,CAAD,CAAN,CAAmDG,SAAnD;AACD,OAFG,CAAJ;AAGD,KAdO,CAAR;AAeD,GAlCO,CAAR;AAmCD,CAtEO,CAAR","sourcesContent":["import { aString, aRandomItemFrom } from '@wix/motion-runtime-test-context';\nimport { corvidEntities } from '..';\nimport {\n isReservedCorvidFieldName,\n isReservedCommonFieldName,\n} from '../lib/corvid-entity';\n\nconst { toCorvidName, fromCorvidName } = corvidEntities;\n\ndescribe('corvid entities transformers', () => {\n describe('toCorvidName', () => {\n test.each`\n name | expected\n ${'id'} | ${'_id'}\n ${'createdDate'} | ${'_createdDate'}\n ${'updatedDate'} | ${'_updatedDate'}\n `('adjusts $name to $expected', ({ name, expected }) => {\n expect(toCorvidName(name)).toStrictEqual(expected);\n });\n\n test('returns the given name when it should not be changed', () => {\n const name = aString();\n\n expect(toCorvidName(name)).toStrictEqual(name);\n });\n });\n\n describe('fromCorvidName', () => {\n test.each`\n name | expected\n ${'_id'} | ${'id'}\n ${'_createdDate'} | ${'createdDate'}\n ${'_updatedDate'} | ${'updatedDate'}\n `('adjusts $name to $expected', ({ name, expected }) => {\n expect(fromCorvidName(name)).toStrictEqual(expected);\n });\n\n test('returns the given name when it should not be changed', () => {\n const name = aString();\n\n expect(fromCorvidName(name)).toStrictEqual(name);\n });\n });\n\n describe('internal methods', () => {\n const nonReservedName = aString();\n\n describe('isReservedCorvidFieldName', () => {\n test('returns true if the provided name is a reserved Corvid field-name', () => {\n const reservedCorvidName = aRandomItemFrom([\n '_id',\n '_createdDate',\n '_updatedDate',\n ]);\n\n expect(isReservedCorvidFieldName(reservedCorvidName)).toBeTruthy();\n });\n\n test('returns false if the provided name is not a reserved common field-name', () => {\n expect(isReservedCorvidFieldName(nonReservedName)).toBeFalsy();\n });\n });\n\n describe('isReservedCommonFieldName', () => {\n test('returns true if the provided name is a reserved common field-name', () => {\n const commonReservedName = aRandomItemFrom([\n 'id',\n 'createdDate',\n 'updatedDate',\n ]);\n\n expect(isReservedCommonFieldName(commonReservedName)).toBeTruthy();\n });\n\n test('returns false if the provided name is not a reserved common field-name', () => {\n expect(isReservedCommonFieldName(nonReservedName)).toBeFalsy();\n });\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _motionRuntimeTestContext = require("@wix/motion-runtime-test-context");
|
|
4
|
+
|
|
5
|
+
var _ = require("..");
|
|
6
|
+
|
|
7
|
+
describe('getArgumentCardinality', () => {
|
|
8
|
+
describe('simple transformation', () => {
|
|
9
|
+
const simpleTransformation = `$[${(0, _motionRuntimeTestContext.aNumber)({
|
|
10
|
+
min: 0,
|
|
11
|
+
max: 9
|
|
12
|
+
})}].${(0, _motionRuntimeTestContext.aString)()}`;
|
|
13
|
+
expect((0, _.getArgumentCardinality)(simpleTransformation)).toStrictEqual(1);
|
|
14
|
+
});
|
|
15
|
+
describe('complex transformations', () => {
|
|
16
|
+
const nonArgumentMapping = (0, _motionRuntimeTestContext.anObject)();
|
|
17
|
+
const argumentMapping = {
|
|
18
|
+
[(0, _motionRuntimeTestContext.aString)()]: '$[0].abc',
|
|
19
|
+
[(0, _motionRuntimeTestContext.aString)()]: '$[1].id',
|
|
20
|
+
[(0, _motionRuntimeTestContext.aString)()]: '$[2].a',
|
|
21
|
+
[(0, _motionRuntimeTestContext.aString)()]: '$[3].a.b.c',
|
|
22
|
+
...nonArgumentMapping
|
|
23
|
+
};
|
|
24
|
+
const argumentMappingArray = ['$[0].a', '$[1].b', 'a.b.c'];
|
|
25
|
+
test('counts the number of arguments referenced in a given transformation object', () => {
|
|
26
|
+
const complexMappingTransformation = { ...nonArgumentMapping,
|
|
27
|
+
...argumentMapping
|
|
28
|
+
};
|
|
29
|
+
expect((0, _.getArgumentCardinality)(complexMappingTransformation)).toStrictEqual(4);
|
|
30
|
+
});
|
|
31
|
+
test('counts the number of arguments referenced in a transformation object with arrays', () => {
|
|
32
|
+
const complexMappingTransformation = { ...nonArgumentMapping,
|
|
33
|
+
[(0, _motionRuntimeTestContext.aString)()]: argumentMappingArray
|
|
34
|
+
};
|
|
35
|
+
expect((0, _.getArgumentCardinality)(complexMappingTransformation)).toStrictEqual(2);
|
|
36
|
+
});
|
|
37
|
+
test('counts only unique occurrences', () => {
|
|
38
|
+
const complexMappingTransformation = { ...nonArgumentMapping,
|
|
39
|
+
...argumentMapping,
|
|
40
|
+
[(0, _motionRuntimeTestContext.aString)()]: argumentMappingArray
|
|
41
|
+
};
|
|
42
|
+
expect((0, _.getArgumentCardinality)(complexMappingTransformation)).toStrictEqual(4);
|
|
43
|
+
});
|
|
44
|
+
test('does not fail on special transformation cases', () => {
|
|
45
|
+
const specialTransformation = {
|
|
46
|
+
[(0, _motionRuntimeTestContext.aString)()]: {
|
|
47
|
+
'@constant': true
|
|
48
|
+
},
|
|
49
|
+
[(0, _motionRuntimeTestContext.aString)()]: {
|
|
50
|
+
'@constant': null
|
|
51
|
+
},
|
|
52
|
+
[(0, _motionRuntimeTestContext.aString)()]: '$[0].a.b.c.'
|
|
53
|
+
};
|
|
54
|
+
expect((0, _.getArgumentCardinality)(specialTransformation)).toStrictEqual(1);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=getArgumentCardinality.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/getArgumentCardinality.spec.ts"],"names":["describe","simpleTransformation","min","max","expect","toStrictEqual","nonArgumentMapping","argumentMapping","argumentMappingArray","test","complexMappingTransformation","specialTransformation"],"mappings":";;AAAA;;AACA;;AAEAA,QAAQ,CAAC,wBAAD,EAA2B,MAAM;AACvCA,EAAAA,QAAQ,CAAC,uBAAD,EAA0B,MAAM;AACtC,UAAMC,oBAAoB,GAAI,KAAI,uCAAQ;AACxCC,MAAAA,GAAG,EAAE,CADmC;AAExCC,MAAAA,GAAG,EAAE;AAFmC,KAAR,CAG/B,KAAI,wCAAU,EAHjB;AAKAC,IAAAA,MAAM,CAAC,8BAAuBH,oBAAvB,CAAD,CAAN,CAAqDI,aAArD,CAAmE,CAAnE;AACD,GAPO,CAAR;AASAL,EAAAA,QAAQ,CAAC,yBAAD,EAA4B,MAAM;AACxC,UAAMM,kBAAkB,GAAG,yCAA3B;AAEA,UAAMC,eAAe,GAAG;AACtB,OAAC,wCAAD,GAAa,UADS;AAEtB,OAAC,wCAAD,GAAa,SAFS;AAGtB,OAAC,wCAAD,GAAa,QAHS;AAItB,OAAC,wCAAD,GAAa,YAJS;AAKtB,SAAGD;AALmB,KAAxB;AAQA,UAAME,oBAAoB,GAAG,CAAC,QAAD,EAAW,QAAX,EAAqB,OAArB,CAA7B;AAEAC,IAAAA,IAAI,CAAC,4EAAD,EAA+E,MAAM;AACvF,YAAMC,4BAA4B,GAAG,EACnC,GAAGJ,kBADgC;AAEnC,WAAGC;AAFgC,OAArC;AAKAH,MAAAA,MAAM,CACJ,8BAAuBM,4BAAvB,CADI,CAAN,CAEEL,aAFF,CAEgB,CAFhB;AAGD,KATG,CAAJ;AAWAI,IAAAA,IAAI,CAAC,kFAAD,EAAqF,MAAM;AAC7F,YAAMC,4BAA4B,GAAG,EACnC,GAAGJ,kBADgC;AAEnC,SAAC,wCAAD,GAAaE;AAFsB,OAArC;AAKAJ,MAAAA,MAAM,CACJ,8BAAuBM,4BAAvB,CADI,CAAN,CAEEL,aAFF,CAEgB,CAFhB;AAGD,KATG,CAAJ;AAWAI,IAAAA,IAAI,CAAC,gCAAD,EAAmC,MAAM;AAC3C,YAAMC,4BAA4B,GAAG,EACnC,GAAGJ,kBADgC;AAEnC,WAAGC,eAFgC;AAGnC,SAAC,wCAAD,GAAaC;AAHsB,OAArC;AAMAJ,MAAAA,MAAM,CACJ,8BAAuBM,4BAAvB,CADI,CAAN,CAEEL,aAFF,CAEgB,CAFhB;AAGD,KAVG,CAAJ;AAYAI,IAAAA,IAAI,CAAC,+CAAD,EAAkD,MAAM;AAC1D,YAAME,qBAAqB,GAAG;AAC5B,SAAC,wCAAD,GAAa;AAAE,uBAAa;AAAf,SADe;AAE5B,SAAC,wCAAD,GAAa;AAAE,uBAAa;AAAf,SAFe;AAG5B,SAAC,wCAAD,GAAa;AAHe,OAA9B;AAMAP,MAAAA,MAAM,CAAC,8BAAuBO,qBAAvB,CAAD,CAAN,CAAsDN,aAAtD,CAAoE,CAApE;AACD,KARG,CAAJ;AASD,GAxDO,CAAR;AAyDD,CAnEO,CAAR","sourcesContent":["import { aNumber, aString, anObject } from '@wix/motion-runtime-test-context';\nimport { getArgumentCardinality } from '..';\n\ndescribe('getArgumentCardinality', () => {\n describe('simple transformation', () => {\n const simpleTransformation = `$[${aNumber({\n min: 0,\n max: 9,\n })}].${aString()}`;\n\n expect(getArgumentCardinality(simpleTransformation)).toStrictEqual(1);\n });\n\n describe('complex transformations', () => {\n const nonArgumentMapping = anObject();\n\n const argumentMapping = {\n [aString()]: '$[0].abc',\n [aString()]: '$[1].id',\n [aString()]: '$[2].a',\n [aString()]: '$[3].a.b.c',\n ...nonArgumentMapping,\n };\n\n const argumentMappingArray = ['$[0].a', '$[1].b', 'a.b.c'];\n\n test('counts the number of arguments referenced in a given transformation object', () => {\n const complexMappingTransformation = {\n ...nonArgumentMapping,\n ...argumentMapping,\n };\n\n expect(\n getArgumentCardinality(complexMappingTransformation),\n ).toStrictEqual(4);\n });\n\n test('counts the number of arguments referenced in a transformation object with arrays', () => {\n const complexMappingTransformation = {\n ...nonArgumentMapping,\n [aString()]: argumentMappingArray,\n };\n\n expect(\n getArgumentCardinality(complexMappingTransformation),\n ).toStrictEqual(2);\n });\n\n test('counts only unique occurrences', () => {\n const complexMappingTransformation = {\n ...nonArgumentMapping,\n ...argumentMapping,\n [aString()]: argumentMappingArray,\n };\n\n expect(\n getArgumentCardinality(complexMappingTransformation),\n ).toStrictEqual(4);\n });\n\n test('does not fail on special transformation cases', () => {\n const specialTransformation = {\n [aString()]: { '@constant': true },\n [aString()]: { '@constant': null },\n [aString()]: '$[0].a.b.c.',\n };\n\n expect(getArgumentCardinality(specialTransformation)).toStrictEqual(1);\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _motionEdmAutogenTestContext = require("@wix/motion-edm-autogen-test-context");
|
|
4
|
+
|
|
5
|
+
var _motionRuntimeTestContext = require("@wix/motion-runtime-test-context");
|
|
6
|
+
|
|
7
|
+
var _lodash = require("lodash");
|
|
8
|
+
|
|
9
|
+
var _helpers = require("../lib/helpers");
|
|
10
|
+
|
|
11
|
+
describe('helper functions', () => {
|
|
12
|
+
const index = (0, _motionRuntimeTestContext.aNumber)({
|
|
13
|
+
min: 0,
|
|
14
|
+
max: 1
|
|
15
|
+
}); // @ts-expect-error
|
|
16
|
+
|
|
17
|
+
const nestedPath = (0, _lodash.times)(3, (0, _motionRuntimeTestContext.aString)()).join('.');
|
|
18
|
+
const simpleTransformation = `$[${index}]`;
|
|
19
|
+
const simpleTransformationWithNestedPath = `$[${index}].${nestedPath}`;
|
|
20
|
+
describe('isSimpleTransformation', () => {
|
|
21
|
+
test.each`
|
|
22
|
+
transformation | expectedValue | transformationType
|
|
23
|
+
${(0, _motionEdmAutogenTestContext.aSimpleMappingTransformation)().simpleMapping} | ${true} | ${'simple'}
|
|
24
|
+
${(0, _motionEdmAutogenTestContext.aComplexMappingTransformation)().complexMapping} | ${false} | ${'complex'}
|
|
25
|
+
`('returns $expectedValue for $transformationType transformation', ({
|
|
26
|
+
transformation,
|
|
27
|
+
expectedValue
|
|
28
|
+
}) => {
|
|
29
|
+
expect((0, _helpers.isSimpleTransformation)(transformation)).toStrictEqual(expectedValue);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('extractIndexAndPath', () => {
|
|
33
|
+
test('extracts the index and nested-path of the argument from a simple tranformation', () => {
|
|
34
|
+
expect((0, _helpers.extractIndexAndPath)(simpleTransformationWithNestedPath)).toStrictEqual({
|
|
35
|
+
index,
|
|
36
|
+
nestedPath
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
test('sets the nestedPath to null when one could not be found', () => {
|
|
40
|
+
expect((0, _helpers.extractIndexAndPath)(simpleTransformation)).toStrictEqual({
|
|
41
|
+
index,
|
|
42
|
+
nestedPath: null
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe('getArgumentIndex', () => {
|
|
47
|
+
test('extracts the index of an argument within a jsonpath', () => {
|
|
48
|
+
expect((0, _helpers.getArgumentIndex)(simpleTransformation)).toStrictEqual(index);
|
|
49
|
+
});
|
|
50
|
+
test('return null when no index was found', () => {
|
|
51
|
+
expect((0, _helpers.getArgumentIndex)((0, _motionRuntimeTestContext.aString)())).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
describe('isJsonPathExpression', () => {
|
|
55
|
+
test.each`
|
|
56
|
+
description | expression | expectedResult
|
|
57
|
+
${'starts with $'} | ${(0, _motionEdmAutogenTestContext.aRandomJsonPath)()} | ${true}
|
|
58
|
+
${'does not start with $'} | ${(0, _motionRuntimeTestContext.aString)()} | ${false}
|
|
59
|
+
`('return $expectedResult when the expression $description', ({
|
|
60
|
+
expression,
|
|
61
|
+
expectedResult
|
|
62
|
+
}) => {
|
|
63
|
+
expect((0, _helpers.isJsonPathExpression)(expression)).toStrictEqual(expectedResult);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
describe('stripJsonPathRootPrefix', () => {
|
|
67
|
+
const nonJsonPathString = (0, _motionRuntimeTestContext.aString)();
|
|
68
|
+
const jsonPath = (0, _motionEdmAutogenTestContext.aRandomResponseTransformationJsonPath)();
|
|
69
|
+
test.each`
|
|
70
|
+
description | expression | expectedResult
|
|
71
|
+
${'is $'} | ${'$'} | ${'$'}
|
|
72
|
+
${'does not start with $'} | ${nonJsonPathString} | ${nonJsonPathString}
|
|
73
|
+
${'starts with $.'} | ${jsonPath} | ${jsonPath.slice(2)}
|
|
74
|
+
`('return $expectedResult when the expression $description', ({
|
|
75
|
+
expression,
|
|
76
|
+
expectedResult
|
|
77
|
+
}) => {
|
|
78
|
+
expect((0, _helpers.stripJsonPathRootPrefix)(expression)).toStrictEqual(expectedResult);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
describe('isInvalidJsonValue', () => {
|
|
82
|
+
test('returns true for an invalid json-value', () => {
|
|
83
|
+
expect((0, _helpers.isInvalidJsonValue)('x-y-z')).toBeTruthy();
|
|
84
|
+
});
|
|
85
|
+
test('returns false for a valid json-value', () => {
|
|
86
|
+
expect((0, _helpers.isInvalidJsonValue)('"string"')).toBeFalsy();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=helpers.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/helpers.spec.ts"],"names":["describe","index","min","max","nestedPath","join","simpleTransformation","simpleTransformationWithNestedPath","test","each","simpleMapping","complexMapping","transformation","expectedValue","expect","toStrictEqual","toBeNull","expression","expectedResult","nonJsonPathString","jsonPath","slice","toBeTruthy","toBeFalsy"],"mappings":"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","sourcesContent":["import {\n aSimpleMappingTransformation,\n aComplexMappingTransformation,\n aRandomJsonPath,\n aRandomResponseTransformationJsonPath,\n} from '@wix/motion-edm-autogen-test-context';\nimport { aNumber, aString } from '@wix/motion-runtime-test-context';\nimport { times } from 'lodash';\nimport {\n isSimpleTransformation,\n extractIndexAndPath,\n getArgumentIndex,\n isJsonPathExpression,\n stripJsonPathRootPrefix,\n isInvalidJsonValue,\n} from '../lib/helpers';\n\ndescribe('helper functions', () => {\n const index = aNumber({ min: 0, max: 1 });\n // @ts-expect-error\n const nestedPath = times(3, aString()).join('.');\n const simpleTransformation = `$[${index}]`;\n const simpleTransformationWithNestedPath = `$[${index}].${nestedPath}`;\n\n describe('isSimpleTransformation', () => {\n test.each`\n transformation | expectedValue | transformationType\n ${aSimpleMappingTransformation().simpleMapping} | ${true} | ${'simple'}\n ${aComplexMappingTransformation().complexMapping} | ${false} | ${'complex'}\n `(\n 'returns $expectedValue for $transformationType transformation',\n ({ transformation, expectedValue }) => {\n expect(isSimpleTransformation(transformation)).toStrictEqual(\n expectedValue,\n );\n },\n );\n });\n\n describe('extractIndexAndPath', () => {\n test('extracts the index and nested-path of the argument from a simple tranformation', () => {\n expect(\n extractIndexAndPath(simpleTransformationWithNestedPath),\n ).toStrictEqual({ index, nestedPath });\n });\n\n test('sets the nestedPath to null when one could not be found', () => {\n expect(extractIndexAndPath(simpleTransformation)).toStrictEqual({\n index,\n nestedPath: null,\n });\n });\n });\n\n describe('getArgumentIndex', () => {\n test('extracts the index of an argument within a jsonpath', () => {\n expect(getArgumentIndex(simpleTransformation)).toStrictEqual(index);\n });\n\n test('return null when no index was found', () => {\n expect(getArgumentIndex(aString())).toBeNull();\n });\n });\n\n describe('isJsonPathExpression', () => {\n test.each`\n description | expression | expectedResult\n ${'starts with $'} | ${aRandomJsonPath()} | ${true}\n ${'does not start with $'} | ${aString()} | ${false}\n `(\n 'return $expectedResult when the expression $description',\n ({ expression, expectedResult }) => {\n expect(isJsonPathExpression(expression)).toStrictEqual(expectedResult);\n },\n );\n });\n\n describe('stripJsonPathRootPrefix', () => {\n const nonJsonPathString = aString();\n const jsonPath = aRandomResponseTransformationJsonPath();\n\n test.each`\n description | expression | expectedResult\n ${'is $'} | ${'$'} | ${'$'}\n ${'does not start with $'} | ${nonJsonPathString} | ${nonJsonPathString}\n ${'starts with $.'} | ${jsonPath} | ${jsonPath.slice(2)}\n `(\n 'return $expectedResult when the expression $description',\n ({ expression, expectedResult }) => {\n expect(stripJsonPathRootPrefix(expression)).toStrictEqual(\n expectedResult,\n );\n },\n );\n });\n\n describe('isInvalidJsonValue', () => {\n test('returns true for an invalid json-value', () => {\n expect(isInvalidJsonValue('x-y-z')).toBeTruthy();\n });\n\n test('returns false for a valid json-value', () => {\n expect(isInvalidJsonValue('\"string\"')).toBeFalsy();\n });\n });\n});\n"]}
|