@vived/app 5.0.4 → 5.0.5
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/Label/Controller/index.js +2 -1
- package/dist/cjs/Label/Controller/index.js.map +1 -1
- package/dist/cjs/Label/Controller/submitCustomLabel.js +18 -0
- package/dist/cjs/Label/Controller/submitCustomLabel.js.map +1 -0
- package/dist/cjs/Label/Controller/submitCustomLabel.test.js +39 -0
- package/dist/cjs/Label/Controller/submitCustomLabel.test.js.map +1 -0
- package/dist/cjs/Label/Controller/updateCustomLabel.js +18 -0
- package/dist/cjs/Label/Controller/updateCustomLabel.js.map +1 -0
- package/dist/cjs/Label/Controller/updateCustomLabel.test.js +39 -0
- package/dist/cjs/Label/Controller/updateCustomLabel.test.js.map +1 -0
- package/dist/cjs/Label/UC/SetCustomLabelUC.js +13 -3
- package/dist/cjs/Label/UC/SetCustomLabelUC.js.map +1 -1
- package/dist/cjs/Label/UC/SetCustomLabelUC.test.js +14 -6
- package/dist/cjs/Label/UC/SetCustomLabelUC.test.js.map +1 -1
- package/dist/esm/Label/Controller/index.js +2 -1
- package/dist/esm/Label/Controller/index.js.map +1 -1
- package/dist/esm/Label/Controller/submitCustomLabel.js +15 -0
- package/dist/esm/Label/Controller/submitCustomLabel.js.map +1 -0
- package/dist/esm/Label/Controller/submitCustomLabel.test.js +37 -0
- package/dist/esm/Label/Controller/submitCustomLabel.test.js.map +1 -0
- package/dist/esm/Label/Controller/updateCustomLabel.js +15 -0
- package/dist/esm/Label/Controller/updateCustomLabel.js.map +1 -0
- package/dist/esm/Label/Controller/updateCustomLabel.test.js +37 -0
- package/dist/esm/Label/Controller/updateCustomLabel.test.js.map +1 -0
- package/dist/esm/Label/UC/SetCustomLabelUC.js +13 -3
- package/dist/esm/Label/UC/SetCustomLabelUC.js.map +1 -1
- package/dist/esm/Label/UC/SetCustomLabelUC.test.js +14 -6
- package/dist/esm/Label/UC/SetCustomLabelUC.test.js.map +1 -1
- package/dist/types/Label/Controller/index.d.ts +2 -1
- package/dist/types/Label/Controller/index.d.ts.map +1 -1
- package/dist/types/Label/Controller/submitCustomLabel.d.ts +3 -0
- package/dist/types/Label/Controller/submitCustomLabel.d.ts.map +1 -0
- package/dist/types/Label/Controller/submitCustomLabel.test.d.ts +2 -0
- package/dist/types/Label/Controller/submitCustomLabel.test.d.ts.map +1 -0
- package/dist/types/Label/Controller/updateCustomLabel.d.ts +3 -0
- package/dist/types/Label/Controller/updateCustomLabel.d.ts.map +1 -0
- package/dist/types/Label/Controller/updateCustomLabel.test.d.ts +2 -0
- package/dist/types/Label/Controller/updateCustomLabel.test.d.ts.map +1 -0
- package/dist/types/Label/UC/SetCustomLabelUC.d.ts +3 -1
- package/dist/types/Label/UC/SetCustomLabelUC.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -15,5 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./ClearCustomLabel"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./updateCustomLabel"), exports);
|
|
19
|
+
__exportStar(require("./submitCustomLabel"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Label/Controller/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Label/Controller/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,sDAAoC;AACpC,sDAAoC","sourcesContent":["export * from \"./ClearCustomLabel\";\r\nexport * from \"./updateCustomLabel\";\r\nexport * from \"./submitCustomLabel\";\r\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.submitCustomLabel = submitCustomLabel;
|
|
4
|
+
const SetCustomLabelUC_1 = require("../UC/SetCustomLabelUC");
|
|
5
|
+
function submitCustomLabel(appObjectID, appObjectRepo) {
|
|
6
|
+
const appObject = appObjectRepo.get(appObjectID);
|
|
7
|
+
if (!appObject) {
|
|
8
|
+
appObjectRepo.submitWarning("submitCustomLabel Contorller", "App Object not found");
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const setCustomLabelUC = SetCustomLabelUC_1.SetCustomLabelUC.get(appObject);
|
|
12
|
+
if (!setCustomLabelUC) {
|
|
13
|
+
appObjectRepo.submitWarning("submitCustomLabel Controller", "SetCustomLabelUC was not added to App Object");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
setCustomLabelUC.submit();
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=submitCustomLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submitCustomLabel.js","sourceRoot":"","sources":["../../../../src/Label/Controller/submitCustomLabel.ts"],"names":[],"mappings":";;AAGA,8CAuBC;AAzBD,6DAA0D;AAE1D,SAAgB,iBAAiB,CAC/B,WAAmB,EACnB,aAA4B;IAE5B,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACjD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,aAAa,CAAC,aAAa,CACzB,8BAA8B,EAC9B,sBAAsB,CACvB,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,gBAAgB,GAAG,mCAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACzD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,aAAa,CAAC,aAAa,CACzB,8BAA8B,EAC9B,8CAA8C,CAC/C,CAAC;QACF,OAAO;IACT,CAAC;IAED,gBAAgB,CAAC,MAAM,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import { AppObjectRepo } from \"@vived/core\";\r\nimport { SetCustomLabelUC } from \"../UC/SetCustomLabelUC\";\r\n\r\nexport function submitCustomLabel(\r\n appObjectID: string,\r\n appObjectRepo: AppObjectRepo\r\n) {\r\n const appObject = appObjectRepo.get(appObjectID);\r\n if (!appObject) {\r\n appObjectRepo.submitWarning(\r\n \"submitCustomLabel Contorller\",\r\n \"App Object not found\"\r\n );\r\n return;\r\n }\r\n\r\n const setCustomLabelUC = SetCustomLabelUC.get(appObject);\r\n if (!setCustomLabelUC) {\r\n appObjectRepo.submitWarning(\r\n \"submitCustomLabel Controller\",\r\n \"SetCustomLabelUC was not added to App Object\"\r\n );\r\n return;\r\n }\r\n\r\n setCustomLabelUC.submit();\r\n}\r\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@vived/core");
|
|
4
|
+
const SetCustomLabelUC_1 = require("../UC/SetCustomLabelUC");
|
|
5
|
+
const submitCustomLabel_1 = require("./submitCustomLabel");
|
|
6
|
+
function makeTestRig() {
|
|
7
|
+
const appObjects = (0, core_1.makeAppObjectRepo)();
|
|
8
|
+
const mockSubmitWarning = jest.fn();
|
|
9
|
+
appObjects.submitWarning = mockSubmitWarning;
|
|
10
|
+
const ao = appObjects.getOrCreate("App Object ID");
|
|
11
|
+
const clearCustomLabelUC = new SetCustomLabelUC_1.SetCustomLabelUC(ao);
|
|
12
|
+
const mockSubmitCustomLabel = jest.fn();
|
|
13
|
+
clearCustomLabelUC.submit = mockSubmitCustomLabel;
|
|
14
|
+
return {
|
|
15
|
+
appObjects,
|
|
16
|
+
ao,
|
|
17
|
+
mockSubmitWarning,
|
|
18
|
+
mockSubmitCustomLabel,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
describe("Submit Custom Label Controller", () => {
|
|
22
|
+
it("Calls Submit Custom Label method", () => {
|
|
23
|
+
const { appObjects, ao, mockSubmitCustomLabel } = makeTestRig();
|
|
24
|
+
(0, submitCustomLabel_1.submitCustomLabel)(ao.id, appObjects);
|
|
25
|
+
expect(mockSubmitCustomLabel).toHaveBeenCalled();
|
|
26
|
+
});
|
|
27
|
+
it("Submits warning if App Object is not found", () => {
|
|
28
|
+
const { appObjects, mockSubmitWarning } = makeTestRig();
|
|
29
|
+
(0, submitCustomLabel_1.submitCustomLabel)("TEST AO", appObjects);
|
|
30
|
+
expect(mockSubmitWarning).toHaveBeenCalled();
|
|
31
|
+
});
|
|
32
|
+
it("Submits warning if SetCustomLabel UC was not added", () => {
|
|
33
|
+
const { appObjects, mockSubmitWarning } = makeTestRig();
|
|
34
|
+
const ao = appObjects.getOrCreate("TEST AO");
|
|
35
|
+
(0, submitCustomLabel_1.submitCustomLabel)(ao.id, appObjects);
|
|
36
|
+
expect(mockSubmitWarning).toHaveBeenCalled();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=submitCustomLabel.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submitCustomLabel.test.js","sourceRoot":"","sources":["../../../../src/Label/Controller/submitCustomLabel.test.ts"],"names":[],"mappings":";;AAAA,sCAAgD;AAChD,6DAA0D;AAC1D,2DAAwD;AAExD,SAAS,WAAW;IAClB,MAAM,UAAU,GAAG,IAAA,wBAAiB,GAAE,CAAC;IAEvC,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IACpC,UAAU,CAAC,aAAa,GAAG,iBAAiB,CAAC;IAE7C,MAAM,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAEnD,MAAM,kBAAkB,GAAG,IAAI,mCAAgB,CAAC,EAAE,CAAC,CAAC;IACpD,MAAM,qBAAqB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IACxC,kBAAkB,CAAC,MAAM,GAAG,qBAAqB,CAAC;IAElD,OAAO;QACL,UAAU;QACV,EAAE;QACF,iBAAiB;QACjB,qBAAqB;KACtB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,qBAAqB,EAAE,GAAG,WAAW,EAAE,CAAC;QAEhE,IAAA,qCAAiB,EAAC,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QAErC,MAAM,CAAC,qBAAqB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE,CAAC;QAExD,IAAA,qCAAiB,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAEzC,MAAM,CAAC,iBAAiB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE,CAAC;QACxD,MAAM,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAE7C,IAAA,qCAAiB,EAAC,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QAErC,MAAM,CAAC,iBAAiB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { makeAppObjectRepo } from \"@vived/core\";\r\nimport { SetCustomLabelUC } from \"../UC/SetCustomLabelUC\";\r\nimport { submitCustomLabel } from \"./submitCustomLabel\";\r\n\r\nfunction makeTestRig() {\r\n const appObjects = makeAppObjectRepo();\r\n\r\n const mockSubmitWarning = jest.fn();\r\n appObjects.submitWarning = mockSubmitWarning;\r\n\r\n const ao = appObjects.getOrCreate(\"App Object ID\");\r\n\r\n const clearCustomLabelUC = new SetCustomLabelUC(ao);\r\n const mockSubmitCustomLabel = jest.fn();\r\n clearCustomLabelUC.submit = mockSubmitCustomLabel;\r\n\r\n return {\r\n appObjects,\r\n ao,\r\n mockSubmitWarning,\r\n mockSubmitCustomLabel,\r\n };\r\n}\r\n\r\ndescribe(\"Submit Custom Label Controller\", () => {\r\n it(\"Calls Submit Custom Label method\", () => {\r\n const { appObjects, ao, mockSubmitCustomLabel } = makeTestRig();\r\n\r\n submitCustomLabel(ao.id, appObjects);\r\n\r\n expect(mockSubmitCustomLabel).toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits warning if App Object is not found\", () => {\r\n const { appObjects, mockSubmitWarning } = makeTestRig();\r\n\r\n submitCustomLabel(\"TEST AO\", appObjects);\r\n\r\n expect(mockSubmitWarning).toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits warning if SetCustomLabel UC was not added\", () => {\r\n const { appObjects, mockSubmitWarning } = makeTestRig();\r\n const ao = appObjects.getOrCreate(\"TEST AO\");\r\n\r\n submitCustomLabel(ao.id, appObjects);\r\n\r\n expect(mockSubmitWarning).toHaveBeenCalled();\r\n });\r\n});\r\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateCustomLabel = updateCustomLabel;
|
|
4
|
+
const SetCustomLabelUC_1 = require("../UC/SetCustomLabelUC");
|
|
5
|
+
function updateCustomLabel(customLabel, appObjectID, appObjectRepo) {
|
|
6
|
+
const appObject = appObjectRepo.get(appObjectID);
|
|
7
|
+
if (!appObject) {
|
|
8
|
+
appObjectRepo.submitWarning("updateCustomLabel Contorller", "App Object not found");
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const setCustomLabelUC = SetCustomLabelUC_1.SetCustomLabelUC.get(appObject);
|
|
12
|
+
if (!setCustomLabelUC) {
|
|
13
|
+
appObjectRepo.submitWarning("updateCustomLabel Controller", "SetCustomLabelUC was not added to App Object");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
setCustomLabelUC.update(customLabel);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=updateCustomLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCustomLabel.js","sourceRoot":"","sources":["../../../../src/Label/Controller/updateCustomLabel.ts"],"names":[],"mappings":";;AAGA,8CAwBC;AA1BD,6DAA0D;AAE1D,SAAgB,iBAAiB,CAC/B,WAAmB,EACnB,WAAmB,EACnB,aAA4B;IAE5B,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACjD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,aAAa,CAAC,aAAa,CACzB,8BAA8B,EAC9B,sBAAsB,CACvB,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,gBAAgB,GAAG,mCAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACzD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,aAAa,CAAC,aAAa,CACzB,8BAA8B,EAC9B,8CAA8C,CAC/C,CAAC;QACF,OAAO;IACT,CAAC;IAED,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { AppObjectRepo } from \"@vived/core\";\r\nimport { SetCustomLabelUC } from \"../UC/SetCustomLabelUC\";\r\n\r\nexport function updateCustomLabel(\r\n customLabel: string,\r\n appObjectID: string,\r\n appObjectRepo: AppObjectRepo\r\n) {\r\n const appObject = appObjectRepo.get(appObjectID);\r\n if (!appObject) {\r\n appObjectRepo.submitWarning(\r\n \"updateCustomLabel Contorller\",\r\n \"App Object not found\"\r\n );\r\n return;\r\n }\r\n\r\n const setCustomLabelUC = SetCustomLabelUC.get(appObject);\r\n if (!setCustomLabelUC) {\r\n appObjectRepo.submitWarning(\r\n \"updateCustomLabel Controller\",\r\n \"SetCustomLabelUC was not added to App Object\"\r\n );\r\n return;\r\n }\r\n\r\n setCustomLabelUC.update(customLabel);\r\n}\r\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@vived/core");
|
|
4
|
+
const SetCustomLabelUC_1 = require("../UC/SetCustomLabelUC");
|
|
5
|
+
const updateCustomLabel_1 = require("./updateCustomLabel");
|
|
6
|
+
function makeTestRig() {
|
|
7
|
+
const appObjects = (0, core_1.makeAppObjectRepo)();
|
|
8
|
+
const mockSubmitWarning = jest.fn();
|
|
9
|
+
appObjects.submitWarning = mockSubmitWarning;
|
|
10
|
+
const ao = appObjects.getOrCreate("App Object ID");
|
|
11
|
+
const clearCustomLabelUC = new SetCustomLabelUC_1.SetCustomLabelUC(ao);
|
|
12
|
+
const mockUpdateCustomLabel = jest.fn();
|
|
13
|
+
clearCustomLabelUC.update = mockUpdateCustomLabel;
|
|
14
|
+
return {
|
|
15
|
+
appObjects,
|
|
16
|
+
ao,
|
|
17
|
+
mockSubmitWarning,
|
|
18
|
+
mockUpdateCustomLabel,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
describe("Update Custom Label Controller", () => {
|
|
22
|
+
it("Calls Set Custom Label method", () => {
|
|
23
|
+
const { appObjects, ao, mockUpdateCustomLabel } = makeTestRig();
|
|
24
|
+
(0, updateCustomLabel_1.updateCustomLabel)("custom", ao.id, appObjects);
|
|
25
|
+
expect(mockUpdateCustomLabel).toHaveBeenCalled();
|
|
26
|
+
});
|
|
27
|
+
it("Submits warning if App Object is not found", () => {
|
|
28
|
+
const { appObjects, mockSubmitWarning } = makeTestRig();
|
|
29
|
+
(0, updateCustomLabel_1.updateCustomLabel)("custom", "TEST AO", appObjects);
|
|
30
|
+
expect(mockSubmitWarning).toHaveBeenCalled();
|
|
31
|
+
});
|
|
32
|
+
it("Submits warning if SetCustomLabel UC was not added", () => {
|
|
33
|
+
const { appObjects, mockSubmitWarning } = makeTestRig();
|
|
34
|
+
const ao = appObjects.getOrCreate("TEST AO");
|
|
35
|
+
(0, updateCustomLabel_1.updateCustomLabel)("custom", ao.id, appObjects);
|
|
36
|
+
expect(mockSubmitWarning).toHaveBeenCalled();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=updateCustomLabel.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCustomLabel.test.js","sourceRoot":"","sources":["../../../../src/Label/Controller/updateCustomLabel.test.ts"],"names":[],"mappings":";;AAAA,sCAAgD;AAChD,6DAA0D;AAC1D,2DAAwD;AAExD,SAAS,WAAW;IAClB,MAAM,UAAU,GAAG,IAAA,wBAAiB,GAAE,CAAC;IAEvC,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IACpC,UAAU,CAAC,aAAa,GAAG,iBAAiB,CAAC;IAE7C,MAAM,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAEnD,MAAM,kBAAkB,GAAG,IAAI,mCAAgB,CAAC,EAAE,CAAC,CAAC;IACpD,MAAM,qBAAqB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IACxC,kBAAkB,CAAC,MAAM,GAAG,qBAAqB,CAAC;IAElD,OAAO;QACL,UAAU;QACV,EAAE;QACF,iBAAiB;QACjB,qBAAqB;KACtB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,qBAAqB,EAAE,GAAG,WAAW,EAAE,CAAC;QAEhE,IAAA,qCAAiB,EAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QAE/C,MAAM,CAAC,qBAAqB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE,CAAC;QAExD,IAAA,qCAAiB,EAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QAEnD,MAAM,CAAC,iBAAiB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE,CAAC;QACxD,MAAM,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAE7C,IAAA,qCAAiB,EAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QAE/C,MAAM,CAAC,iBAAiB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { makeAppObjectRepo } from \"@vived/core\";\r\nimport { SetCustomLabelUC } from \"../UC/SetCustomLabelUC\";\r\nimport { updateCustomLabel } from \"./updateCustomLabel\";\r\n\r\nfunction makeTestRig() {\r\n const appObjects = makeAppObjectRepo();\r\n\r\n const mockSubmitWarning = jest.fn();\r\n appObjects.submitWarning = mockSubmitWarning;\r\n\r\n const ao = appObjects.getOrCreate(\"App Object ID\");\r\n\r\n const clearCustomLabelUC = new SetCustomLabelUC(ao);\r\n const mockUpdateCustomLabel = jest.fn();\r\n clearCustomLabelUC.update = mockUpdateCustomLabel;\r\n\r\n return {\r\n appObjects,\r\n ao,\r\n mockSubmitWarning,\r\n mockUpdateCustomLabel,\r\n };\r\n}\r\n\r\ndescribe(\"Update Custom Label Controller\", () => {\r\n it(\"Calls Set Custom Label method\", () => {\r\n const { appObjects, ao, mockUpdateCustomLabel } = makeTestRig();\r\n\r\n updateCustomLabel(\"custom\", ao.id, appObjects);\r\n\r\n expect(mockUpdateCustomLabel).toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits warning if App Object is not found\", () => {\r\n const { appObjects, mockSubmitWarning } = makeTestRig();\r\n\r\n updateCustomLabel(\"custom\", \"TEST AO\", appObjects);\r\n\r\n expect(mockSubmitWarning).toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits warning if SetCustomLabel UC was not added\", () => {\r\n const { appObjects, mockSubmitWarning } = makeTestRig();\r\n const ao = appObjects.getOrCreate(\"TEST AO\");\r\n\r\n updateCustomLabel(\"custom\", ao.id, appObjects);\r\n\r\n expect(mockSubmitWarning).toHaveBeenCalled();\r\n });\r\n});\r\n"]}
|
|
@@ -11,16 +11,26 @@ class SetCustomLabelUC extends core_1.AppObjectUC {
|
|
|
11
11
|
}
|
|
12
12
|
constructor(appObject) {
|
|
13
13
|
super(appObject, SetCustomLabelUC.type);
|
|
14
|
-
this.
|
|
14
|
+
this.update = (customLabel) => {
|
|
15
15
|
if (!this.label) {
|
|
16
16
|
this.warn("[SetCustomLabelUC] Unable to get Entity");
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
const prevLabel = this.label.custom;
|
|
20
19
|
this.label.custom = customLabel;
|
|
21
|
-
new SetCustomLabelUndoRedo_1.SetCustomLabelUndoRedo(prevLabel, customLabel, this.appObject);
|
|
22
20
|
(0, Dispatcher_1.dispatchStateChange)(this.appObjects);
|
|
23
21
|
};
|
|
22
|
+
this.submit = () => {
|
|
23
|
+
if (!this.label) {
|
|
24
|
+
this.warn("[SetCustomLabelUC] Unable to get Entity");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (this.localCustomLabel !== undefined) {
|
|
28
|
+
const prevLabel = this.localCustomLabel;
|
|
29
|
+
new SetCustomLabelUndoRedo_1.SetCustomLabelUndoRedo(prevLabel, this.label.custom, this.appObject);
|
|
30
|
+
this.localCustomLabel = this.label.display;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
this.localCustomLabel = this.label?.display;
|
|
24
34
|
}
|
|
25
35
|
static get(appObj) {
|
|
26
36
|
return appObj.getComponent(this.type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetCustomLabelUC.js","sourceRoot":"","sources":["../../../../src/Label/UC/SetCustomLabelUC.ts"],"names":[],"mappings":";;;AAAA,sCAAqD;AACrD,iDAAuD;AACvD,0CAA0C;AAC1C,qEAAkE;AAElE,MAAa,gBAAiB,SAAQ,kBAAW;
|
|
1
|
+
{"version":3,"file":"SetCustomLabelUC.js","sourceRoot":"","sources":["../../../../src/Label/UC/SetCustomLabelUC.ts"],"names":[],"mappings":";;;AAAA,sCAAqD;AACrD,iDAAuD;AACvD,0CAA0C;AAC1C,qEAAkE;AAElE,MAAa,gBAAiB,SAAQ,kBAAW;IAK/C,IAAY,KAAK;QACf,OAAO,IAAI,CAAC,uBAAuB,CAAc,sBAAW,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;IA0BD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAzB1C,WAAM,GAAG,CAAC,WAAmB,EAAE,EAAE;YAC/B,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;gBACrD,OAAO;YACT,CAAC;YACD,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;YAChC,IAAA,gCAAmB,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACvC,CAAC,CAAC;QAEF,WAAM,GAAG,GAAG,EAAE;YACZ,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;gBACrD,OAAO;YACT,CAAC;YAED,IAAI,IAAI,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACxC,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC;gBAExC,IAAI,+CAAsB,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;gBAEzE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;YAC7C,CAAC;QACH,CAAC,CAAC;QAKA,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,MAAiB;QAC1B,OAAO,MAAM,CAAC,YAAY,CAAmB,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1D,CAAC;;AAzCH,4CA0CC;AAzCiB,qBAAI,GAAG,kBAAkB,AAArB,CAAsB","sourcesContent":["import { AppObject, AppObjectUC } from \"@vived/core\";\r\nimport { dispatchStateChange } from \"../../Dispatcher\";\r\nimport { LabelEntity } from \"../Entities\";\r\nimport { SetCustomLabelUndoRedo } from \"./SetCustomLabelUndoRedo\";\r\n\r\nexport class SetCustomLabelUC extends AppObjectUC {\r\n static readonly type = \"SetCustomLabelUC\";\r\n\r\n private localCustomLabel?: string;\r\n\r\n private get label() {\r\n return this.getCachedLocalComponent<LabelEntity>(LabelEntity.type);\r\n }\r\n\r\n update = (customLabel: string) => {\r\n if (!this.label) {\r\n this.warn(\"[SetCustomLabelUC] Unable to get Entity\");\r\n return;\r\n }\r\n this.label.custom = customLabel;\r\n dispatchStateChange(this.appObjects);\r\n };\r\n\r\n submit = () => {\r\n if (!this.label) {\r\n this.warn(\"[SetCustomLabelUC] Unable to get Entity\");\r\n return;\r\n }\r\n\r\n if (this.localCustomLabel !== undefined) {\r\n const prevLabel = this.localCustomLabel;\r\n\r\n new SetCustomLabelUndoRedo(prevLabel, this.label.custom, this.appObject);\r\n\r\n this.localCustomLabel = this.label.display;\r\n }\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, SetCustomLabelUC.type);\r\n\r\n this.localCustomLabel = this.label?.display;\r\n }\r\n\r\n static get(appObj: AppObject): SetCustomLabelUC | undefined {\r\n return appObj.getComponent<SetCustomLabelUC>(this.type);\r\n }\r\n}\r\n"]}
|
|
@@ -28,24 +28,32 @@ describe("Set Custom Label UC", () => {
|
|
|
28
28
|
it("Sets custom label", () => {
|
|
29
29
|
const { label, setCustomLabelUC } = makeTestRig();
|
|
30
30
|
label.custom = "";
|
|
31
|
-
setCustomLabelUC.
|
|
31
|
+
setCustomLabelUC.update("custom");
|
|
32
32
|
expect(label.custom).toEqual("custom");
|
|
33
33
|
});
|
|
34
34
|
it("Submits warning if label entity was not added to App Object", () => {
|
|
35
35
|
const { appObjects, mockSubmitWarning } = makeTestRig();
|
|
36
36
|
const ao = appObjects.getOrCreate("testAO");
|
|
37
37
|
const clearCustomLabel = new SetCustomLabelUC_1.SetCustomLabelUC(ao);
|
|
38
|
-
clearCustomLabel.
|
|
39
|
-
expect(mockSubmitWarning).toHaveBeenCalledTimes(
|
|
38
|
+
clearCustomLabel.update("custom");
|
|
39
|
+
expect(mockSubmitWarning).toHaveBeenCalledTimes(3);
|
|
40
40
|
});
|
|
41
41
|
it("Dispatches state chagne when clear custom label", () => {
|
|
42
|
-
const {
|
|
43
|
-
setCustomLabelUC.
|
|
42
|
+
const { setCustomLabelUC, mockDispatcher } = makeTestRig();
|
|
43
|
+
setCustomLabelUC.update("custom");
|
|
44
44
|
expect(mockDispatcher.doDispatch).toHaveBeenCalled();
|
|
45
45
|
});
|
|
46
46
|
it("Submits and undo", () => {
|
|
47
|
+
const { setCustomLabelUC, mockUndo } = makeTestRig();
|
|
48
|
+
setCustomLabelUC.update("custom");
|
|
49
|
+
setCustomLabelUC.submit();
|
|
50
|
+
expect(mockUndo.submitAction).toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
it("Submits undo operation with correct previous and current labels", () => {
|
|
47
53
|
const { label, setCustomLabelUC, mockUndo } = makeTestRig();
|
|
48
|
-
|
|
54
|
+
label.custom = "initial";
|
|
55
|
+
setCustomLabelUC.update("custom");
|
|
56
|
+
setCustomLabelUC.submit();
|
|
49
57
|
expect(mockUndo.submitAction).toHaveBeenCalled();
|
|
50
58
|
});
|
|
51
59
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetCustomLabelUC.test.js","sourceRoot":"","sources":["../../../../src/Label/UC/SetCustomLabelUC.test.ts"],"names":[],"mappings":";;AAAA,sCAAgD;AAChD,4FAAyF;AACzF,oEAAiE;AACjE,0CAA8C;AAC9C,yDAAsD;AAEtD,SAAS,WAAW;IAClB,MAAM,UAAU,GAAG,IAAA,wBAAiB,GAAE,CAAC;IAEvC,MAAM,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAEzC,MAAM,QAAQ,GAAG,IAAI,2BAAY,CAAC,EAAE,CAAC,CAAC;IACtC,MAAM,cAAc,GAAG,IAAI,iDAAuB,CAAC,EAAE,CAAC,CAAC;IAEvD,MAAM,KAAK,GAAG,IAAA,0BAAe,EAAC,EAAE,CAAC,CAAC;IAClC,MAAM,gBAAgB,GAAG,IAAI,mCAAgB,CAAC,EAAE,CAAC,CAAC;IAElD,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IACpC,UAAU,CAAC,aAAa,GAAG,iBAAiB,CAAC;IAE7C,OAAO;QACL,UAAU;QACV,EAAE;QACF,QAAQ;QACR,cAAc;QACd,KAAK;QACL,gBAAgB;QAChB,iBAAiB;KAClB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,WAAW,EAAE,CAAC;QAElD,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC;QAClB,gBAAgB,CAAC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CAAC,CAAC,CAAC","sourcesContent":["import { makeAppObjectRepo } from \"@vived/core\";\r\nimport { MockDispatchStateChange } from \"../../Dispatcher/Mocks/MockDispatchStateChange\";\r\nimport { MockUndoRedo } from \"../../UndoRedo/Mocks/MockUndoRedo\";\r\nimport { makeLabelEntity } from \"../Entities\";\r\nimport { SetCustomLabelUC } from \"./SetCustomLabelUC\";\r\n\r\nfunction makeTestRig() {\r\n const appObjects = makeAppObjectRepo();\r\n\r\n const ao = appObjects.getOrCreate(\"App\");\r\n\r\n const mockUndo = new MockUndoRedo(ao);\r\n const mockDispatcher = new MockDispatchStateChange(ao);\r\n\r\n const label = makeLabelEntity(ao);\r\n const setCustomLabelUC = new SetCustomLabelUC(ao);\r\n\r\n const mockSubmitWarning = jest.fn();\r\n appObjects.submitWarning = mockSubmitWarning;\r\n\r\n return {\r\n appObjects,\r\n ao,\r\n mockUndo,\r\n mockDispatcher,\r\n label,\r\n setCustomLabelUC,\r\n mockSubmitWarning,\r\n };\r\n}\r\n\r\ndescribe(\"Set Custom Label UC\", () => {\r\n it(\"Sets custom label\", () => {\r\n const { label, setCustomLabelUC } = makeTestRig();\r\n\r\n label.custom = \"\";\r\n setCustomLabelUC.update(\"custom\");\r\n\r\n expect(label.custom).toEqual(\"custom\");\r\n });\r\n\r\n it(\"Submits warning if label entity was not added to App Object\", () => {\r\n const { appObjects, mockSubmitWarning } = makeTestRig();\r\n const ao = appObjects.getOrCreate(\"testAO\");\r\n\r\n const clearCustomLabel = new SetCustomLabelUC(ao);\r\n clearCustomLabel.update(\"custom\");\r\n\r\n expect(mockSubmitWarning).toHaveBeenCalledTimes(3);\r\n });\r\n\r\n it(\"Dispatches state chagne when clear custom label\", () => {\r\n const { setCustomLabelUC, mockDispatcher } = makeTestRig();\r\n\r\n setCustomLabelUC.update(\"custom\");\r\n\r\n expect(mockDispatcher.doDispatch).toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits and undo\", () => {\r\n const { setCustomLabelUC, mockUndo } = makeTestRig();\r\n\r\n setCustomLabelUC.update(\"custom\");\r\n setCustomLabelUC.submit();\r\n\r\n expect(mockUndo.submitAction).toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits undo operation with correct previous and current labels\", () => {\r\n const { label, setCustomLabelUC, mockUndo } = makeTestRig();\r\n\r\n label.custom = \"initial\";\r\n setCustomLabelUC.update(\"custom\");\r\n setCustomLabelUC.submit();\r\n\r\n expect(mockUndo.submitAction).toHaveBeenCalled();\r\n });\r\n});\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Label/Controller/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Label/Controller/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from \"./ClearCustomLabel\";\r\nexport * from \"./updateCustomLabel\";\r\nexport * from \"./submitCustomLabel\";\r\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SetCustomLabelUC } from "../UC/SetCustomLabelUC";
|
|
2
|
+
export function submitCustomLabel(appObjectID, appObjectRepo) {
|
|
3
|
+
const appObject = appObjectRepo.get(appObjectID);
|
|
4
|
+
if (!appObject) {
|
|
5
|
+
appObjectRepo.submitWarning("submitCustomLabel Contorller", "App Object not found");
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const setCustomLabelUC = SetCustomLabelUC.get(appObject);
|
|
9
|
+
if (!setCustomLabelUC) {
|
|
10
|
+
appObjectRepo.submitWarning("submitCustomLabel Controller", "SetCustomLabelUC was not added to App Object");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
setCustomLabelUC.submit();
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=submitCustomLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submitCustomLabel.js","sourceRoot":"","sources":["../../../../src/Label/Controller/submitCustomLabel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,UAAU,iBAAiB,CAC/B,WAAmB,EACnB,aAA4B;IAE5B,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACjD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,aAAa,CAAC,aAAa,CACzB,8BAA8B,EAC9B,sBAAsB,CACvB,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACzD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,aAAa,CAAC,aAAa,CACzB,8BAA8B,EAC9B,8CAA8C,CAC/C,CAAC;QACF,OAAO;IACT,CAAC;IAED,gBAAgB,CAAC,MAAM,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import { AppObjectRepo } from \"@vived/core\";\r\nimport { SetCustomLabelUC } from \"../UC/SetCustomLabelUC\";\r\n\r\nexport function submitCustomLabel(\r\n appObjectID: string,\r\n appObjectRepo: AppObjectRepo\r\n) {\r\n const appObject = appObjectRepo.get(appObjectID);\r\n if (!appObject) {\r\n appObjectRepo.submitWarning(\r\n \"submitCustomLabel Contorller\",\r\n \"App Object not found\"\r\n );\r\n return;\r\n }\r\n\r\n const setCustomLabelUC = SetCustomLabelUC.get(appObject);\r\n if (!setCustomLabelUC) {\r\n appObjectRepo.submitWarning(\r\n \"submitCustomLabel Controller\",\r\n \"SetCustomLabelUC was not added to App Object\"\r\n );\r\n return;\r\n }\r\n\r\n setCustomLabelUC.submit();\r\n}\r\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { makeAppObjectRepo } from "@vived/core";
|
|
2
|
+
import { SetCustomLabelUC } from "../UC/SetCustomLabelUC";
|
|
3
|
+
import { submitCustomLabel } from "./submitCustomLabel";
|
|
4
|
+
function makeTestRig() {
|
|
5
|
+
const appObjects = makeAppObjectRepo();
|
|
6
|
+
const mockSubmitWarning = jest.fn();
|
|
7
|
+
appObjects.submitWarning = mockSubmitWarning;
|
|
8
|
+
const ao = appObjects.getOrCreate("App Object ID");
|
|
9
|
+
const clearCustomLabelUC = new SetCustomLabelUC(ao);
|
|
10
|
+
const mockSubmitCustomLabel = jest.fn();
|
|
11
|
+
clearCustomLabelUC.submit = mockSubmitCustomLabel;
|
|
12
|
+
return {
|
|
13
|
+
appObjects,
|
|
14
|
+
ao,
|
|
15
|
+
mockSubmitWarning,
|
|
16
|
+
mockSubmitCustomLabel,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
describe("Submit Custom Label Controller", () => {
|
|
20
|
+
it("Calls Submit Custom Label method", () => {
|
|
21
|
+
const { appObjects, ao, mockSubmitCustomLabel } = makeTestRig();
|
|
22
|
+
submitCustomLabel(ao.id, appObjects);
|
|
23
|
+
expect(mockSubmitCustomLabel).toHaveBeenCalled();
|
|
24
|
+
});
|
|
25
|
+
it("Submits warning if App Object is not found", () => {
|
|
26
|
+
const { appObjects, mockSubmitWarning } = makeTestRig();
|
|
27
|
+
submitCustomLabel("TEST AO", appObjects);
|
|
28
|
+
expect(mockSubmitWarning).toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
it("Submits warning if SetCustomLabel UC was not added", () => {
|
|
31
|
+
const { appObjects, mockSubmitWarning } = makeTestRig();
|
|
32
|
+
const ao = appObjects.getOrCreate("TEST AO");
|
|
33
|
+
submitCustomLabel(ao.id, appObjects);
|
|
34
|
+
expect(mockSubmitWarning).toHaveBeenCalled();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=submitCustomLabel.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submitCustomLabel.test.js","sourceRoot":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AE,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE,CAAC;QACxD,MAAM,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAE7C,iBAAiB,CAAC,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QAErC,MAAM,CAAC,iBAAiB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { makeAppObjectRepo } from \"@vived/core\";\r\nimport { SetCustomLabelUC } from \"../UC/SetCustomLabelUC\";\r\nimport { submitCustomLabel } from \"./submitCustomLabel\";\r\n\r\nfunction makeTestRig() {\r\n const appObjects = makeAppObjectRepo();\r\n\r\n const mockSubmitWarning = jest.fn();\r\n appObjects.submitWarning = mockSubmitWarning;\r\n\r\n const ao = appObjects.getOrCreate(\"App Object ID\");\r\n\r\n const clearCustomLabelUC = new SetCustomLabelUC(ao);\r\n const mockSubmitCustomLabel = jest.fn();\r\n clearCustomLabelUC.submit = mockSubmitCustomLabel;\r\n\r\n return {\r\n appObjects,\r\n ao,\r\n mockSubmitWarning,\r\n mockSubmitCustomLabel,\r\n };\r\n}\r\n\r\ndescribe(\"Submit Custom Label Controller\", () => {\r\n it(\"Calls Submit Custom Label method\", () => {\r\n const { appObjects, ao, mockSubmitCustomLabel } = makeTestRig();\r\n\r\n submitCustomLabel(ao.id, appObjects);\r\n\r\n expect(mockSubmitCustomLabel).toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits warning if App Object is not found\", () => {\r\n const { appObjects, mockSubmitWarning } = makeTestRig();\r\n\r\n submitCustomLabel(\"TEST AO\", appObjects);\r\n\r\n expect(mockSubmitWarning).toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits warning if SetCustomLabel UC was not added\", () => {\r\n const { appObjects, mockSubmitWarning } = makeTestRig();\r\n const ao = appObjects.getOrCreate(\"TEST AO\");\r\n\r\n submitCustomLabel(ao.id, appObjects);\r\n\r\n expect(mockSubmitWarning).toHaveBeenCalled();\r\n });\r\n});\r\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SetCustomLabelUC } from "../UC/SetCustomLabelUC";
|
|
2
|
+
export function updateCustomLabel(customLabel, appObjectID, appObjectRepo) {
|
|
3
|
+
const appObject = appObjectRepo.get(appObjectID);
|
|
4
|
+
if (!appObject) {
|
|
5
|
+
appObjectRepo.submitWarning("updateCustomLabel Contorller", "App Object not found");
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const setCustomLabelUC = SetCustomLabelUC.get(appObject);
|
|
9
|
+
if (!setCustomLabelUC) {
|
|
10
|
+
appObjectRepo.submitWarning("updateCustomLabel Controller", "SetCustomLabelUC was not added to App Object");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
setCustomLabelUC.update(customLabel);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=updateCustomLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCustomLabel.js","sourceRoot":"","sources":["../../../../src/Label/Controller/updateCustomLabel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,UAAU,iBAAiB,CAC/B,WAAmB,EACnB,WAAmB,EACnB,aAA4B;IAE5B,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACjD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,aAAa,CAAC,aAAa,CACzB,8BAA8B,EAC9B,sBAAsB,CACvB,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACzD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,aAAa,CAAC,aAAa,CACzB,8BAA8B,EAC9B,8CAA8C,CAC/C,CAAC;QACF,OAAO;IACT,CAAC;IAED,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { AppObjectRepo } from \"@vived/core\";\r\nimport { SetCustomLabelUC } from \"../UC/SetCustomLabelUC\";\r\n\r\nexport function updateCustomLabel(\r\n customLabel: string,\r\n appObjectID: string,\r\n appObjectRepo: AppObjectRepo\r\n) {\r\n const appObject = appObjectRepo.get(appObjectID);\r\n if (!appObject) {\r\n appObjectRepo.submitWarning(\r\n \"updateCustomLabel Contorller\",\r\n \"App Object not found\"\r\n );\r\n return;\r\n }\r\n\r\n const setCustomLabelUC = SetCustomLabelUC.get(appObject);\r\n if (!setCustomLabelUC) {\r\n appObjectRepo.submitWarning(\r\n \"updateCustomLabel Controller\",\r\n \"SetCustomLabelUC was not added to App Object\"\r\n );\r\n return;\r\n }\r\n\r\n setCustomLabelUC.update(customLabel);\r\n}\r\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { makeAppObjectRepo } from "@vived/core";
|
|
2
|
+
import { SetCustomLabelUC } from "../UC/SetCustomLabelUC";
|
|
3
|
+
import { updateCustomLabel } from "./updateCustomLabel";
|
|
4
|
+
function makeTestRig() {
|
|
5
|
+
const appObjects = makeAppObjectRepo();
|
|
6
|
+
const mockSubmitWarning = jest.fn();
|
|
7
|
+
appObjects.submitWarning = mockSubmitWarning;
|
|
8
|
+
const ao = appObjects.getOrCreate("App Object ID");
|
|
9
|
+
const clearCustomLabelUC = new SetCustomLabelUC(ao);
|
|
10
|
+
const mockUpdateCustomLabel = jest.fn();
|
|
11
|
+
clearCustomLabelUC.update = mockUpdateCustomLabel;
|
|
12
|
+
return {
|
|
13
|
+
appObjects,
|
|
14
|
+
ao,
|
|
15
|
+
mockSubmitWarning,
|
|
16
|
+
mockUpdateCustomLabel,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
describe("Update Custom Label Controller", () => {
|
|
20
|
+
it("Calls Set Custom Label method", () => {
|
|
21
|
+
const { appObjects, ao, mockUpdateCustomLabel } = makeTestRig();
|
|
22
|
+
updateCustomLabel("custom", ao.id, appObjects);
|
|
23
|
+
expect(mockUpdateCustomLabel).toHaveBeenCalled();
|
|
24
|
+
});
|
|
25
|
+
it("Submits warning if App Object is not found", () => {
|
|
26
|
+
const { appObjects, mockSubmitWarning } = makeTestRig();
|
|
27
|
+
updateCustomLabel("custom", "TEST AO", appObjects);
|
|
28
|
+
expect(mockSubmitWarning).toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
it("Submits warning if SetCustomLabel UC was not added", () => {
|
|
31
|
+
const { appObjects, mockSubmitWarning } = makeTestRig();
|
|
32
|
+
const ao = appObjects.getOrCreate("TEST AO");
|
|
33
|
+
updateCustomLabel("custom", ao.id, appObjects);
|
|
34
|
+
expect(mockSubmitWarning).toHaveBeenCalled();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=updateCustomLabel.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCustomLabel.test.js","sourceRoot":"","sources":["../../../../src/Label/Controller/updateCustomLabel.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,SAAS,WAAW;IAClB,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;IAEvC,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IACpC,UAAU,CAAC,aAAa,GAAG,iBAAiB,CAAC;IAE7C,MAAM,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAEnD,MAAM,kBAAkB,GAAG,IAAI,gBAAgB,C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\"../UC/SetCustomLabelUC\";\r\nimport { updateCustomLabel } from \"./updateCustomLabel\";\r\n\r\nfunction makeTestRig() {\r\n const appObjects = makeAppObjectRepo();\r\n\r\n const mockSubmitWarning = jest.fn();\r\n appObjects.submitWarning = mockSubmitWarning;\r\n\r\n const ao = appObjects.getOrCreate(\"App Object ID\");\r\n\r\n const clearCustomLabelUC = new SetCustomLabelUC(ao);\r\n const mockUpdateCustomLabel = jest.fn();\r\n clearCustomLabelUC.update = mockUpdateCustomLabel;\r\n\r\n return {\r\n appObjects,\r\n ao,\r\n mockSubmitWarning,\r\n mockUpdateCustomLabel,\r\n };\r\n}\r\n\r\ndescribe(\"Update Custom Label Controller\", () => {\r\n it(\"Calls Set Custom Label method\", () => {\r\n const { appObjects, ao, mockUpdateCustomLabel } = makeTestRig();\r\n\r\n updateCustomLabel(\"custom\", ao.id, appObjects);\r\n\r\n expect(mockUpdateCustomLabel).toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits warning if App Object is not found\", () => {\r\n const { appObjects, mockSubmitWarning } = makeTestRig();\r\n\r\n updateCustomLabel(\"custom\", \"TEST AO\", appObjects);\r\n\r\n expect(mockSubmitWarning).toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits warning if SetCustomLabel UC was not added\", () => {\r\n const { appObjects, mockSubmitWarning } = makeTestRig();\r\n const ao = appObjects.getOrCreate(\"TEST AO\");\r\n\r\n updateCustomLabel(\"custom\", ao.id, appObjects);\r\n\r\n expect(mockSubmitWarning).toHaveBeenCalled();\r\n });\r\n});\r\n"]}
|
|
@@ -8,16 +8,26 @@ export class SetCustomLabelUC extends AppObjectUC {
|
|
|
8
8
|
}
|
|
9
9
|
constructor(appObject) {
|
|
10
10
|
super(appObject, SetCustomLabelUC.type);
|
|
11
|
-
this.
|
|
11
|
+
this.update = (customLabel) => {
|
|
12
12
|
if (!this.label) {
|
|
13
13
|
this.warn("[SetCustomLabelUC] Unable to get Entity");
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
const prevLabel = this.label.custom;
|
|
17
16
|
this.label.custom = customLabel;
|
|
18
|
-
new SetCustomLabelUndoRedo(prevLabel, customLabel, this.appObject);
|
|
19
17
|
dispatchStateChange(this.appObjects);
|
|
20
18
|
};
|
|
19
|
+
this.submit = () => {
|
|
20
|
+
if (!this.label) {
|
|
21
|
+
this.warn("[SetCustomLabelUC] Unable to get Entity");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (this.localCustomLabel !== undefined) {
|
|
25
|
+
const prevLabel = this.localCustomLabel;
|
|
26
|
+
new SetCustomLabelUndoRedo(prevLabel, this.label.custom, this.appObject);
|
|
27
|
+
this.localCustomLabel = this.label.display;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
this.localCustomLabel = this.label?.display;
|
|
21
31
|
}
|
|
22
32
|
static get(appObj) {
|
|
23
33
|
return appObj.getComponent(this.type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetCustomLabelUC.js","sourceRoot":"","sources":["../../../../src/Label/UC/SetCustomLabelUC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,OAAO,gBAAiB,SAAQ,WAAW;
|
|
1
|
+
{"version":3,"file":"SetCustomLabelUC.js","sourceRoot":"","sources":["../../../../src/Label/UC/SetCustomLabelUC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC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Content":["import { AppObject, AppObjectUC } from \"@vived/core\";\r\nimport { dispatchStateChange } from \"../../Dispatcher\";\r\nimport { LabelEntity } from \"../Entities\";\r\nimport { SetCustomLabelUndoRedo } from \"./SetCustomLabelUndoRedo\";\r\n\r\nexport class SetCustomLabelUC extends AppObjectUC {\r\n static readonly type = \"SetCustomLabelUC\";\r\n\r\n private localCustomLabel?: string;\r\n\r\n private get label() {\r\n return this.getCachedLocalComponent<LabelEntity>(LabelEntity.type);\r\n }\r\n\r\n update = (customLabel: string) => {\r\n if (!this.label) {\r\n this.warn(\"[SetCustomLabelUC] Unable to get Entity\");\r\n return;\r\n }\r\n this.label.custom = customLabel;\r\n dispatchStateChange(this.appObjects);\r\n };\r\n\r\n submit = () => {\r\n if (!this.label) {\r\n this.warn(\"[SetCustomLabelUC] Unable to get Entity\");\r\n return;\r\n }\r\n\r\n if (this.localCustomLabel !== undefined) {\r\n const prevLabel = this.localCustomLabel;\r\n\r\n new SetCustomLabelUndoRedo(prevLabel, this.label.custom, this.appObject);\r\n\r\n this.localCustomLabel = this.label.display;\r\n }\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, SetCustomLabelUC.type);\r\n\r\n this.localCustomLabel = this.label?.display;\r\n }\r\n\r\n static get(appObj: AppObject): SetCustomLabelUC | undefined {\r\n return appObj.getComponent<SetCustomLabelUC>(this.type);\r\n }\r\n}\r\n"]}
|
|
@@ -26,24 +26,32 @@ describe("Set Custom Label UC", () => {
|
|
|
26
26
|
it("Sets custom label", () => {
|
|
27
27
|
const { label, setCustomLabelUC } = makeTestRig();
|
|
28
28
|
label.custom = "";
|
|
29
|
-
setCustomLabelUC.
|
|
29
|
+
setCustomLabelUC.update("custom");
|
|
30
30
|
expect(label.custom).toEqual("custom");
|
|
31
31
|
});
|
|
32
32
|
it("Submits warning if label entity was not added to App Object", () => {
|
|
33
33
|
const { appObjects, mockSubmitWarning } = makeTestRig();
|
|
34
34
|
const ao = appObjects.getOrCreate("testAO");
|
|
35
35
|
const clearCustomLabel = new SetCustomLabelUC(ao);
|
|
36
|
-
clearCustomLabel.
|
|
37
|
-
expect(mockSubmitWarning).toHaveBeenCalledTimes(
|
|
36
|
+
clearCustomLabel.update("custom");
|
|
37
|
+
expect(mockSubmitWarning).toHaveBeenCalledTimes(3);
|
|
38
38
|
});
|
|
39
39
|
it("Dispatches state chagne when clear custom label", () => {
|
|
40
|
-
const {
|
|
41
|
-
setCustomLabelUC.
|
|
40
|
+
const { setCustomLabelUC, mockDispatcher } = makeTestRig();
|
|
41
|
+
setCustomLabelUC.update("custom");
|
|
42
42
|
expect(mockDispatcher.doDispatch).toHaveBeenCalled();
|
|
43
43
|
});
|
|
44
44
|
it("Submits and undo", () => {
|
|
45
|
+
const { setCustomLabelUC, mockUndo } = makeTestRig();
|
|
46
|
+
setCustomLabelUC.update("custom");
|
|
47
|
+
setCustomLabelUC.submit();
|
|
48
|
+
expect(mockUndo.submitAction).toHaveBeenCalled();
|
|
49
|
+
});
|
|
50
|
+
it("Submits undo operation with correct previous and current labels", () => {
|
|
45
51
|
const { label, setCustomLabelUC, mockUndo } = makeTestRig();
|
|
46
|
-
|
|
52
|
+
label.custom = "initial";
|
|
53
|
+
setCustomLabelUC.update("custom");
|
|
54
|
+
setCustomLabelUC.submit();
|
|
47
55
|
expect(mockUndo.submitAction).toHaveBeenCalled();
|
|
48
56
|
});
|
|
49
57
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetCustomLabelUC.test.js","sourceRoot":"","sources":["../../../../src/Label/UC/SetCustomLabelUC.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM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AAC,iBAAiB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,GAAG,WAAW,EAAE,CAAC;QAE3D,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAElC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC1B,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC;QAErD,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClC,gBAAgB,CAAC,MAAM,EAAE,CAAC;QAE1B,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC;QAE5D,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;QACzB,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClC,gBAAgB,CAAC,MAAM,EAAE,CAAC;QAE1B,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { makeAppObjectRepo } from \"@vived/core\";\r\nimport { MockDispatchStateChange } from \"../../Dispatcher/Mocks/MockDispatchStateChange\";\r\nimport { MockUndoRedo } from \"../../UndoRedo/Mocks/MockUndoRedo\";\r\nimport { makeLabelEntity } from \"../Entities\";\r\nimport { SetCustomLabelUC } from \"./SetCustomLabelUC\";\r\n\r\nfunction makeTestRig() {\r\n const appObjects = makeAppObjectRepo();\r\n\r\n const ao = appObjects.getOrCreate(\"App\");\r\n\r\n const mockUndo = new MockUndoRedo(ao);\r\n const mockDispatcher = new MockDispatchStateChange(ao);\r\n\r\n const label = makeLabelEntity(ao);\r\n const setCustomLabelUC = new SetCustomLabelUC(ao);\r\n\r\n const mockSubmitWarning = jest.fn();\r\n appObjects.submitWarning = mockSubmitWarning;\r\n\r\n return {\r\n appObjects,\r\n ao,\r\n mockUndo,\r\n mockDispatcher,\r\n label,\r\n setCustomLabelUC,\r\n mockSubmitWarning,\r\n };\r\n}\r\n\r\ndescribe(\"Set Custom Label UC\", () => {\r\n it(\"Sets custom label\", () => {\r\n const { label, setCustomLabelUC } = makeTestRig();\r\n\r\n label.custom = \"\";\r\n setCustomLabelUC.update(\"custom\");\r\n\r\n expect(label.custom).toEqual(\"custom\");\r\n });\r\n\r\n it(\"Submits warning if label entity was not added to App Object\", () => {\r\n const { appObjects, mockSubmitWarning } = makeTestRig();\r\n const ao = appObjects.getOrCreate(\"testAO\");\r\n\r\n const clearCustomLabel = new SetCustomLabelUC(ao);\r\n clearCustomLabel.update(\"custom\");\r\n\r\n expect(mockSubmitWarning).toHaveBeenCalledTimes(3);\r\n });\r\n\r\n it(\"Dispatches state chagne when clear custom label\", () => {\r\n const { setCustomLabelUC, mockDispatcher } = makeTestRig();\r\n\r\n setCustomLabelUC.update(\"custom\");\r\n\r\n expect(mockDispatcher.doDispatch).toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits and undo\", () => {\r\n const { setCustomLabelUC, mockUndo } = makeTestRig();\r\n\r\n setCustomLabelUC.update(\"custom\");\r\n setCustomLabelUC.submit();\r\n\r\n expect(mockUndo.submitAction).toHaveBeenCalled();\r\n });\r\n\r\n it(\"Submits undo operation with correct previous and current labels\", () => {\r\n const { label, setCustomLabelUC, mockUndo } = makeTestRig();\r\n\r\n label.custom = \"initial\";\r\n setCustomLabelUC.update(\"custom\");\r\n setCustomLabelUC.submit();\r\n\r\n expect(mockUndo.submitAction).toHaveBeenCalled();\r\n });\r\n});\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Label/Controller/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Label/Controller/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submitCustomLabel.d.ts","sourceRoot":"","sources":["../../../../src/Label/Controller/submitCustomLabel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,aAAa,QAqB7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submitCustomLabel.test.d.ts","sourceRoot":"","sources":["../../../../src/Label/Controller/submitCustomLabel.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCustomLabel.d.ts","sourceRoot":"","sources":["../../../../src/Label/Controller/updateCustomLabel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,aAAa,QAqB7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCustomLabel.test.d.ts","sourceRoot":"","sources":["../../../../src/Label/Controller/updateCustomLabel.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AppObject, AppObjectUC } from "@vived/core";
|
|
2
2
|
export declare class SetCustomLabelUC extends AppObjectUC {
|
|
3
3
|
static readonly type = "SetCustomLabelUC";
|
|
4
|
+
private localCustomLabel?;
|
|
4
5
|
private get label();
|
|
5
|
-
|
|
6
|
+
update: (customLabel: string) => void;
|
|
7
|
+
submit: () => void;
|
|
6
8
|
constructor(appObject: AppObject);
|
|
7
9
|
static get(appObj: AppObject): SetCustomLabelUC | undefined;
|
|
8
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetCustomLabelUC.d.ts","sourceRoot":"","sources":["../../../../src/Label/UC/SetCustomLabelUC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAKrD,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,MAAM,CAAC,QAAQ,CAAC,IAAI,sBAAsB;IAE1C,OAAO,KAAK,KAAK,GAEhB;IAED,
|
|
1
|
+
{"version":3,"file":"SetCustomLabelUC.d.ts","sourceRoot":"","sources":["../../../../src/Label/UC/SetCustomLabelUC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAKrD,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,MAAM,CAAC,QAAQ,CAAC,IAAI,sBAAsB;IAE1C,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAElC,OAAO,KAAK,KAAK,GAEhB;IAED,MAAM,GAAI,aAAa,MAAM,UAO3B;IAEF,MAAM,aAaJ;gBAEU,SAAS,EAAE,SAAS;IAMhC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,gBAAgB,GAAG,SAAS;CAG5D"}
|