@luvio/adapter-test-library
Advanced tools
Comparing version 0.154.8 to 0.154.9
@@ -557,2 +557,36 @@ import sinon from 'sinon'; | ||
class MockCrossEnvironmentStorage { | ||
constructor() { | ||
this.environments = new Map(); | ||
} | ||
registerEnvironmentForNotifications(notification) { | ||
const identifier = (Math.random() + 1).toString(36).substring(2); | ||
this.environments.set(identifier, notification); | ||
return Promise.resolve({ | ||
identifier, | ||
unsubscribe: () => { | ||
this.environments.delete(identifier); | ||
return Promise.resolve(); | ||
}, | ||
}); | ||
} | ||
notifyCrossEnvironments(identifier, notification) { | ||
this.environments.forEach((callback, id) => { | ||
if (identifier !== id) { | ||
callback(notification); | ||
} | ||
}); | ||
return Promise.resolve(); | ||
} | ||
} | ||
async function createMockCrossEnvironmentNotifier(listener, storage) { | ||
const { identifier, unsubscribe } = await storage.registerEnvironmentForNotifications(listener); | ||
return { | ||
unsubscribe, | ||
notifyCrossEnvironments: (notification) => { | ||
return storage.notifyCrossEnvironments(identifier, notification); | ||
}, | ||
}; | ||
} | ||
// Use this util if you want to configure multiple network mocks in your test code. | ||
@@ -642,2 +676,2 @@ // If you're only mocking one, we suggest you use buildLuvioWithNetwork instead. | ||
export { ConnectivityState, MemoryDurableStorePersistence, MockDurableStore, buildErrorMockPayload, buildFetchResponse, buildLuvioInstance, buildLuvioWithNetwork, buildMockNetworkAdapter, buildSuccessMockPayload, customMatchers, flushPendingNetworkRequests, getMockFulfilledSnapshot, getMockLuvioWithFulfilledSnapshot, getMockNetworkAdapterCallCount, isImmutable, overrideMockNetworkResponses, resetMockNetworkAdapter, setMockNetworkPayloads, setNetworkConnectivity, setupCustomLuvioMatchers, stripProperties, testAdapterCompletesRoundtrip, testDeleteAdapterCompletesRoundtrip, verifyImmutable }; | ||
export { ConnectivityState, MemoryDurableStorePersistence, MockCrossEnvironmentStorage, MockDurableStore, buildErrorMockPayload, buildFetchResponse, buildLuvioInstance, buildLuvioWithNetwork, buildMockNetworkAdapter, buildSuccessMockPayload, createMockCrossEnvironmentNotifier, customMatchers, flushPendingNetworkRequests, getMockFulfilledSnapshot, getMockLuvioWithFulfilledSnapshot, getMockNetworkAdapterCallCount, isImmutable, overrideMockNetworkResponses, resetMockNetworkAdapter, setMockNetworkPayloads, setNetworkConnectivity, setupCustomLuvioMatchers, stripProperties, testAdapterCompletesRoundtrip, testDeleteAdapterCompletesRoundtrip, verifyImmutable }; |
@@ -7,2 +7,3 @@ export { MockPayload, ConnectivityState, buildMockNetworkAdapter, resetMockNetworkAdapter, getMockNetworkAdapterCallCount, buildSuccessMockPayload, buildErrorMockPayload, setMockNetworkPayloads, setNetworkConnectivity, buildFetchResponse, overrideMockNetworkResponses, flushPendingNetworkRequests, } from './network'; | ||
export { MockDurableStore } from './MockDurableStore'; | ||
export { createMockCrossEnvironmentNotifier, MockCrossEnvironmentStorage, } from './MockCrossEnvironmentNotifier'; | ||
export { MemoryDurableStorePersistence, DurableStorePersistence } from './durableStorePersistence'; | ||
@@ -9,0 +10,0 @@ export { testAdapterCompletesRoundtrip, buildLuvioWithNetwork, buildLuvioInstance, } from './adapterRoundtrip'; |
{ | ||
"name": "@luvio/adapter-test-library", | ||
"version": "0.154.8", | ||
"version": "0.154.9", | ||
"description": "Test library for luvio adapters", | ||
@@ -31,4 +31,4 @@ "repository": { | ||
"devDependencies": { | ||
"@luvio/engine": "^0.154.8", | ||
"@luvio/environments": "^0.154.8", | ||
"@luvio/engine": "^0.154.9", | ||
"@luvio/environments": "^0.154.9", | ||
"@types/sinon": "^7.5.2" | ||
@@ -35,0 +35,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38300
14
890