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
@@ -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} />
);
};