@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 +8 -0
- package/package.json +1 -1
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +2 -0
- package/src/lib/localStorage-mock.d.ts +13 -0
- package/src/lib/localStorage-mock.d.ts.map +1 -0
- package/src/lib/localStorage-mock.js +37 -0
- package/src/lib/to-throw-type.d.ts +7 -0
- package/src/lib/to-throw-type.d.ts.map +1 -1
package/README.md
CHANGED
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
package/src/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|