@futdevpro/fsm-dynamo 1.9.51 → 1.10.2
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/.github/workflows/main.yml +3 -3
- package/build/_collections/utils/array.util.d.ts +1 -7
- package/build/_collections/utils/array.util.d.ts.map +1 -1
- package/build/_collections/utils/array.util.js +0 -31
- package/build/_collections/utils/array.util.js.map +1 -1
- package/build/_collections/utils/array.util.spec.js +0 -35
- package/build/_collections/utils/array.util.spec.js.map +1 -1
- package/build/_collections/utils/log.util.d.ts +1 -0
- package/build/_collections/utils/log.util.d.ts.map +1 -1
- package/build/_collections/utils/log.util.js +3 -0
- package/build/_collections/utils/log.util.js.map +1 -1
- package/build/_collections/utils/log.util.spec.d.ts +2 -0
- package/build/_collections/utils/log.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/log.util.spec.js +85 -0
- package/build/_collections/utils/log.util.spec.js.map +1 -0
- package/build/_collections/utils/math/box-bounds.util.spec.d.ts +2 -0
- package/build/_collections/utils/math/box-bounds.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/math/box-bounds.util.spec.js +53 -0
- package/build/_collections/utils/math/box-bounds.util.spec.js.map +1 -0
- package/build/_collections/utils/math/math.util.spec.d.ts +2 -0
- package/build/_collections/utils/math/math.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/math/math.util.spec.js +89 -0
- package/build/_collections/utils/math/math.util.spec.js.map +1 -0
- package/build/_collections/utils/math/random.util.spec.d.ts +2 -0
- package/build/_collections/utils/math/random.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/math/random.util.spec.js +75 -0
- package/build/_collections/utils/math/random.util.spec.js.map +1 -0
- package/build/_collections/utils/math/trigonometry.util.spec.d.ts +2 -0
- package/build/_collections/utils/math/trigonometry.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/math/trigonometry.util.spec.js +49 -0
- package/build/_collections/utils/math/trigonometry.util.spec.js.map +1 -0
- package/build/_collections/utils/math/vector2.util.spec.d.ts +2 -0
- package/build/_collections/utils/math/vector2.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/math/vector2.util.spec.js +82 -0
- package/build/_collections/utils/math/vector2.util.spec.js.map +1 -0
- package/build/_collections/utils/regex/password-regex.util.spec.d.ts +2 -0
- package/build/_collections/utils/regex/password-regex.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/regex/password-regex.util.spec.js +44 -0
- package/build/_collections/utils/regex/password-regex.util.spec.js.map +1 -0
- package/build/_collections/utils/regex/regex.util.spec.d.ts +2 -0
- package/build/_collections/utils/regex/regex.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/regex/regex.util.spec.js +40 -0
- package/build/_collections/utils/regex/regex.util.spec.js.map +1 -0
- package/build/_collections/utils/regex/username-regex.util.spec.d.ts +2 -0
- package/build/_collections/utils/regex/username-regex.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/regex/username-regex.util.spec.js +59 -0
- package/build/_collections/utils/regex/username-regex.util.spec.js.map +1 -0
- package/build/_collections/utils/round-list.util.d.ts.map +1 -1
- package/build/_collections/utils/round-list.util.js +1 -1
- package/build/_collections/utils/round-list.util.js.map +1 -1
- package/build/_collections/utils/round-list.util.spec.d.ts +2 -0
- package/build/_collections/utils/round-list.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/round-list.util.spec.js +65 -0
- package/build/_collections/utils/round-list.util.spec.js.map +1 -0
- package/build/_collections/utils/shared.util.spec.d.ts +2 -0
- package/build/_collections/utils/shared.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/shared.util.spec.js +113 -0
- package/build/_collections/utils/shared.util.spec.js.map +1 -0
- package/build/_collections/utils/string.util.d.ts +5 -0
- package/build/_collections/utils/string.util.d.ts.map +1 -0
- package/build/_collections/utils/string.util.js +11 -0
- package/build/_collections/utils/string.util.js.map +1 -0
- package/build/_collections/utils/string.util.spec.d.ts +2 -0
- package/build/_collections/utils/string.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/string.util.spec.js +36 -0
- package/build/_collections/utils/string.util.spec.js.map +1 -0
- package/build/_collections/utils/type-cloning-facility.util.spec.d.ts +2 -0
- package/build/_collections/utils/type-cloning-facility.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/type-cloning-facility.util.spec.js +41 -0
- package/build/_collections/utils/type-cloning-facility.util.spec.js.map +1 -0
- package/build/_collections/utils/utilities.util.d.ts +0 -8
- package/build/_collections/utils/utilities.util.d.ts.map +1 -1
- package/build/_collections/utils/utilities.util.js +0 -8
- package/build/_collections/utils/utilities.util.js.map +1 -1
- package/build/_collections/utils/utilities.util.spec.d.ts +2 -0
- package/build/_collections/utils/utilities.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/utilities.util.spec.js +145 -0
- package/build/_collections/utils/utilities.util.spec.js.map +1 -0
- package/build/_collections/utils/uuid.util.d.ts +0 -1
- package/build/_collections/utils/uuid.util.d.ts.map +1 -1
- package/build/_collections/utils/uuid.util.js +1 -1
- package/build/_collections/utils/uuid.util.js.map +1 -1
- package/build/_collections/utils/uuid.util.spec.d.ts +2 -0
- package/build/_collections/utils/uuid.util.spec.d.ts.map +1 -0
- package/build/_collections/utils/uuid.util.spec.js +29 -0
- package/build/_collections/utils/uuid.util.spec.js.map +1 -0
- package/build/_models/control-models/data-model-params.control-model.spec.d.ts +2 -0
- package/build/_models/control-models/data-model-params.control-model.spec.d.ts.map +1 -0
- package/build/_models/control-models/data-model-params.control-model.spec.js +53 -0
- package/build/_models/control-models/data-model-params.control-model.spec.js.map +1 -0
- package/build/_models/control-models/data-property-params.control-model.spec.d.ts +2 -0
- package/build/_models/control-models/data-property-params.control-model.spec.d.ts.map +1 -0
- package/build/_models/control-models/data-property-params.control-model.spec.js +83 -0
- package/build/_models/control-models/data-property-params.control-model.spec.js.map +1 -0
- package/build/_models/control-models/poll.control-model.d.ts +7 -7
- package/build/_models/control-models/poll.control-model.d.ts.map +1 -1
- package/build/_models/control-models/poll.control-model.js.map +1 -1
- package/build/_models/control-models/poll.control-model.spec.d.ts +2 -0
- package/build/_models/control-models/poll.control-model.spec.d.ts.map +1 -0
- package/build/_models/control-models/poll.control-model.spec.js +57 -0
- package/build/_models/control-models/poll.control-model.spec.js.map +1 -0
- package/build/_models/control-models/range-value.control-model.spec.d.ts +2 -0
- package/build/_models/control-models/range-value.control-model.spec.d.ts.map +1 -0
- package/build/_models/control-models/range-value.control-model.spec.js +163 -0
- package/build/_models/control-models/range-value.control-model.spec.js.map +1 -0
- package/build/_models/data-models/metadata.data-model.spec.d.ts +2 -0
- package/build/_models/data-models/metadata.data-model.spec.d.ts.map +1 -0
- package/build/_models/data-models/metadata.data-model.spec.js +102 -0
- package/build/_models/data-models/metadata.data-model.spec.js.map +1 -0
- package/build/_models/interfaces/search-query.interface.d.ts +2 -2
- package/build/_models/interfaces/search-query.interface.d.ts.map +1 -1
- package/build/_models/interfaces/search-result.interface.d.ts +5 -0
- package/build/_models/interfaces/search-result.interface.d.ts.map +1 -0
- package/build/_models/interfaces/search-result.interface.js +3 -0
- package/build/_models/interfaces/search-result.interface.js.map +1 -0
- package/build/_modules/custom-data/_models/cud.data-model.spec.d.ts +2 -0
- package/build/_modules/custom-data/_models/cud.data-model.spec.d.ts.map +1 -0
- package/build/_modules/custom-data/_models/cud.data-model.spec.js +34 -0
- package/build/_modules/custom-data/_models/cud.data-model.spec.js.map +1 -0
- package/build/_modules/location/_collections/loc-regions.util.spec.d.ts +2 -0
- package/build/_modules/location/_collections/loc-regions.util.spec.d.ts.map +1 -0
- package/build/_modules/location/_collections/loc-regions.util.spec.js +51 -0
- package/build/_modules/location/_collections/loc-regions.util.spec.js.map +1 -0
- package/build/_modules/location/_collections/loc.util.spec.d.ts +2 -0
- package/build/_modules/location/_collections/loc.util.spec.d.ts.map +1 -0
- package/build/_modules/location/_collections/loc.util.spec.js +39 -0
- package/build/_modules/location/_collections/loc.util.spec.js.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-country-pipe.util.spec.d.ts +2 -0
- package/build/_modules/pipe/_collections/utils/pip-country-pipe.util.spec.d.ts.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-country-pipe.util.spec.js +33 -0
- package/build/_modules/pipe/_collections/utils/pip-country-pipe.util.spec.js.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-custom-pipe.util.spec.d.ts +2 -0
- package/build/_modules/pipe/_collections/utils/pip-custom-pipe.util.spec.d.ts.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-custom-pipe.util.spec.js +36 -0
- package/build/_modules/pipe/_collections/utils/pip-custom-pipe.util.spec.js.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-division-pipe.util.spec.d.ts +2 -0
- package/build/_modules/pipe/_collections/utils/pip-division-pipe.util.spec.d.ts.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-division-pipe.util.spec.js +35 -0
- package/build/_modules/pipe/_collections/utils/pip-division-pipe.util.spec.js.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-list-pipe.util.spec.d.ts +2 -0
- package/build/_modules/pipe/_collections/utils/pip-list-pipe.util.spec.d.ts.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-list-pipe.util.spec.js +31 -0
- package/build/_modules/pipe/_collections/utils/pip-list-pipe.util.spec.js.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-multi-pipe-pipe.util.spec.d.ts +2 -0
- package/build/_modules/pipe/_collections/utils/pip-multi-pipe-pipe.util.spec.d.ts.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-multi-pipe-pipe.util.spec.js +54 -0
- package/build/_modules/pipe/_collections/utils/pip-multi-pipe-pipe.util.spec.js.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-obj-key-pipe.util.spec.d.ts +2 -0
- package/build/_modules/pipe/_collections/utils/pip-obj-key-pipe.util.spec.d.ts.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-obj-key-pipe.util.spec.js +26 -0
- package/build/_modules/pipe/_collections/utils/pip-obj-key-pipe.util.spec.js.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-range-pipe.util.spec.d.ts +2 -0
- package/build/_modules/pipe/_collections/utils/pip-range-pipe.util.spec.d.ts.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-range-pipe.util.spec.js +50 -0
- package/build/_modules/pipe/_collections/utils/pip-range-pipe.util.spec.js.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-region-pipe.util.spec.d.ts +2 -0
- package/build/_modules/pipe/_collections/utils/pip-region-pipe.util.spec.d.ts.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-region-pipe.util.spec.js +23 -0
- package/build/_modules/pipe/_collections/utils/pip-region-pipe.util.spec.js.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-replace-pipe.util.spec.d.ts +2 -0
- package/build/_modules/pipe/_collections/utils/pip-replace-pipe.util.spec.d.ts.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-replace-pipe.util.spec.js +38 -0
- package/build/_modules/pipe/_collections/utils/pip-replace-pipe.util.spec.js.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-slider-pipe.util.spec.d.ts +2 -0
- package/build/_modules/pipe/_collections/utils/pip-slider-pipe.util.spec.d.ts.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-slider-pipe.util.spec.js +20 -0
- package/build/_modules/pipe/_collections/utils/pip-slider-pipe.util.spec.js.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.spec.d.ts +2 -0
- package/build/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.spec.d.ts.map +1 -0
- package/build/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.spec.js +49 -0
- package/build/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.spec.js.map +1 -0
- package/build/_modules/socket/_models/sck-client-params.control-model.spec.d.ts +2 -0
- package/build/_modules/socket/_models/sck-client-params.control-model.spec.d.ts.map +1 -0
- package/build/_modules/socket/_models/sck-client-params.control-model.spec.js +54 -0
- package/build/_modules/socket/_models/sck-client-params.control-model.spec.js.map +1 -0
- package/build/_modules/socket/_models/sck-socket-event.control-model.d.ts +1 -1
- package/build/_modules/socket/_models/sck-socket-event.control-model.d.ts.map +1 -1
- package/build/_modules/socket/_models/sck-socket-event.control-model.js +2 -2
- package/build/_modules/socket/_models/sck-socket-event.control-model.js.map +1 -1
- package/build/_modules/socket/_models/sck-socket-event.control-model.spec.d.ts +2 -0
- package/build/_modules/socket/_models/sck-socket-event.control-model.spec.d.ts.map +1 -0
- package/build/_modules/socket/_models/sck-socket-event.control-model.spec.js +49 -0
- package/build/_modules/socket/_models/sck-socket-event.control-model.spec.js.map +1 -0
- package/build/_modules/socket/_services/sck-client.service-base.d.ts +3 -3
- package/build/_modules/socket/_services/sck-client.service-base.d.ts.map +1 -1
- package/build/_modules/socket/_services/sck-client.service-base.js +3 -3
- package/build/_modules/socket/_services/sck-client.service-base.js.map +1 -1
- package/build/_modules/socket/_services/sck-client.service-base.spec.d.ts +2 -0
- package/build/_modules/socket/_services/sck-client.service-base.spec.d.ts.map +1 -0
- package/build/_modules/socket/_services/sck-client.service-base.spec.js +82 -0
- package/build/_modules/socket/_services/sck-client.service-base.spec.js.map +1 -0
- package/build/_modules/usage/_models/usg-action.control-model.spec.d.ts +2 -0
- package/build/_modules/usage/_models/usg-action.control-model.spec.d.ts.map +1 -0
- package/build/_modules/usage/_models/usg-action.control-model.spec.js +24 -0
- package/build/_modules/usage/_models/usg-action.control-model.spec.js.map +1 -0
- package/build/_modules/usage/_models/usg-daily-usage-data.control-model.spec.d.ts +2 -0
- package/build/_modules/usage/_models/usg-daily-usage-data.control-model.spec.d.ts.map +1 -0
- package/build/_modules/usage/_models/usg-daily-usage-data.control-model.spec.js +33 -0
- package/build/_modules/usage/_models/usg-daily-usage-data.control-model.spec.js.map +1 -0
- package/build/_modules/usage/_models/usg-data.control-model.spec.d.ts +2 -0
- package/build/_modules/usage/_models/usg-data.control-model.spec.d.ts.map +1 -0
- package/build/_modules/usage/_models/usg-data.control-model.spec.js +37 -0
- package/build/_modules/usage/_models/usg-data.control-model.spec.js.map +1 -0
- package/build/_modules/usage/_models/usg-session.data-model.spec.d.ts +2 -0
- package/build/_modules/usage/_models/usg-session.data-model.spec.d.ts.map +1 -0
- package/build/_modules/usage/_models/usg-session.data-model.spec.js +66 -0
- package/build/_modules/usage/_models/usg-session.data-model.spec.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/futdevpro-fsm-dynamo-01.10.02.tgz +0 -0
- package/package.json +11 -23
- package/src/_collections/utils/array.util.spec.ts +0 -45
- package/src/_collections/utils/array.util.ts +2 -45
- package/src/_collections/utils/log.util.spec.ts +99 -0
- package/src/_collections/utils/log.util.ts +4 -0
- package/src/_collections/utils/math/box-bounds.util.spec.ts +63 -0
- package/src/_collections/utils/math/math.util.spec.ts +104 -0
- package/src/_collections/utils/math/random.util.spec.ts +82 -0
- package/src/_collections/utils/math/trigonometry.util.spec.ts +57 -0
- package/src/_collections/utils/math/vector2.util.spec.ts +94 -0
- package/src/_collections/utils/regex/password-regex.util.spec.ts +51 -0
- package/src/_collections/utils/regex/regex.util.spec.ts +42 -0
- package/src/_collections/utils/regex/username-regex.util.spec.ts +61 -0
- package/src/_collections/utils/round-list.util.spec.ts +79 -0
- package/src/_collections/utils/round-list.util.ts +46 -1
- package/src/_collections/utils/shared.util.spec.ts +143 -0
- package/src/_collections/utils/string.util.spec.ts +41 -0
- package/src/_collections/utils/string.util.ts +10 -0
- package/src/_collections/utils/type-cloning-facility.util.spec.ts +51 -0
- package/src/_collections/utils/utilities.util.spec.ts +166 -0
- package/src/_collections/utils/utilities.util.ts +1 -12
- package/src/_collections/utils/uuid.util.spec.ts +30 -0
- package/src/_collections/utils/uuid.util.ts +14 -1
- package/src/_models/control-models/data-model-params.control-model.spec.ts +67 -0
- package/src/_models/control-models/data-property-params.control-model.spec.ts +109 -0
- package/src/_models/control-models/poll.control-model.spec.ts +63 -0
- package/src/_models/control-models/poll.control-model.ts +8 -7
- package/src/_models/control-models/range-value.control-model.spec.ts +187 -0
- package/src/_models/data-models/metadata.data-model.spec.ts +123 -0
- package/src/_models/interfaces/search-query.interface.ts +2 -2
- package/src/_models/interfaces/search-result.interface.ts +6 -0
- package/src/_modules/custom-data/_models/cud.data-model.spec.ts +38 -0
- package/src/_modules/location/_collections/loc-regions.util.spec.ts +61 -0
- package/src/_modules/location/_collections/loc.util.spec.ts +52 -0
- package/src/_modules/pipe/_collections/utils/pip-country-pipe.util.spec.ts +47 -0
- package/src/_modules/pipe/_collections/utils/pip-custom-pipe.util.spec.ts +39 -0
- package/src/_modules/pipe/_collections/utils/pip-division-pipe.util.spec.ts +41 -0
- package/src/_modules/pipe/_collections/utils/pip-list-pipe.util.spec.ts +34 -0
- package/src/_modules/pipe/_collections/utils/pip-multi-pipe-pipe.util.spec.ts +60 -0
- package/src/_modules/pipe/_collections/utils/pip-obj-key-pipe.util.spec.ts +28 -0
- package/src/_modules/pipe/_collections/utils/pip-range-pipe.util.spec.ts +59 -0
- package/src/_modules/pipe/_collections/utils/pip-region-pipe.util.spec.ts +31 -0
- package/src/_modules/pipe/_collections/utils/pip-replace-pipe.util.spec.ts +44 -0
- package/src/_modules/pipe/_collections/utils/pip-slider-pipe.util.spec.ts +21 -0
- package/src/_modules/pipe/_collections/utils/pip-smart-replace-pipe.util.spec.ts +61 -0
- package/src/_modules/socket/_models/sck-client-params.control-model.spec.ts +67 -0
- package/src/_modules/socket/_models/sck-socket-event.control-model.spec.ts +66 -0
- package/src/_modules/socket/_models/sck-socket-event.control-model.ts +2 -2
- package/src/_modules/socket/_services/sck-client.service-base.spec.ts +99 -0
- package/src/_modules/socket/_services/sck-client.service-base.ts +7 -7
- package/src/_modules/usage/_models/usg-action.control-model.spec.ts +27 -0
- package/src/_modules/usage/_models/usg-daily-usage-data.control-model.spec.ts +36 -0
- package/src/_modules/usage/_models/usg-data.control-model.spec.ts +41 -0
- package/src/_modules/usage/_models/usg-session.data-model.spec.ts +73 -0
- package/src/index.ts +1 -0
- package/futdevpro-fsm-dynamo-01.09.51.tgz +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
import { DyFM_String } from './string.util';
|
|
3
|
+
|
|
4
|
+
describe('DyFM_String', () => {
|
|
5
|
+
describe('breakTrim', () => {
|
|
6
|
+
it('should remove spaces from the start and end of the string', () => {
|
|
7
|
+
const result = DyFM_String.breakTrim(' hello world ');
|
|
8
|
+
expect(result).toBe('hello world');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should remove newline characters from the start and end of the string', () => {
|
|
12
|
+
const result = DyFM_String.breakTrim('\nhello world\n');
|
|
13
|
+
expect(result).toBe('hello world');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should remove carriage return characters from the start and end of the string', () => {
|
|
17
|
+
const result = DyFM_String.breakTrim('\rhello world\r');
|
|
18
|
+
expect(result).toBe('hello world');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should remove all types of line breaks from the start and end of the string', () => {
|
|
22
|
+
const result = DyFM_String.breakTrim('\r\nhello world\r\n');
|
|
23
|
+
expect(result).toBe('hello world');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should return an empty string if the input is only spaces and line breaks', () => {
|
|
27
|
+
const result = DyFM_String.breakTrim(' \r\n ');
|
|
28
|
+
expect(result).toBe('');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should not alter a string that has no spaces or line breaks at the start or end', () => {
|
|
32
|
+
const result = DyFM_String.breakTrim('hello world');
|
|
33
|
+
expect(result).toBe('hello world');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should handle an empty string input', () => {
|
|
37
|
+
const result = DyFM_String.breakTrim('');
|
|
38
|
+
expect(result).toBe('');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
import { DyFM_TypeCloningFacility } from './type-cloning-facility.util';
|
|
3
|
+
|
|
4
|
+
describe('DyFM_TypeCloningFacility', () => {
|
|
5
|
+
|
|
6
|
+
it('should clone a simple object', () => {
|
|
7
|
+
const original = { a: 1, b: 'test', c: true };
|
|
8
|
+
const cloned = DyFM_TypeCloningFacility.clone(original);
|
|
9
|
+
|
|
10
|
+
expect(cloned).toEqual(original);
|
|
11
|
+
expect(cloned).not.toBe(original);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should clone an object with nested objects', () => {
|
|
15
|
+
const original = { a: { b: { c: 2 } } };
|
|
16
|
+
const cloned = DyFM_TypeCloningFacility.clone(original);
|
|
17
|
+
|
|
18
|
+
expect(cloned).toEqual(original);
|
|
19
|
+
expect(cloned).not.toBe(original);
|
|
20
|
+
expect(cloned.a).not.toBe(original.a);
|
|
21
|
+
expect(cloned.a.b).not.toBe(original.a.b);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
xit('should handle circular references', () => {
|
|
25
|
+
const original: any = { a: 1 };
|
|
26
|
+
original.self = original;
|
|
27
|
+
|
|
28
|
+
const cloned = DyFM_TypeCloningFacility.clone(original);
|
|
29
|
+
|
|
30
|
+
expect(cloned).toEqual({ a: 1, self: cloned });
|
|
31
|
+
expect(cloned).not.toBe(original);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should clone arrays within objects', () => {
|
|
35
|
+
const original = { a: [1, 2, 3] };
|
|
36
|
+
const cloned = DyFM_TypeCloningFacility.clone(original);
|
|
37
|
+
|
|
38
|
+
expect(cloned).toEqual(original);
|
|
39
|
+
expect(cloned.a).not.toBe(original.a);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should clone an array of objects', () => {
|
|
43
|
+
const original = [{ a: 1 }, { b: 2 }];
|
|
44
|
+
const cloned = DyFM_TypeCloningFacility.cloneArray(original);
|
|
45
|
+
|
|
46
|
+
expect(cloned).toEqual(original);
|
|
47
|
+
expect(cloned).not.toBe(original);
|
|
48
|
+
expect(cloned[0]).not.toBe(original[0]);
|
|
49
|
+
expect(cloned[1]).not.toBe(original[1]);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
|
|
2
|
+
import { of } from 'rxjs';
|
|
3
|
+
import { DyFM_clone, DyFM_deepClone, DyFM_delay, DyFM_JSONListify, DyFM_orderedSameObject, DyFM_orderedSameObject2, DyFM_sameObjects, DyFM_sameObjectSurface, DyFM_setExistingValuesOnly, DyFM_sortForTrue, DyFM_surfaceClone, DyFM_takeUntil, DyFM_waitUntil, DyFM_waitUntilAsync } from './utilities.util';
|
|
4
|
+
|
|
5
|
+
describe('Utilities', () => {
|
|
6
|
+
|
|
7
|
+
describe('DyFM_clone', () => {
|
|
8
|
+
it('should clone a simple object', () => {
|
|
9
|
+
const obj = { a: 1, b: 2 };
|
|
10
|
+
const clonedObj = DyFM_clone(obj);
|
|
11
|
+
expect(clonedObj).toEqual(obj);
|
|
12
|
+
expect(clonedObj).not.toBe(obj);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should return the same value for non-object types', () => {
|
|
16
|
+
expect(DyFM_clone(null)).toBeNull();
|
|
17
|
+
expect(DyFM_clone(undefined)).toBeUndefined();
|
|
18
|
+
expect(DyFM_clone(42)).toBe(42);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('DyFM_surfaceClone', () => {
|
|
23
|
+
it('should perform a shallow clone of an object', () => {
|
|
24
|
+
const obj = { a: 1, b: { c: 3 } };
|
|
25
|
+
const clonedObj = DyFM_surfaceClone(obj);
|
|
26
|
+
expect(clonedObj).toEqual(obj);
|
|
27
|
+
expect(clonedObj).not.toBe(obj);
|
|
28
|
+
expect(clonedObj.b).toBe(obj.b);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('DyFM_deepClone', () => {
|
|
33
|
+
it('should perform a deep clone of an object', () => {
|
|
34
|
+
const obj = { a: 1, b: { c: 3 } };
|
|
35
|
+
const clonedObj = DyFM_deepClone(obj);
|
|
36
|
+
expect(clonedObj).toEqual(obj);
|
|
37
|
+
expect(clonedObj).not.toBe(obj);
|
|
38
|
+
expect(clonedObj.b).not.toBe(obj.b);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('DyFM_sameObjects', () => {
|
|
43
|
+
it('should return true for identical objects', () => {
|
|
44
|
+
const objA = { a: 1, b: 2 };
|
|
45
|
+
const objB = { a: 1, b: 2 };
|
|
46
|
+
expect(DyFM_sameObjects(objA, objB)).toBeTrue();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should return false for different objects', () => {
|
|
50
|
+
const objA = { a: 1, b: 2 };
|
|
51
|
+
const objB = { a: 1, b: 3 };
|
|
52
|
+
expect(DyFM_sameObjects(objA, objB)).toBeFalse();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('DyFM_orderedSameObject', () => {
|
|
57
|
+
it('should return true for objects with same keys and values', () => {
|
|
58
|
+
const objA = { a: 1, b: 2 };
|
|
59
|
+
const objB = { b: 2, a: 1 };
|
|
60
|
+
expect(DyFM_orderedSameObject(objA, objB)).toBeTrue();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
xit('should return false for objects with different keys or values', () => {
|
|
64
|
+
const objA = { a: 1, b: 2 };
|
|
65
|
+
const objB = { a: 1, b: 3 };
|
|
66
|
+
expect(DyFM_orderedSameObject(objA, objB)).toBeFalse();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('DyFM_orderedSameObject2', () => {
|
|
71
|
+
it('should return true for objects with same keys and values', () => {
|
|
72
|
+
const objA = { a: 1, b: 2 };
|
|
73
|
+
const objB = { b: 2, a: 1 };
|
|
74
|
+
expect(DyFM_orderedSameObject2(objA, objB)).toBeTrue();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should return false for objects with different keys or values', () => {
|
|
78
|
+
const objA = { a: 1, b: 2 };
|
|
79
|
+
const objB = { a: 1, b: 3 };
|
|
80
|
+
expect(DyFM_orderedSameObject2(objA, objB)).toBeFalse();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('DyFM_sameObjectSurface', () => {
|
|
85
|
+
it('should return true for objects with same surface values', () => {
|
|
86
|
+
const objA = { a: 1, b: 2 };
|
|
87
|
+
const objB = { a: 1, b: 2 };
|
|
88
|
+
expect(DyFM_sameObjectSurface(objA, objB)).toBeTrue();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should return false for objects with different surface values', () => {
|
|
92
|
+
const objA = { a: 1, b: 2 };
|
|
93
|
+
const objB = { a: 1, b: 3 };
|
|
94
|
+
expect(DyFM_sameObjectSurface(objA, objB)).toBeFalse();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
xdescribe('DyFM_setExistingValuesOnly', () => {
|
|
99
|
+
it('should set values only if they exist in the target object', () => {
|
|
100
|
+
const setOn = { a: 1, b: 2 };
|
|
101
|
+
const setTo = { a: 3, c: 4 };
|
|
102
|
+
DyFM_setExistingValuesOnly(setOn, setTo);
|
|
103
|
+
expect(setOn).toEqual({ a: 3, b: 2 });
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('DyFM_delay', () => {
|
|
108
|
+
it('should resolve after a specified delay', async () => {
|
|
109
|
+
const start = Date.now();
|
|
110
|
+
await DyFM_delay(100);
|
|
111
|
+
const end = Date.now();
|
|
112
|
+
expect(end - start).toBeGreaterThanOrEqual(100);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('DyFM_waitUntil', () => {
|
|
117
|
+
it('should resolve when the check function returns true', async () => {
|
|
118
|
+
let condition = false;
|
|
119
|
+
setTimeout(() => condition = true, 100);
|
|
120
|
+
await DyFM_waitUntil(() => condition, 50, 500);
|
|
121
|
+
expect(condition).toBeTrue();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('should reject if the timeout is reached', async () => {
|
|
125
|
+
await expectAsync(DyFM_waitUntil(() => false, 50, 100)).toBeRejectedWith('timeout');
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
describe('DyFM_waitUntilAsync', () => {
|
|
130
|
+
it('should resolve when the async check function returns true', async () => {
|
|
131
|
+
let condition = false;
|
|
132
|
+
setTimeout(() => condition = true, 100);
|
|
133
|
+
await DyFM_waitUntilAsync(async () => condition, 50, 500);
|
|
134
|
+
expect(condition).toBeTrue();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('should reject if the timeout is reached', async () => {
|
|
138
|
+
await expectAsync(DyFM_waitUntilAsync(async () => false, 50, 100)).toBeRejectedWith('timeout');
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
xdescribe('DyFM_takeUntil', () => {
|
|
143
|
+
it('should resolve when the observable emits a value that passes the check', async () => {
|
|
144
|
+
const observable = of(1, 2, 3);
|
|
145
|
+
const result = await DyFM_takeUntil(observable, value => value === 2);
|
|
146
|
+
expect(result).toBe(2);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe('DyFM_sortForTrue', () => {
|
|
151
|
+
it('should sort items based on the check function', () => {
|
|
152
|
+
const items = [{ value: true }, { value: false }];
|
|
153
|
+
items.sort((a, b) => DyFM_sortForTrue(a, b, item => item.value));
|
|
154
|
+
expect(items).toEqual([{ value: true }, { value: false }]);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
describe('DyFM_JSONListify', () => {
|
|
159
|
+
it('should convert a JSON list to an array', () => {
|
|
160
|
+
const JSONList = { 0: 'a', 1: 'b', 2: 'c' };
|
|
161
|
+
const result = DyFM_JSONListify<string>(JSONList);
|
|
162
|
+
expect(result).toEqual(['a', 'b', 'c']);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
+
|
|
2
3
|
import { DyFM_Log } from './log.util';
|
|
3
4
|
|
|
4
5
|
const defaultErrorMsg =
|
|
@@ -174,10 +175,6 @@ export function DyFM_orderedSameObject2<T>(objA: T, objB: T): boolean {
|
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
177
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
178
|
export function DyFM_sameObjectSurface<T>(objA: T, objB: T): boolean {
|
|
182
179
|
let result = true;
|
|
183
180
|
|
|
@@ -300,14 +297,6 @@ export function DyFM_sortForTrue<T>(
|
|
|
300
297
|
return isA === check(b) ? 0 : isA ? -1 : 1;
|
|
301
298
|
}
|
|
302
299
|
|
|
303
|
-
/**
|
|
304
|
-
*
|
|
305
|
-
* @param checkFor
|
|
306
|
-
* @returns
|
|
307
|
-
*
|
|
308
|
-
* @example
|
|
309
|
-
* codes.sort(getSortForTrueFn((c: Code) => c.haveImg));
|
|
310
|
-
*/
|
|
311
300
|
export function DyFM_getSortForTrueFn<T>(
|
|
312
301
|
checkFor: (a: T) => boolean
|
|
313
302
|
): (a: T, b: T) => DyFM_SortDirection {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
import { DyFM_UUID } from './uuid.util';
|
|
3
|
+
import * as UUID from 'uuid';
|
|
4
|
+
|
|
5
|
+
describe('DyFM_UUID', () => {
|
|
6
|
+
describe('generate', () => {
|
|
7
|
+
it('should generate a UUID', () => {
|
|
8
|
+
const uuid = DyFM_UUID.generate();
|
|
9
|
+
expect(UUID.validate(uuid)).toBeTrue();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should generate a unique UUID not in the reserved list', () => {
|
|
13
|
+
const reserved = ['123e4567-e89b-12d3-a456-426614174000'];
|
|
14
|
+
const uuid = DyFM_UUID.generate(reserved);
|
|
15
|
+
expect(reserved.includes(uuid)).toBeFalse();
|
|
16
|
+
expect(UUID.validate(uuid)).toBeTrue();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should generate a UUID even if reserved list is empty', () => {
|
|
20
|
+
const reserved: string[] = [];
|
|
21
|
+
const uuid = DyFM_UUID.generate(reserved);
|
|
22
|
+
expect(UUID.validate(uuid)).toBeTrue();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should generate a UUID when reserved list is undefined', () => {
|
|
26
|
+
const uuid = DyFM_UUID.generate(undefined);
|
|
27
|
+
expect(UUID.validate(uuid)).toBeTrue();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import * as UUID from 'uuid';
|
|
4
4
|
|
|
5
5
|
export class DyFM_UUID {
|
|
6
|
-
static readonly getUUID = UUID.v4;
|
|
6
|
+
/* static readonly getUUID = UUID.v4; */
|
|
7
|
+
|
|
7
8
|
static generate(reserved?: string[]): string {
|
|
8
9
|
let uuid = UUID.v4();
|
|
9
10
|
|
|
@@ -15,4 +16,16 @@ export class DyFM_UUID {
|
|
|
15
16
|
|
|
16
17
|
return uuid;
|
|
17
18
|
}
|
|
19
|
+
|
|
20
|
+
/* static generate(reserved?: string[]): string {
|
|
21
|
+
let uuid = UUID.v4();
|
|
22
|
+
|
|
23
|
+
if (reserved) {
|
|
24
|
+
while (reserved.includes(uuid)) {
|
|
25
|
+
uuid = UUID.v4();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return uuid;
|
|
30
|
+
} */
|
|
18
31
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
|
|
2
|
+
import { DyFM_Log } from '../../_collections/utils/log.util';
|
|
3
|
+
import { DyFM_DataModel_Type } from '../../_enums/data-model-type.enum';
|
|
4
|
+
import { DyFM_Metadata } from '../data-models/metadata.data-model';
|
|
5
|
+
import { DyFM_DataModel_Params, DyFM_DataModel_Settings } from './data-model-params.control-model';
|
|
6
|
+
import { DyFM_DataProperties } from './data-property-params.control-model';
|
|
7
|
+
|
|
8
|
+
describe('DyFM_DataModel_Params', () => {
|
|
9
|
+
class MockMetadata extends DyFM_Metadata {
|
|
10
|
+
// Mock implementation of DyFM_Metadata if needed
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let mockSettings: DyFM_DataModel_Settings<MockMetadata>;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
mockSettings = {
|
|
17
|
+
dataName: 'testModel',
|
|
18
|
+
properties: {} as DyFM_DataProperties<MockMetadata>
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create an instance with the provided settings', () => {
|
|
23
|
+
const params = new DyFM_DataModel_Params(mockSettings);
|
|
24
|
+
expect(params.dataName).toBe('testModel');
|
|
25
|
+
expect(params.properties).toEqual({});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should log an error if properties are missing or not an object', () => {
|
|
29
|
+
spyOn(DyFM_Log, 'error');
|
|
30
|
+
mockSettings.properties = null as any;
|
|
31
|
+
const params = new DyFM_DataModel_Params(mockSettings);
|
|
32
|
+
expect(DyFM_Log.error).toHaveBeenCalledWith(
|
|
33
|
+
'DyFM_DataModel_Params.constructor: Properties are missing in testModel model.'
|
|
34
|
+
);
|
|
35
|
+
expect(params.properties).toEqual({});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should log an error if a property key is missing', () => {
|
|
39
|
+
spyOn(DyFM_Log, 'error');
|
|
40
|
+
mockSettings.properties = { '': { key: '' } } as any;
|
|
41
|
+
new DyFM_DataModel_Params(mockSettings);
|
|
42
|
+
expect(DyFM_Log.error).toHaveBeenCalledWith(
|
|
43
|
+
'DyFM_DataModel_Params.constructor: A property key is missing in testModel model.'
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should set modelType to data if not provided or is data', () => {
|
|
48
|
+
const params = new DyFM_DataModel_Params(mockSettings);
|
|
49
|
+
expect(params.modelType).toBe(DyFM_DataModel_Type.data);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should set dbName based on dataName if not provided', () => {
|
|
53
|
+
const params = new DyFM_DataModel_Params(mockSettings);
|
|
54
|
+
expect(params.dbName).toBe('TestModel');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
xit('should convert dbName to camelCase if it contains underscores', () => {
|
|
58
|
+
mockSettings.dataName = 'test_model';
|
|
59
|
+
const params = new DyFM_DataModel_Params(mockSettings);
|
|
60
|
+
expect(params.dbName).toBe('TestModel');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should return true for constructed method', () => {
|
|
64
|
+
const params = new DyFM_DataModel_Params(mockSettings);
|
|
65
|
+
expect(params.constructed()).toBeTrue();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
|
|
2
|
+
import { DyFM_BasicProperty_Type } from '../../_enums/basic-property-type.enum';
|
|
3
|
+
import { DyFM_DataProperty_Params, DyFM_DataProperty_Settings } from './data-property-params.control-model';
|
|
4
|
+
|
|
5
|
+
describe('DyFM_DataProperty_Params', () => {
|
|
6
|
+
it('should create an instance with given settings', () => {
|
|
7
|
+
const settings: DyFM_DataProperty_Settings<string> = {
|
|
8
|
+
key: 'testKey',
|
|
9
|
+
type: DyFM_BasicProperty_Type.string,
|
|
10
|
+
default: 'defaultValue',
|
|
11
|
+
unique: true,
|
|
12
|
+
readonly: false,
|
|
13
|
+
required: true,
|
|
14
|
+
index: false,
|
|
15
|
+
isDependencyHook: false,
|
|
16
|
+
dependencyDataName: 'dependencyName',
|
|
17
|
+
minlength: 5,
|
|
18
|
+
maxlength: 10,
|
|
19
|
+
subObjectParams: {},
|
|
20
|
+
additionalValidators: [(data) => { console.log(data); }]
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const instance = new DyFM_DataProperty_Params(settings);
|
|
24
|
+
|
|
25
|
+
expect(instance.key).toBe('testKey');
|
|
26
|
+
expect(instance.type).toBe(DyFM_BasicProperty_Type.string);
|
|
27
|
+
expect(instance.default).toBe('defaultValue');
|
|
28
|
+
expect(instance.unique).toBe(true);
|
|
29
|
+
expect(instance.readonly).toBe(false);
|
|
30
|
+
expect(instance.required).toBe(true);
|
|
31
|
+
expect(instance.index).toBe(false);
|
|
32
|
+
expect(instance.isDependencyHook).toBe(false);
|
|
33
|
+
expect(instance.dependencyDataName).toBe('dependencyName');
|
|
34
|
+
expect(instance.minlength).toBe(5);
|
|
35
|
+
expect(instance.maxlength).toBe(10);
|
|
36
|
+
expect(instance.subObjectParams).toEqual({});
|
|
37
|
+
expect(instance.additionalValidators?.length).toBe(1);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should log error if type is missing', () => {
|
|
41
|
+
const consoleErrorSpy = spyOn(console, 'error');
|
|
42
|
+
const settings: DyFM_DataProperty_Settings<string> = {
|
|
43
|
+
key: 'testKey',
|
|
44
|
+
type: undefined as any, // Simulating missing type
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
new DyFM_DataProperty_Params(settings);
|
|
48
|
+
|
|
49
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
50
|
+
'DYNAMO ERROR: ',
|
|
51
|
+
'\n type is missing from DynamoBEDataPropertyParams'
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should log error if isDependencyHook is true but dependencyDataName is missing', () => {
|
|
56
|
+
const consoleErrorSpy = spyOn(console, 'error');
|
|
57
|
+
const settings: DyFM_DataProperty_Settings<string> = {
|
|
58
|
+
key: 'testKey',
|
|
59
|
+
type: DyFM_BasicProperty_Type.string,
|
|
60
|
+
isDependencyHook: true,
|
|
61
|
+
dependencyDataName: undefined
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
new DyFM_DataProperty_Params(settings);
|
|
65
|
+
|
|
66
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
67
|
+
'DYNAMO ERROR: ',
|
|
68
|
+
'\n dependencyName missing for dependencyHook from ' +
|
|
69
|
+
'DynamoBEDataPropertyParams'
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should log error if settings are not provided', () => {
|
|
74
|
+
const consoleErrorSpy = spyOn(console, 'error');
|
|
75
|
+
|
|
76
|
+
new DyFM_DataProperty_Params(undefined as any);
|
|
77
|
+
|
|
78
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
79
|
+
'DYNAMO ERROR: ',
|
|
80
|
+
'\nMISSING DynamoBEDataPropertyParams constructor input'
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
xit('should return correct BEType based on type', () => {
|
|
85
|
+
const settings: DyFM_DataProperty_Settings<any> = {
|
|
86
|
+
type: DyFM_BasicProperty_Type.string
|
|
87
|
+
};
|
|
88
|
+
const instance = new DyFM_DataProperty_Params(settings);
|
|
89
|
+
expect(instance.getBEType()).toBe(String);
|
|
90
|
+
|
|
91
|
+
settings.type = DyFM_BasicProperty_Type.number;
|
|
92
|
+
expect(instance.getBEType()).toBe(Number);
|
|
93
|
+
|
|
94
|
+
settings.type = DyFM_BasicProperty_Type.boolean;
|
|
95
|
+
expect(instance.getBEType()).toBe(Boolean);
|
|
96
|
+
|
|
97
|
+
settings.type = DyFM_BasicProperty_Type.date;
|
|
98
|
+
expect(instance.getBEType()).toBe(Date);
|
|
99
|
+
|
|
100
|
+
settings.type = DyFM_BasicProperty_Type.object;
|
|
101
|
+
expect(instance.getBEType()).toBe(Object);
|
|
102
|
+
|
|
103
|
+
settings.type = 'customType[]';
|
|
104
|
+
expect(instance.getBEType()).toBe(Array);
|
|
105
|
+
|
|
106
|
+
settings.type = 'customFunction =>';
|
|
107
|
+
expect(instance.getBEType()).toBe(Function);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
|
|
2
|
+
import { DyFM_Error } from './error.control-model';
|
|
3
|
+
import { DyFM_Poll } from './poll.control-model';
|
|
4
|
+
|
|
5
|
+
describe('DyFM_Poll', () => {
|
|
6
|
+
let pollInstance: DyFM_Poll<number>;
|
|
7
|
+
let pollDo: jasmine.Spy<(...args: any[]) => Promise<number>>;
|
|
8
|
+
let pollWhile: jasmine.Spy<(res: number) => boolean>;
|
|
9
|
+
let pollEnd: jasmine.Spy<(res: number) => void>;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
pollDo = jasmine.createSpy('pollDo').and.returnValue(Promise.resolve(1));
|
|
13
|
+
pollWhile = jasmine.createSpy('pollWhile').and.returnValue(true);
|
|
14
|
+
pollEnd = jasmine.createSpy('pollEnd');
|
|
15
|
+
|
|
16
|
+
pollInstance = new DyFM_Poll<number>({
|
|
17
|
+
pollDo,
|
|
18
|
+
pollWhile,
|
|
19
|
+
pollEnd,
|
|
20
|
+
pollDelay: 0,
|
|
21
|
+
pollPeriod: 1000,
|
|
22
|
+
stopOnFail: true,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
xit('should initialize with the correct properties', () => {
|
|
27
|
+
expect(pollInstance.running).toBeTrue();
|
|
28
|
+
expect(pollDo).toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should stop polling when stop is called', () => {
|
|
32
|
+
pollInstance.stop();
|
|
33
|
+
expect(pollInstance.running).toBeFalse();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
xit('should call pollEnd and stop polling when pollWhile returns false', async () => {
|
|
37
|
+
pollWhile.and.returnValue(false);
|
|
38
|
+
await pollDo.calls.mostRecent().returnValue;
|
|
39
|
+
expect(pollEnd).toHaveBeenCalledWith(1);
|
|
40
|
+
expect(pollInstance.running).toBeFalse();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
xit('should throw DyFM_Error when pollDo fails and stopOnFail is true', async () => {
|
|
44
|
+
pollDo.and.returnValue(Promise.reject('error'));
|
|
45
|
+
try {
|
|
46
|
+
await pollDo.calls.mostRecent().returnValue;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
expect(error).toEqual(jasmine.any(DyFM_Error));
|
|
49
|
+
}
|
|
50
|
+
expect(pollInstance.running).toBeFalse();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
xit('should restart polling with new arguments', () => {
|
|
54
|
+
const newArgs = [2];
|
|
55
|
+
pollInstance.restartPoll(newArgs);
|
|
56
|
+
expect(pollDo).toHaveBeenCalledWith(...newArgs);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
xit('should restart polling with initial arguments if no new arguments are provided', () => {
|
|
60
|
+
pollInstance.restartPoll();
|
|
61
|
+
expect(pollDo).toHaveBeenCalledWith(...pollInstance['args']);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -10,13 +10,14 @@ import { DyFM_Error } from './error.control-model';
|
|
|
10
10
|
export class DyFM_Poll<T> {
|
|
11
11
|
poll: Subscription;
|
|
12
12
|
running: boolean;
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
13
|
+
|
|
14
|
+
private readonly pollDo: (...args) => Promise<T>;
|
|
15
|
+
private readonly pollWhile: (res: T) => boolean;
|
|
16
|
+
private readonly pollEnd: (res: T) => void;
|
|
17
|
+
private readonly args?: any[];
|
|
18
|
+
private readonly pollDelay?: number;
|
|
19
|
+
private readonly pollPeriod?: number;
|
|
20
|
+
private readonly stopOnFail?: boolean;
|
|
20
21
|
|
|
21
22
|
constructor(
|
|
22
23
|
set: {
|