@luvio/adapter-test-library 0.142.1 → 0.142.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 (51) hide show
  1. package/package.json +13 -6
  2. package/babel.config.js +0 -1
  3. package/dist/umd/es2018/test-library.js +0 -600
  4. package/dist/umd/es2018/types/MockDurableStore.d.ts +0 -16
  5. package/dist/umd/es2018/types/adapterRoundtrip.d.ts +0 -35
  6. package/dist/umd/es2018/types/customMatchers.d.ts +0 -10
  7. package/dist/umd/es2018/types/durableStorePersistence.d.ts +0 -13
  8. package/dist/umd/es2018/types/jest.setup.d.ts +0 -1
  9. package/dist/umd/es2018/types/main.d.ts +0 -9
  10. package/dist/umd/es2018/types/mocks.d.ts +0 -17
  11. package/dist/umd/es2018/types/network.d.ts +0 -38
  12. package/dist/umd/es2018/types/utils.d.ts +0 -39
  13. package/dist/umd/es2018/types/verification.d.ts +0 -2
  14. package/dist/umd/es5/test-library.js +0 -818
  15. package/dist/umd/es5/types/MockDurableStore.d.ts +0 -16
  16. package/dist/umd/es5/types/adapterRoundtrip.d.ts +0 -35
  17. package/dist/umd/es5/types/customMatchers.d.ts +0 -10
  18. package/dist/umd/es5/types/durableStorePersistence.d.ts +0 -13
  19. package/dist/umd/es5/types/jest.setup.d.ts +0 -1
  20. package/dist/umd/es5/types/main.d.ts +0 -9
  21. package/dist/umd/es5/types/mocks.d.ts +0 -17
  22. package/dist/umd/es5/types/network.d.ts +0 -38
  23. package/dist/umd/es5/types/utils.d.ts +0 -39
  24. package/dist/umd/es5/types/verification.d.ts +0 -2
  25. package/jest.config.js +0 -16
  26. package/matcher-types.d.ts +0 -10
  27. package/project.json +0 -8
  28. package/rollup.config.js +0 -33
  29. package/src/MockDurableStore.ts +0 -145
  30. package/src/__tests__/MockDurableStore.spec.ts +0 -53
  31. package/src/adapterRoundtrip.ts +0 -101
  32. package/src/customMatchers.ts +0 -17
  33. package/src/durableStorePersistence.ts +0 -34
  34. package/src/jest.setup.ts +0 -4
  35. package/src/main.ts +0 -26
  36. package/src/mocks.ts +0 -31
  37. package/src/network.ts +0 -240
  38. package/src/utils.ts +0 -207
  39. package/src/verification.ts +0 -60
  40. package/tsconfig.json +0 -4
  41. /package/dist/{es/es2018/test-library.js → test-library.js} +0 -0
  42. /package/dist/{es/es2018/types → types}/MockDurableStore.d.ts +0 -0
  43. /package/dist/{es/es2018/types → types}/adapterRoundtrip.d.ts +0 -0
  44. /package/dist/{es/es2018/types → types}/customMatchers.d.ts +0 -0
  45. /package/dist/{es/es2018/types → types}/durableStorePersistence.d.ts +0 -0
  46. /package/dist/{es/es2018/types → types}/jest.setup.d.ts +0 -0
  47. /package/dist/{es/es2018/types → types}/main.d.ts +0 -0
  48. /package/dist/{es/es2018/types → types}/mocks.d.ts +0 -0
  49. /package/dist/{es/es2018/types → types}/network.d.ts +0 -0
  50. /package/dist/{es/es2018/types → types}/utils.d.ts +0 -0
  51. /package/dist/{es/es2018/types → types}/verification.d.ts +0 -0
@@ -1,35 +0,0 @@
1
- import type { AdapterFactory, NetworkAdapter, Snapshot } from '@luvio/engine';
2
- import { Luvio } from '@luvio/engine';
3
- import type { MockPayload } from './network';
4
- export declare function buildLuvioInstance(mockNetworkAdapter: NetworkAdapter): Luvio;
5
- type AdapterRoundtripTestParams<C, D> = AdapterNetworkRoundtripTestParams<C, D> | AdapterNetworkRoundtripWithLuvioTestParams<C, D> | AdapterCacheHitRoundtripTestParams<C, D>;
6
- type AdapterTest<C, D> = {
7
- adapterFactory: AdapterFactory<C, D>;
8
- adapterConfig: C;
9
- privateProperties?: string[];
10
- };
11
- type AdapterTestWithInjectedLuvio<C, D> = AdapterTest<C, D> & {
12
- luvio: Luvio;
13
- expectedData: D;
14
- };
15
- type NetworkConfig = {
16
- request: MockPayload['networkArgs'];
17
- response: any;
18
- };
19
- type AdapterNetworkRoundtripTestParams<C, D> = AdapterTest<C, D> & {
20
- type: 'network';
21
- network: NetworkConfig;
22
- expectedData?: D;
23
- };
24
- type AdapterNetworkRoundtripWithLuvioTestParams<C, D> = AdapterTestWithInjectedLuvio<C, D> & {
25
- type: 'injectedLuvioNetwork';
26
- };
27
- type AdapterCacheHitRoundtripTestParams<C, D> = AdapterTestWithInjectedLuvio<C, D> & {
28
- type: 'cache';
29
- };
30
- export declare function testAdapterCompletesRoundtrip<C = any, D = any>(params: AdapterRoundtripTestParams<C, D>): Promise<Snapshot<D, unknown>>;
31
- export declare function buildLuvioWithNetwork(networkConfig: NetworkConfig): {
32
- luvio: Luvio;
33
- networkAdapter: NetworkAdapter;
34
- };
35
- export {};
@@ -1,10 +0,0 @@
1
- import type { FetchResponse } from '@luvio/engine';
2
- export interface LuvioCustomMatchers<R> {
3
- toEqualFulfilledSnapshotWithData: (expected: any, privateProperties?: string[]) => R;
4
- toEqualStaleSnapshotWithData: (expected: any, privateProperties?: string[]) => R;
5
- toEqualErrorSnapshot: (expectedStatus?: number) => R;
6
- toEqualOfflineErrorSnapshot: () => R;
7
- toHaveBeenHitTimes: (expected: Number) => R;
8
- toHaveBeenHitOnce: () => R;
9
- toEqualFetchResponse: (expected: FetchResponse<unknown>) => R;
10
- }
@@ -1,13 +0,0 @@
1
- export interface DurableStorePersistence {
2
- get<T>(key: string): Promise<T | undefined>;
3
- set<T>(key: string, value: T): Promise<void>;
4
- delete(key: string): Promise<void>;
5
- flushPendingWork(): Promise<void>;
6
- }
7
- export declare class MemoryDurableStorePersistence implements DurableStorePersistence {
8
- private store;
9
- get<T>(key: string): Promise<T | undefined>;
10
- set<T>(key: string, value: T): Promise<void>;
11
- delete(key: string): Promise<void>;
12
- flushPendingWork(): Promise<void>;
13
- }
@@ -1 +0,0 @@
1
- export declare function setupCustomLuvioMatchers(): void;
@@ -1,9 +0,0 @@
1
- export { MockPayload, ConnectivityState, buildMockNetworkAdapter, resetMockNetworkAdapter, getMockNetworkAdapterCallCount, buildSuccessMockPayload, buildErrorMockPayload, setMockNetworkPayloads, setNetworkConnectivity, buildFetchResponse, overrideMockNetworkResponses, flushPendingNetworkRequests, } from './network';
2
- export { verifyImmutable, isImmutable } from './verification';
3
- export { getMockLuvioWithFulfilledSnapshot, getMockFulfilledSnapshot } from './mocks';
4
- export { stripProperties, customMatchers } from './utils';
5
- export { setupCustomLuvioMatchers } from './jest.setup';
6
- export { MockDurableStore } from './MockDurableStore';
7
- export { MemoryDurableStorePersistence, DurableStorePersistence } from './durableStorePersistence';
8
- export { testAdapterCompletesRoundtrip, buildLuvioWithNetwork, buildLuvioInstance, } from './adapterRoundtrip';
9
- export { LuvioCustomMatchers } from './customMatchers';
@@ -1,17 +0,0 @@
1
- export declare function getMockLuvioWithFulfilledSnapshot(): {
2
- storeLookup(): {
3
- state: string;
4
- };
5
- snapshotAvailable(): boolean;
6
- dispatchResourceRequest(): {
7
- then(): {
8
- state: string;
9
- };
10
- };
11
- applyCachePolicy(): {
12
- state: string;
13
- };
14
- };
15
- export declare function getMockFulfilledSnapshot(): {
16
- state: string;
17
- };
@@ -1,38 +0,0 @@
1
- import type { NetworkAdapter, ResourceRequest, FetchResponse, Headers } from '@luvio/engine';
2
- export declare enum ConnectivityState {
3
- Online = 0,
4
- Offline = 1
5
- }
6
- export interface MockPayload {
7
- networkArgs: Partial<ResourceRequest>;
8
- response: FetchResponse<any>;
9
- }
10
- /**
11
- * Flushes any pending network requests. Useful for tests that need to ensure all
12
- * un-awaited background refreshes are complete
13
- *
14
- * @param _mockNetworkAdapter {NetworkAdapter} The network adapter instance to flush
15
- */
16
- export declare function flushPendingNetworkRequests(_mockNetworkAdapter: NetworkAdapter): Promise<void>;
17
- export declare function buildMockNetworkAdapter(mockPayloads: MockPayload[]): NetworkAdapter;
18
- export declare function setNetworkConnectivity(mockNetworkAdapter: NetworkAdapter, connectivityState: ConnectivityState): void;
19
- export declare function setMockNetworkPayloads(mockNetworkAdapter: NetworkAdapter, mockPayloads: MockPayload[]): void;
20
- /**
21
- * Overrides the mock network adapter responses with the given "responses". Each request to
22
- * the network adapter will "pop" a response from the response array. If more requests
23
- * to the network adapter are made than responses in the given array then an error
24
- * will be returned.
25
- *
26
- * This differs from setMockNetworkPayloads because it does not look at the incoming
27
- * network request args to determine what the response should be, it just returns
28
- * the response based on the request order.
29
- *
30
- * NOTE: this overrides any previously setup MockPayloads for the given network adapter
31
- * until resetMockNetworkAdapter is called.
32
- */
33
- export declare function overrideMockNetworkResponses(mockNetworkAdapter: NetworkAdapter, responses: FetchResponse<any>[]): void;
34
- export declare function resetMockNetworkAdapter(mockNetworkAdapter: NetworkAdapter, newPayloads?: MockPayload[]): void;
35
- export declare function getMockNetworkAdapterCallCount(mockNetworkAdapter: NetworkAdapter): number | undefined;
36
- export declare function buildFetchResponse<T>(body: T, status?: number, statusText?: string, headers?: Headers): FetchResponse<T>;
37
- export declare function buildSuccessMockPayload(networkArgs: Partial<ResourceRequest>, body: any, headers?: Headers): MockPayload;
38
- export declare function buildErrorMockPayload(networkArgs: Partial<ResourceRequest>, body: any, errorStatusCode: number, errorStatusText: string, headers?: Headers): MockPayload;
@@ -1,39 +0,0 @@
1
- import type { FetchResponse, NetworkAdapter, Snapshot } from '@luvio/engine';
2
- /**
3
- * Clone an object
4
- *
5
- * @param {object} data The object to clone
6
- * @returns {object} The cloned object
7
- */
8
- export declare function clone<T>(data: T): T;
9
- /**
10
- * Strips the given properties from an object. Useful for comparing data payloads
11
- * where the given props may not be present in the data returned from an adapter.
12
- *
13
- * Does not mutate the passed in object.
14
- *
15
- * @param {object} obj The object from which to strip properties
16
- * @param {string[]} props The properties to be removed
17
- * @returns {object} The updated object with the given props stripped out
18
- */
19
- export declare function stripProperties(obj: {
20
- [s: string]: any;
21
- }, props: string[]): {
22
- [s: string]: any;
23
- };
24
- export declare function doesThrow(predicate: () => void): boolean;
25
- export declare function flushPromises(): Promise<unknown>;
26
- type MatcherResult = {
27
- pass: boolean;
28
- message: () => string;
29
- };
30
- export declare const customMatchers: {
31
- toEqualFulfilledSnapshotWithData: (snapshot: Snapshot<unknown, unknown>, expected: any, privateProperties?: string[]) => MatcherResult;
32
- toEqualStaleSnapshotWithData: (snapshot: Snapshot<unknown, unknown>, expected: any, privateProperties?: string[]) => MatcherResult;
33
- toEqualErrorSnapshot: (actual: Snapshot<unknown, unknown>, expectedStatus?: number) => MatcherResult;
34
- toEqualOfflineErrorSnapshot: (actual: Snapshot<unknown, unknown>) => MatcherResult;
35
- toHaveBeenHitTimes: (mockNetworkAdapter: NetworkAdapter, expected: Number) => MatcherResult;
36
- toHaveBeenHitOnce: (mockNetworkAdapter: NetworkAdapter) => MatcherResult;
37
- toEqualFetchResponse: (actual: FetchResponse<unknown>, expected: FetchResponse<unknown>) => MatcherResult;
38
- };
39
- export {};
@@ -1,2 +0,0 @@
1
- export declare function isImmutable(value: any): boolean;
2
- export declare function verifyImmutable(value: any, path: string): void;