test-utils: TestApiRegistry.with -> .from

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-11-18 10:37:12 +01:00
parent 000190de69
commit 0c92f73a11
5 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ const apis = ApiRegistry.from([
Would be migrated to this:
```ts
const apis = TestApiRegistry.with(
const apis = TestApiRegistry.from(
[identityApiRef, mockIdentityApi],
[configApiRef, new ConfigReader({})],
);
@@ -35,7 +35,7 @@ describe('<DismissableBanner />', () => {
};
beforeEach(() => {
apis = TestApiRegistry.with([storageApiRef, createWebStorage()]);
apis = TestApiRegistry.from([storageApiRef, createWebStorage()]);
});
it('renders the message and the popover', async () => {
+1 -1
View File
@@ -193,7 +193,7 @@ export type TestApiProviderProps<TApiPairs extends any[]> = {
export class TestApiRegistry implements ApiHolder {
// (undocumented)
get<T>(api: ApiRef<T>): T | undefined;
static with<TApiPairs extends any[]>(
static from<TApiPairs extends any[]>(
...apis: readonly [...TestApiProviderPropsApiPairs<TApiPairs>]
): TestApiRegistry;
}
@@ -98,7 +98,7 @@ describe('TestApiRegistry', () => {
it('should be created with APIs', () => {
const x = { a: 'a', b: 3 };
const y = 'y';
const registry = TestApiRegistry.with([xApiRef, x], [yApiRef, y]);
const registry = TestApiRegistry.from([xApiRef, x], [yApiRef, y]);
expect(registry.get(xApiRef)).toBe(x);
expect(registry.get(yApiRef)).toBe(y);
@@ -106,7 +106,7 @@ describe('TestApiRegistry', () => {
it('should allow partial implementations', () => {
const x = { a: 'a' };
const registry = TestApiRegistry.with([xApiRef, x]);
const registry = TestApiRegistry.from([xApiRef, x]);
expect(registry.get(xApiRef)).toBe(x);
expect(registry.get(yApiRef)).toBeUndefined();
@@ -115,7 +115,7 @@ describe('TestApiRegistry', () => {
it('should require partial implementations to match types', () => {
const x = { a: 2 };
// @ts-expect-error
const registry = TestApiRegistry.with([xApiRef, x]);
const registry = TestApiRegistry.from([xApiRef, x]);
expect(registry.get(xApiRef)).toBe(x);
expect(registry.get(yApiRef)).toBeUndefined();
@@ -125,7 +125,7 @@ describe('TestApiRegistry', () => {
const x1 = { a: 'a' };
const x2 = { a: 's' };
const x3 = { a: 'd' };
const registry = TestApiRegistry.with(
const registry = TestApiRegistry.from(
[xApiRef, x1],
[xApiRef, x2],
[xApiRef, x3],
@@ -63,7 +63,7 @@ export class TestApiRegistry implements ApiHolder {
* @public
* @param apis - A list of pairs mapping an ApiRef to its respective implementation.
*/
static with<TApiPairs extends any[]>(
static from<TApiPairs extends any[]>(
...apis: readonly [...TestApiProviderPropsApiPairs<TApiPairs>]
) {
return new TestApiRegistry(
@@ -121,6 +121,6 @@ export const TestApiProvider = <T extends any[]>({
children,
}: TestApiProviderProps<T>) => {
return (
<ApiProvider apis={TestApiRegistry.with(...apis)} children={children} />
<ApiProvider apis={TestApiRegistry.from(...apis)} children={children} />
);
};