@zajno/common 1.1.14 → 1.2.3

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.
Files changed (80) hide show
  1. package/coverage/clover.xml +20 -24
  2. package/coverage/coverage-final.json +3 -3
  3. package/coverage/lcov-report/index.html +18 -18
  4. package/coverage/lcov-report/src/__tests__/helpers/index.html +1 -1
  5. package/coverage/lcov-report/src/__tests__/helpers/main.ts.html +1 -1
  6. package/coverage/lcov-report/src/dates/calc.ts.html +1 -1
  7. package/coverage/lcov-report/src/dates/convert.ts.html +1 -1
  8. package/coverage/lcov-report/src/dates/datex.ts.html +1 -1
  9. package/coverage/lcov-report/src/dates/format.ts.html +1 -1
  10. package/coverage/lcov-report/src/dates/index.html +1 -1
  11. package/coverage/lcov-report/src/dates/index.ts.html +1 -1
  12. package/coverage/lcov-report/src/dates/parse.ts.html +1 -1
  13. package/coverage/lcov-report/src/dates/period.ts.html +1 -1
  14. package/coverage/lcov-report/src/dates/shift.ts.html +1 -1
  15. package/coverage/lcov-report/src/dates/types.ts.html +1 -1
  16. package/coverage/lcov-report/src/dates/yearDate.ts.html +1 -1
  17. package/coverage/lcov-report/src/enumHelper.ts.html +3 -3
  18. package/coverage/lcov-report/src/index.html +1 -1
  19. package/coverage/lcov-report/src/math/arrays.ts.html +1 -1
  20. package/coverage/lcov-report/src/math/calc.ts.html +1 -1
  21. package/coverage/lcov-report/src/math/distribution.ts.html +1 -1
  22. package/coverage/lcov-report/src/math/index.html +1 -1
  23. package/coverage/lcov-report/src/math/index.ts.html +1 -1
  24. package/coverage/lcov-report/src/validation/ValidationErrors.ts.html +4 -10
  25. package/coverage/lcov-report/src/validation/creditCard.ts.html +1 -1
  26. package/coverage/lcov-report/src/validation/helpers.ts.html +1 -1
  27. package/coverage/lcov-report/src/validation/index.html +21 -21
  28. package/coverage/lcov-report/src/validation/index.ts.html +1 -1
  29. package/coverage/lcov-report/src/validation/types.ts.html +1 -1
  30. package/coverage/lcov-report/src/validation/validators.ts.html +10 -16
  31. package/coverage/lcov-report/src/validation/wrappers.ts.html +1 -1
  32. package/coverage/lcov.info +46 -58
  33. package/lib/logger/console.d.ts +3 -4
  34. package/lib/logger/console.d.ts.map +1 -1
  35. package/lib/logger/console.js +6 -8
  36. package/lib/logger/console.js.map +1 -1
  37. package/lib/logger/index.d.ts +7 -4
  38. package/lib/logger/index.d.ts.map +1 -1
  39. package/lib/logger/index.js +31 -19
  40. package/lib/logger/index.js.map +1 -1
  41. package/lib/logger/named.d.ts +6 -9
  42. package/lib/logger/named.d.ts.map +1 -1
  43. package/lib/logger/named.js +18 -22
  44. package/lib/logger/named.js.map +1 -1
  45. package/lib/logger/proxy.d.ts +10 -0
  46. package/lib/logger/proxy.d.ts.map +1 -0
  47. package/lib/logger/proxy.js +28 -0
  48. package/lib/logger/proxy.js.map +1 -0
  49. package/lib/services/localization/ILocalization.d.ts +0 -34
  50. package/lib/services/localization/ILocalization.d.ts.map +1 -1
  51. package/lib/services/localization/defaultShape.d.ts +0 -34
  52. package/lib/services/localization/defaultShape.d.ts.map +1 -1
  53. package/lib/services/localization/defaultShape.js +0 -34
  54. package/lib/services/localization/defaultShape.js.map +1 -1
  55. package/lib/services/localization/validationErrorsStrings.d.ts.map +1 -1
  56. package/lib/services/localization/validationErrorsStrings.js +0 -2
  57. package/lib/services/localization/validationErrorsStrings.js.map +1 -1
  58. package/lib/validation/ValidationErrors.d.ts +2 -4
  59. package/lib/validation/ValidationErrors.d.ts.map +1 -1
  60. package/lib/validation/ValidationErrors.js +2 -4
  61. package/lib/validation/ValidationErrors.js.map +1 -1
  62. package/lib/validation/validators.d.ts +0 -2
  63. package/lib/validation/validators.d.ts.map +1 -1
  64. package/lib/validation/validators.js +0 -2
  65. package/lib/validation/validators.js.map +1 -1
  66. package/package.json +10 -10
  67. package/src/dates/__tests__/dates.test.ts +195 -195
  68. package/src/logger/console.ts +3 -5
  69. package/src/logger/index.ts +36 -20
  70. package/src/logger/named.ts +20 -26
  71. package/src/logger/proxy.ts +29 -0
  72. package/src/math/__tests__/arrays.test.ts +19 -19
  73. package/src/math/__tests__/calc.test.ts +28 -28
  74. package/src/math/__tests__/distribution.test.ts +8 -8
  75. package/src/math/__tests__/index.test.ts +11 -11
  76. package/src/services/localization/defaultShape.ts +0 -34
  77. package/src/services/localization/validationErrorsStrings.ts +0 -2
  78. package/src/validation/ValidationErrors.ts +0 -2
  79. package/src/validation/validators.ts +0 -2
  80. package/yarn.lock +1269 -2003
@@ -1,13 +1,11 @@
1
- import { ILogger, LoggerFunction } from './abstractions';
1
+ import { ILogger } from './abstractions';
2
2
  import { NamedLogger } from './named';
3
3
 
4
- const CONSOLE = console;
4
+ export const CONSOLE: ILogger = console;
5
5
 
6
6
  export class ConsoleLogger extends NamedLogger {
7
7
 
8
- protected get logFunction(): LoggerFunction { return CONSOLE.log; }
9
- protected get warnFunction(): LoggerFunction { return CONSOLE.warn; }
10
- protected get errorFunction(): LoggerFunction { return CONSOLE.error; }
8
+ protected get implementation() { return CONSOLE; }
11
9
 
12
10
  constructor(name?: string, enabled = true) {
13
11
  super(name, enabled);
@@ -1,5 +1,6 @@
1
- import { ILogger, ILoggerSwitchable, LoggerFunction } from './abstractions';
2
- import { ConsoleLogger } from './console';
1
+ import { ILogger, LoggerFunction } from './abstractions';
2
+ import { CONSOLE, ConsoleLogger } from './console';
3
+ import { EMPTY_LOGGER, ProxyLogger } from './proxy';
3
4
 
4
5
  export { NamedLogger } from './named';
5
6
  export { ILogger, LoggerFunction };
@@ -7,40 +8,55 @@ export { ConsoleLogger };
7
8
 
8
9
  // TBD Introduce more logger types ?
9
10
  export type LoggerTypes = 'console';
11
+ export type LoggerFactory = (() => ILogger);
10
12
 
11
- let Enabled: LoggerTypes | false = process.env.COMMON_UTILS_LOGGER as LoggerTypes || false;
13
+ let Mode: LoggerTypes | false | LoggerFactory = process.env.COMMON_UTILS_LOGGER as LoggerTypes || false;
12
14
 
13
- const createdLoggers: ILoggerSwitchable[] = [];
15
+ const proxies: ProxyLogger[] = [];
14
16
 
15
- function _create(name: string, forceDisable: boolean) {
16
- switch (Enabled) {
17
+ function _createImplementation(): ILogger {
18
+ switch (Mode) {
17
19
  case 'console': {
18
- return new ConsoleLogger(name, !forceDisable);
20
+ return CONSOLE;
21
+ }
22
+
23
+ case false: {
24
+ return EMPTY_LOGGER;
19
25
  }
20
26
 
21
27
  default: {
22
- return new ConsoleLogger(name, false);
28
+ if (typeof Mode === 'function') {
29
+ return Mode();
30
+ }
31
+
32
+ return undefined;
23
33
  }
24
34
  }
25
35
  }
26
36
 
27
- export function createLogger(name = '', forceDisable = false): ILogger {
28
- const result = _create(name, forceDisable);
29
- createdLoggers.push(result);
30
- return result;
37
+ export function createLogger(name: string, forceDisable = false): ILogger {
38
+ const result = _createImplementation();
39
+ const proxy = new ProxyLogger(result, name, !forceDisable);
40
+ proxies.push(proxy);
41
+ return proxy;
31
42
  }
32
43
 
33
- const logger = new ConsoleLogger('', !!Enabled);
34
- createdLoggers.push(logger);
44
+ export function setMode(mode: typeof Mode) {
45
+ if (Mode === mode) {
46
+ return;
47
+ }
35
48
 
36
- export function setEnabled(enabled: LoggerTypes | false) {
37
- Enabled = enabled;
49
+ Mode = mode;
38
50
 
39
- if (!Enabled) {
40
- createdLoggers.forEach(l => l.disable());
51
+ if (!Mode) {
52
+ proxies.forEach(l => l.disable());
41
53
  } else {
42
- createdLoggers.forEach(l => l.enable());
54
+ proxies.forEach(l => l.setLogger(_createImplementation()));
43
55
  }
44
56
  }
45
57
 
46
- export default logger as ILogger;
58
+ export function getMode() { return Mode; }
59
+
60
+ const logger: ILogger = createLogger('', false);
61
+
62
+ export default logger;
@@ -1,25 +1,17 @@
1
1
  import { ILogger, ILoggerSwitchable, LoggerFunction } from './abstractions';
2
2
 
3
- const EMPTY_FUNCTION = () => { /* no-op */ };
4
-
5
- function addArg(func: (...args: any[]) => any, value: string) {
6
- return (...args: any[]) => func(value, ...args);
7
- }
3
+ export const EMPTY_FUNCTION = () => { /* no-op */ };
8
4
 
9
5
  export abstract class NamedLogger implements ILogger, ILoggerSwitchable {
10
- private _log: LoggerFunction = null;
11
- private _warn: LoggerFunction = null;
12
- private _error: LoggerFunction = null;
6
+ public log: LoggerFunction = null;
7
+ public warn: LoggerFunction = null;
8
+ public error: LoggerFunction = null;
13
9
 
14
10
  private _name: string = null;
15
11
 
16
- get log() { return this._log; }
17
- get warn() { return this._warn; }
18
- get error() { return this._error; }
12
+ get name() { return this._name; }
19
13
 
20
- protected abstract get logFunction(): LoggerFunction;
21
- protected abstract get warnFunction(): LoggerFunction;
22
- protected abstract get errorFunction(): LoggerFunction;
14
+ protected abstract get implementation(): ILogger;
23
15
 
24
16
  constructor(name?: string, enabled = true) {
25
17
  this._name = name;
@@ -34,20 +26,22 @@ export abstract class NamedLogger implements ILogger, ILoggerSwitchable {
34
26
  enable(overrideName = null) {
35
27
  this._name = overrideName || this._name;
36
28
 
37
- this._log = this._name
38
- ? addArg(this.logFunction, this._name)
39
- : this.logFunction;
40
- this._warn = this._name
41
- ? addArg(this.warnFunction, this._name)
42
- : this.warnFunction;
43
- this._error = this._name
44
- ? addArg(this.errorFunction, this._name)
45
- : this.errorFunction;
29
+ this.log = this._name
30
+ ? (...args) => this.implementation.log(this._name, ...args)
31
+ : (...args) => this.implementation.log(...args);
32
+
33
+ this.warn = this._name
34
+ ? (...args) => this.implementation.warn(this._name, ...args)
35
+ : (...args) => this.implementation.warn(...args);
36
+
37
+ this.error = this._name
38
+ ? (...args) => this.implementation.error(this._name, ...args)
39
+ : (...args) => this.implementation.error(...args);
46
40
  }
47
41
 
48
42
  disable() {
49
- this._log = EMPTY_FUNCTION;
50
- this._warn = EMPTY_FUNCTION;
51
- this._error = EMPTY_FUNCTION;
43
+ this.log = EMPTY_FUNCTION;
44
+ this.warn = EMPTY_FUNCTION;
45
+ this.error = EMPTY_FUNCTION;
52
46
  }
53
47
  }
@@ -0,0 +1,29 @@
1
+ import { ILogger } from './abstractions';
2
+ import { EMPTY_FUNCTION, NamedLogger } from './named';
3
+
4
+ export const EMPTY_LOGGER: ILogger = {
5
+ log: EMPTY_FUNCTION,
6
+ warn: EMPTY_FUNCTION,
7
+ error: EMPTY_FUNCTION,
8
+ };
9
+
10
+ export class ProxyLogger extends NamedLogger {
11
+
12
+ protected get implementation() { return this._logger || EMPTY_LOGGER; }
13
+
14
+ private _logger: ILogger = null;
15
+
16
+ constructor(logger: ILogger, name?: string, enabled = true) {
17
+ super(name, enabled);
18
+ this._logger = logger;
19
+ }
20
+
21
+ public setLogger(logger: ILogger) {
22
+ this._logger = logger || null;
23
+ if (this._logger) {
24
+ this.enable();
25
+ } else {
26
+ this.disable();
27
+ }
28
+ }
29
+ }
@@ -17,43 +17,43 @@ describe('math/arrays', () => {
17
17
 
18
18
  expect(() => arrays.arrayCompare([1, 2, 3], false, null)).toThrow();
19
19
 
20
- expect(arrays.arrayCompare([1, 2, 3], false, (i, t) => i > t)).toEqual(3);
21
- expect(arrays.arrayCompare([1, 2, 3], false, (i, t) => i < t)).toEqual(1);
20
+ expect(arrays.arrayCompare([1, 2, 3], false, (i, t) => i > t)).toBe(3);
21
+ expect(arrays.arrayCompare([1, 2, 3], false, (i, t) => i < t)).toBe(1);
22
22
 
23
- expect(arrays.arrayCompare([-1, 2, -3], true, (i, t) => i > t)).toEqual(3);
23
+ expect(arrays.arrayCompare([-1, 2, -3], true, (i, t) => i > t)).toBe(3);
24
24
  expect(arrays.arrayCompare([-1, 2, -3], true, (i, t) => i < t)).toEqual(-1);
25
25
  });
26
26
 
27
27
  it('arrayMax', () => {
28
28
  expect(arrays.arrayMax([], false)).toBeNull();
29
- expect(arrays.arrayMax([1, 2, 3], false)).toEqual(3);
30
- expect(arrays.arrayMax([-1, 2, -3], true)).toEqual(3);
29
+ expect(arrays.arrayMax([1, 2, 3], false)).toBe(3);
30
+ expect(arrays.arrayMax([-1, 2, -3], true)).toBe(3);
31
31
  });
32
32
 
33
33
  it('arrayMin', () => {
34
34
  expect(arrays.arrayMin([], false)).toBeNull();
35
- expect(arrays.arrayMin([1, 2, 3], false)).toEqual(1);
35
+ expect(arrays.arrayMin([1, 2, 3], false)).toBe(1);
36
36
  expect(arrays.arrayMin([-1, 2, -3], true)).toEqual(-1);
37
37
  });
38
38
 
39
39
  it('arrayAverage', () => {
40
- expect(arrays.arrayAverage(null)).toEqual(0);
41
- expect(arrays.arrayAverage([])).toEqual(0);
42
- expect(arrays.arrayAverage([1, 2, 3])).toEqual(2);
40
+ expect(arrays.arrayAverage(null)).toBe(0);
41
+ expect(arrays.arrayAverage([])).toBe(0);
42
+ expect(arrays.arrayAverage([1, 2, 3])).toBe(2);
43
43
  expect(arrays.arrayAverage([-2, 2, -3])).toEqual(-1);
44
- expect(arrays.arrayAverage([-1, 2, -3], true)).toEqual(2);
44
+ expect(arrays.arrayAverage([-1, 2, -3], true)).toBe(2);
45
45
  });
46
46
 
47
47
  it('arrayCount', () => {
48
- expect(arrays.arrayCount(null, null)).toEqual(0);
49
- expect(arrays.arrayCount([], null)).toEqual(0);
48
+ expect(arrays.arrayCount(null, null)).toBe(0);
49
+ expect(arrays.arrayCount([], null)).toBe(0);
50
50
 
51
51
  expect(() => arrays.arrayCount([1, 2, 3], null)).toThrow();
52
- expect(arrays.arrayCount([1, 2, 3], i => i >= 2)).toEqual(2);
52
+ expect(arrays.arrayCount([1, 2, 3], i => i >= 2)).toBe(2);
53
53
 
54
54
  type T = { a: number };
55
55
  const tArr: T[] = [ { a: 1 }, { a: 2 }, { a: 3 } ];
56
- expect(arrays.arrayCount(tArr, i => i.a >= 2)).toEqual(2);
56
+ expect(arrays.arrayCount(tArr, i => i.a >= 2)).toBe(2);
57
57
  });
58
58
 
59
59
  it('arrayFirstResult', () => {
@@ -61,7 +61,7 @@ describe('math/arrays', () => {
61
61
  expect(arrays.arrayFirstResult([], null)).toBeFalsy();
62
62
 
63
63
  expect(() => arrays.arrayFirstResult([1, 2, 3], null)).toThrow();
64
- expect(arrays.arrayFirstResult([1, 2, 3], i => i == 2 ? 'pass' : false)).toEqual('pass');
64
+ expect(arrays.arrayFirstResult([1, 2, 3], i => i == 2 ? 'pass' : false)).toBe('pass');
65
65
  });
66
66
 
67
67
  it('normalize', () => {
@@ -75,7 +75,7 @@ describe('math/arrays', () => {
75
75
  expect(() => arrays.randomArrayItem(null)).toThrow();
76
76
  expect(arrays.randomArrayItem([])).toBeNull();
77
77
 
78
- expect(arrays.randomArrayItem([1])).toEqual(1);
78
+ expect(arrays.randomArrayItem([1])).toBe(1);
79
79
  expect([1, 2, 3]).toContain(arrays.randomArrayItem([1, 2, 3]));
80
80
 
81
81
  const arr1 = [1, 2, 3], arr2 = arr1.slice();
@@ -135,9 +135,9 @@ describe('math/arrays', () => {
135
135
  it('findIndexLeast', () => {
136
136
  expect(() => arrays.findIndexLeast(0, null)).toThrow();
137
137
 
138
- expect(arrays.findIndexLeast(2, [3, 2, 1])).toEqual(0);
139
- expect(arrays.findIndexLeast(2, [3, 2, 1], true)).toEqual(2);
140
- expect(arrays.findIndexLeast(2, [1, 2, 3])).toEqual(2);
138
+ expect(arrays.findIndexLeast(2, [3, 2, 1])).toBe(0);
139
+ expect(arrays.findIndexLeast(2, [3, 2, 1], true)).toBe(2);
140
+ expect(arrays.findIndexLeast(2, [1, 2, 3])).toBe(2);
141
141
 
142
142
  });
143
143
  });
@@ -2,29 +2,29 @@ import * as calc from '../calc';
2
2
 
3
3
  describe('math/calc', () => {
4
4
  it('clamp', () => {
5
- expect(calc.clamp(123)).toEqual(123);
6
- expect(calc.clamp(123, 10)).toEqual(123);
7
- expect(calc.clamp(0, 1, 2, false)).toEqual(1);
8
- expect(calc.clamp(0, 1, 2, true)).toEqual(2);
9
- expect(calc.clamp(3, 1, 2, false)).toEqual(2);
10
- expect(calc.clamp(3, 1, 2, true)).toEqual(1);
11
- expect(calc.clamp(15, 10, 20, false)).toEqual(15);
12
- expect(calc.clamp(15, 10, 20, true)).toEqual(15);
5
+ expect(calc.clamp(123)).toBe(123);
6
+ expect(calc.clamp(123, 10)).toBe(123);
7
+ expect(calc.clamp(0, 1, 2, false)).toBe(1);
8
+ expect(calc.clamp(0, 1, 2, true)).toBe(2);
9
+ expect(calc.clamp(3, 1, 2, false)).toBe(2);
10
+ expect(calc.clamp(3, 1, 2, true)).toBe(1);
11
+ expect(calc.clamp(15, 10, 20, false)).toBe(15);
12
+ expect(calc.clamp(15, 10, 20, true)).toBe(15);
13
13
  });
14
14
 
15
15
  it('clamp01', () => {
16
- expect(calc.clamp01(-1)).toEqual(0);
17
- expect(calc.clamp01(0)).toEqual(0);
18
- expect(calc.clamp01(0.5)).toEqual(0.5);
19
- expect(calc.clamp01(1)).toEqual(1);
20
- expect(calc.clamp01(2)).toEqual(1);
16
+ expect(calc.clamp01(-1)).toBe(0);
17
+ expect(calc.clamp01(0)).toBe(0);
18
+ expect(calc.clamp01(0.5)).toBe(0.5);
19
+ expect(calc.clamp01(1)).toBe(1);
20
+ expect(calc.clamp01(2)).toBe(1);
21
21
  });
22
22
 
23
23
  it('contains', () => {
24
- expect(calc.contains(1, 2, 3)).toEqual(false);
25
- expect(calc.contains(1, 3, 2)).toEqual(false);
26
- expect(calc.contains(15, 10, 20)).toEqual(true);
27
- expect(calc.contains(15, 20, 10)).toEqual(true);
24
+ expect(calc.contains(1, 2, 3)).toBe(false);
25
+ expect(calc.contains(1, 3, 2)).toBe(false);
26
+ expect(calc.contains(15, 10, 20)).toBe(true);
27
+ expect(calc.contains(15, 20, 10)).toBe(true);
28
28
  });
29
29
 
30
30
  it('getIntersection', () => {
@@ -33,20 +33,20 @@ describe('math/calc', () => {
33
33
  });
34
34
 
35
35
  it('roundNumber', () => {
36
- expect(calc.roundNumber(10)).toEqual(10);
37
- expect(calc.roundNumber(10.1)).toEqual(10.1);
38
- expect(calc.roundNumber(10.12)).toEqual(10.12);
39
- expect(calc.roundNumber(10.123)).toEqual(10.12);
40
- expect(calc.roundNumber(10.1234)).toEqual(10.12);
41
- expect(calc.roundNumber(10.1234, 4)).toEqual(10.1234);
42
- expect(calc.roundNumber(10.1235, 3)).toEqual(10.124);
43
- expect(calc.roundNumber(10.1234, 3, 'ceil')).toEqual(10.124);
44
- expect(calc.roundNumber(10.1239, 3, 'floor')).toEqual(10.123);
36
+ expect(calc.roundNumber(10)).toBe(10);
37
+ expect(calc.roundNumber(10.1)).toBe(10.1);
38
+ expect(calc.roundNumber(10.12)).toBe(10.12);
39
+ expect(calc.roundNumber(10.123)).toBe(10.12);
40
+ expect(calc.roundNumber(10.1234)).toBe(10.12);
41
+ expect(calc.roundNumber(10.1234, 4)).toBe(10.1234);
42
+ expect(calc.roundNumber(10.1235, 3)).toBe(10.124);
43
+ expect(calc.roundNumber(10.1234, 3, 'ceil')).toBe(10.124);
44
+ expect(calc.roundNumber(10.1239, 3, 'floor')).toBe(10.123);
45
45
  });
46
46
 
47
47
  it('roundHalf', () => {
48
- expect(calc.roundHalf(12.213)).toEqual(12);
49
- expect(calc.roundHalf(12.999)).toEqual(13);
48
+ expect(calc.roundHalf(12.213)).toBe(12);
49
+ expect(calc.roundHalf(12.999)).toBe(13);
50
50
  });
51
51
 
52
52
  describe('random', () => {
@@ -6,20 +6,20 @@ describe('math/distribution', () => {
6
6
 
7
7
  const r1 = distribution.extendDistribution<TKeys>(1, 'type1');
8
8
  expect(r1).toBeTruthy();
9
- expect(r1.total).toEqual(1);
10
- expect(r1.byType.type1).toEqual(1);
9
+ expect(r1.total).toBe(1);
10
+ expect(r1.byType.type1).toBe(1);
11
11
 
12
12
  distribution.extendDistribution(3, 'type2', r1);
13
- expect(r1.total).toEqual(4);
14
- expect(r1.byType.type1).toEqual(1);
15
- expect(r1.byType.type2).toEqual(3);
13
+ expect(r1.total).toBe(4);
14
+ expect(r1.byType.type1).toBe(1);
15
+ expect(r1.byType.type2).toBe(3);
16
16
 
17
17
  const d: distribution.Distribution<TKeys> = { total: 0, byType: null };
18
18
  distribution.extendDistribution(1, 'type1', d);
19
- expect(d.total).toEqual(1);
20
- expect(d.byType.type1).toEqual(1);
19
+ expect(d.total).toBe(1);
20
+ expect(d.byType.type1).toBe(1);
21
21
  expect(d.byType.type2).toBeUndefined();
22
22
 
23
- expect(distribution.extendDistribution(0, 'type1').total).toEqual(0);
23
+ expect(distribution.extendDistribution(0, 'type1').total).toBe(0);
24
24
  });
25
25
  });
@@ -2,19 +2,19 @@ import * as math from '../index';
2
2
 
3
3
  describe('math', () => {
4
4
  it('getNumberSuffix', () => {
5
- expect(math.getNumberSuffix(1)).toEqual('st');
6
- expect(math.getNumberSuffix(11)).toEqual('st');
7
- expect(math.getNumberSuffix(11111)).toEqual('st');
5
+ expect(math.getNumberSuffix(1)).toBe('st');
6
+ expect(math.getNumberSuffix(11)).toBe('st');
7
+ expect(math.getNumberSuffix(11111)).toBe('st');
8
8
 
9
- expect(math.getNumberSuffix(2)).toEqual('nd');
10
- expect(math.getNumberSuffix(1232)).toEqual('nd');
11
- expect(math.getNumberSuffix(32412.99)).toEqual('th');
9
+ expect(math.getNumberSuffix(2)).toBe('nd');
10
+ expect(math.getNumberSuffix(1232)).toBe('nd');
11
+ expect(math.getNumberSuffix(32412.99)).toBe('th');
12
12
 
13
- expect(math.getNumberSuffix(3)).toEqual('rd');
14
- expect(math.getNumberSuffix(323)).toEqual('rd');
15
- expect(math.getNumberSuffix(1233.233)).toEqual('th');
13
+ expect(math.getNumberSuffix(3)).toBe('rd');
14
+ expect(math.getNumberSuffix(323)).toBe('rd');
15
+ expect(math.getNumberSuffix(1233.233)).toBe('th');
16
16
 
17
- expect(math.getNumberSuffix(0)).toEqual('th');
18
- expect(math.getNumberSuffix(145)).toEqual('th');
17
+ expect(math.getNumberSuffix(0)).toBe('th');
18
+ expect(math.getNumberSuffix(145)).toBe('th');
19
19
  });
20
20
  });
@@ -16,45 +16,11 @@ export const Strings = {
16
16
  PasswordsShouldMatch: 'Passwords should match',
17
17
  FirstName: 'First name is required',
18
18
  LastName: 'Last name is required',
19
- Occupation: 'What\'s your client\'s job?',
20
- Goal: 'Choose a goal to achieve',
21
19
  OnlyDigit: 'Only digits are valid',
22
20
  Website: 'Incorrect website',
23
21
  Linkedin: 'Incorrect Linkedin link',
24
22
  },
25
23
  UnknownServerError: 'Something went wrong and we were not able to process your request. Please contact the administrator.',
26
- ClientStatuses: {
27
- Active: 'Active',
28
- Invited: 'Invited',
29
- Inactive: 'Inactive',
30
- },
31
- BubbleChartStatus: {
32
- Things: 'Things',
33
- People: 'People',
34
- Places: 'Places',
35
- },
36
- Locations: {
37
- AtWork: 'At work',
38
- OnAWalk: 'On a walk',
39
- InThePark: 'At the park',
40
- Somewhere: 'Somewhere else',
41
- AtHome: 'At home',
42
- InTransit: 'In transition',
43
- },
44
- Sentiments: {
45
- Undefined: 'Unknown',
46
- VeryPositive: 'Very Positive',
47
- Positive: 'Positive',
48
- Mixed: 'Mixed',
49
- Difficult: 'Difficult',
50
- Rough: 'Rough',
51
- },
52
- Periods: {
53
- ThisWeek: 'this week',
54
- Month: 'this month',
55
- Months3: 'last 3 months',
56
- Months6: 'last 6 months',
57
- },
58
24
  };
59
25
 
60
26
  export type StringsShape = typeof Strings;
@@ -18,8 +18,6 @@ export default function Create(strings: StringsShape): ValidationErrorsStrings {
18
18
 
19
19
  [ValidationErrors.FirstName]: strings.Validation.FirstName,
20
20
  [ValidationErrors.LastName]: strings.Validation.LastName,
21
- [ValidationErrors.Occupation]: strings.Validation.Occupation,
22
- [ValidationErrors.Goal]: strings.Validation.Goal,
23
21
  [ValidationErrors.OnlyDigit]: strings.Validation.OnlyDigit,
24
22
  [ValidationErrors.Website]: strings.Validation.Website,
25
23
  [ValidationErrors.Linkedin]: strings.Validation.Linkedin,
@@ -17,8 +17,6 @@ export enum ValidationErrors {
17
17
  EmailIsInUse,
18
18
  FirstName,
19
19
  LastName,
20
- Occupation,
21
- Goal,
22
20
  Website,
23
21
  Linkedin,
24
22
  }
@@ -32,8 +32,6 @@ export const Validators = {
32
32
 
33
33
  firstName: <T = string>(val: T) => val ? ValidationErrors.None : ValidationErrors.FirstName,
34
34
  lastName: <T = string>(val: T) => val ? ValidationErrors.None : ValidationErrors.LastName,
35
- occupation: <T = string>(val: T) => val ? ValidationErrors.None : ValidationErrors.Occupation,
36
- goal: <T = string>(val: T) => val ? ValidationErrors.None : ValidationErrors.Goal,
37
35
 
38
36
  fullName: (val: string) => ValidatorsRegExps.name.test(val.trim()) ? ValidationErrors.None : ValidationErrors.InvalidNameFormat,
39
37
  onlyEnglish: (val: string) => ValidatorsRegExps.englishLetters.test(val) ? ValidationErrors.None : ValidationErrors.OnlyEnglishLetters,