@digitaldefiance/express-suite-test-utils 1.0.1 → 1.0.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.
package/README.md CHANGED
@@ -70,6 +70,14 @@ MIT
70
70
 
71
71
  ## ChangeLog
72
72
 
73
+ ### v1.0.3
74
+
75
+ - Add jest global declaration for toThrowType
76
+
77
+ ### v1.0.2
78
+
79
+ - Add LocalStorageMock
80
+
73
81
  ### v1.0.1
74
82
 
75
83
  - Bugfix release, fixing lack of js files in tarball
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/express-suite-test-utils",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Test utilities for Digital Defiance Express Suite",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
package/src/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from './lib/to-throw-type';
2
2
  export * from './lib/console';
3
+ export * from './lib/localStorage-mock';
4
+ export * from './lib/localStorage-mock';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-express-suite-test-utils/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-express-suite-test-utils/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAA"}
package/src/index.js CHANGED
@@ -3,3 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./lib/to-throw-type"), exports);
5
5
  tslib_1.__exportStar(require("./lib/console"), exports);
6
+ tslib_1.__exportStar(require("./lib/localStorage-mock"), exports);
7
+ tslib_1.__exportStar(require("./lib/localStorage-mock"), exports);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Simple localStorage mock for Node.js test environment
3
+ */
4
+ export declare class LocalStorageMock implements Storage {
5
+ private store;
6
+ get length(): number;
7
+ clear(): void;
8
+ getItem(key: string): string | null;
9
+ key(index: number): string | null;
10
+ removeItem(key: string): void;
11
+ setItem(key: string, value: string): void;
12
+ }
13
+ //# sourceMappingURL=localStorage-mock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localStorage-mock.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-test-utils/src/lib/localStorage-mock.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAiB,YAAW,OAAO;IAC9C,OAAO,CAAC,KAAK,CAAkC;IAE/C,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAInC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAKjC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI7B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAG1C"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocalStorageMock = void 0;
4
+ /**
5
+ * Simple localStorage mock for Node.js test environment
6
+ */
7
+ class LocalStorageMock {
8
+ store = new Map();
9
+ get length() {
10
+ return this.store.size;
11
+ }
12
+ clear() {
13
+ this.store.clear();
14
+ }
15
+ getItem(key) {
16
+ return this.store.get(key) ?? null;
17
+ }
18
+ key(index) {
19
+ const keys = Array.from(this.store.keys());
20
+ return keys[index] ?? null;
21
+ }
22
+ removeItem(key) {
23
+ this.store.delete(key);
24
+ }
25
+ setItem(key, value) {
26
+ this.store.set(key, value);
27
+ }
28
+ }
29
+ exports.LocalStorageMock = LocalStorageMock;
30
+ // Set up global localStorage mock
31
+ if (typeof globalThis.localStorage === 'undefined') {
32
+ Object.defineProperty(globalThis, 'localStorage', {
33
+ value: new LocalStorageMock(),
34
+ writable: true,
35
+ configurable: true,
36
+ });
37
+ }
@@ -1,5 +1,12 @@
1
1
  import type { MatcherContext } from 'expect';
2
2
  export type ErrorClass<E extends Error> = new (...args: any[]) => E;
3
+ declare global {
4
+ namespace jest {
5
+ interface Matchers<R> {
6
+ toThrowType<E extends Error>(errorType: ErrorClass<E>, validator?: (error: E) => void): R;
7
+ }
8
+ }
9
+ }
3
10
  export declare const toThrowType: <E extends Error>(this: MatcherContext, received: (() => unknown | Promise<unknown>) | Promise<unknown>, errorType: ErrorClass<E>, validator?: (error: E) => void) => Promise<{
4
11
  pass: boolean;
5
12
  message: () => string;
@@ -1 +1 @@
1
- {"version":3,"file":"to-throw-type.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-test-utils/src/lib/to-throw-type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAI7C,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,KAAK,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAoDpE,eAAO,MAAM,WAAW,GAAmB,CAAC,SAAS,KAAK,EACxD,MAAM,cAAc,EACpB,UAAU,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,EAC/D,WAAW,UAAU,CAAC,CAAC,CAAC,EACxB,YAAY,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KAC7B,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,MAAM,CAAA;CAAE,CA4HlD,CAAC"}
1
+ {"version":3,"file":"to-throw-type.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-test-utils/src/lib/to-throw-type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAI7C,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,KAAK,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEpE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,IAAI,CAAC;QACb,UAAU,QAAQ,CAAC,CAAC;YAClB,WAAW,CAAC,CAAC,SAAS,KAAK,EACzB,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EACxB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAC7B,CAAC,CAAC;SACN;KACF;CACF;AAoDD,eAAO,MAAM,WAAW,GAAmB,CAAC,SAAS,KAAK,EACxD,MAAM,cAAc,EACpB,UAAU,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,EAC/D,WAAW,UAAU,CAAC,CAAC,CAAC,EACxB,YAAY,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KAC7B,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,MAAM,CAAA;CAAE,CA4HlD,CAAC"}