@digitaldefiance/express-suite-test-utils 1.0.1 → 1.0.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/README.md CHANGED
@@ -70,6 +70,10 @@ MIT
70
70
 
71
71
  ## ChangeLog
72
72
 
73
+ ### v1.0.2
74
+
75
+ - Add LocalStorageMock
76
+
73
77
  ### v1.0.1
74
78
 
75
79
  - 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.2",
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
+ }