implement the beginnings of mockApis
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { MockConfigApi, TestApiProvider } from '@backstage/test-utils';
|
||||
import { mockApis, TestApiProvider } from '@backstage/test-utils';
|
||||
import { screen, render, waitFor, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
@@ -35,10 +35,12 @@ const SearchContextFilterSpy = ({ name }: { name: string }) => {
|
||||
};
|
||||
|
||||
describe('SearchFilter.Autocomplete', () => {
|
||||
const configApiMock = new MockConfigApi({
|
||||
search: {
|
||||
query: {
|
||||
pageLimit: 100,
|
||||
const configApiMock = mockApis.config({
|
||||
data: {
|
||||
search: {
|
||||
query: {
|
||||
pageLimit: 100,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ import { configApiRef } from '@backstage/core-plugin-api';
|
||||
|
||||
import { SearchContextProvider } from '../../context';
|
||||
import { SearchFilter } from './SearchFilter';
|
||||
import { MockConfigApi, TestApiProvider } from '@backstage/test-utils';
|
||||
import { mockApis, TestApiProvider } from '@backstage/test-utils';
|
||||
import { searchApiRef } from '../../api';
|
||||
|
||||
describe('SearchFilter', () => {
|
||||
@@ -37,10 +37,12 @@ describe('SearchFilter', () => {
|
||||
const values = ['value1', 'value2'];
|
||||
const filters = { unrelated: 'unrelated' };
|
||||
|
||||
const configApiMock = new MockConfigApi({
|
||||
search: {
|
||||
query: {
|
||||
pagelimit: 10,
|
||||
const configApiMock = mockApis.config({
|
||||
data: {
|
||||
search: {
|
||||
query: {
|
||||
pagelimit: 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { ApiProvider } from '@backstage/core-app-api';
|
||||
import { MockConfigApi, TestApiRegistry } from '@backstage/test-utils';
|
||||
import { mockApis, TestApiRegistry } from '@backstage/test-utils';
|
||||
import { act, renderHook, waitFor } from '@testing-library/react';
|
||||
|
||||
import { searchApiRef } from '../../api';
|
||||
@@ -27,17 +28,19 @@ jest.useFakeTimers();
|
||||
|
||||
describe('SearchFilter.hooks', () => {
|
||||
describe('useDefaultFilterValue', () => {
|
||||
const configApiMock = new MockConfigApi({
|
||||
search: {
|
||||
query: {
|
||||
pageLimit: 100,
|
||||
const configApiMock = mockApis.config({
|
||||
data: {
|
||||
search: {
|
||||
query: {
|
||||
pageLimit: 100,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const searchApiMock = {
|
||||
query: jest.fn().mockResolvedValue({ results: [] }),
|
||||
};
|
||||
const mockApis = TestApiRegistry.from(
|
||||
const apis = TestApiRegistry.from(
|
||||
[searchApiRef, searchApiMock],
|
||||
[configApiRef, configApiMock],
|
||||
);
|
||||
@@ -54,7 +57,7 @@ describe('SearchFilter.hooks', () => {
|
||||
filters: {},
|
||||
};
|
||||
return (
|
||||
<ApiProvider apis={mockApis}>
|
||||
<ApiProvider apis={apis}>
|
||||
<SearchContextProvider
|
||||
initialState={{ ...emptySearchContext, ...overrides }}
|
||||
>
|
||||
|
||||
@@ -19,7 +19,7 @@ import { screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
import {
|
||||
MockConfigApi,
|
||||
mockApis,
|
||||
renderWithEffects,
|
||||
TestApiProvider,
|
||||
} from '@backstage/test-utils';
|
||||
@@ -31,10 +31,12 @@ import { SearchPagination } from './SearchPagination';
|
||||
import { configApiRef } from '@backstage/core-plugin-api';
|
||||
|
||||
describe('SearchPagination', () => {
|
||||
const configApiMock = new MockConfigApi({
|
||||
search: {
|
||||
query: {
|
||||
pagelimit: 10,
|
||||
const configApiMock = mockApis.config({
|
||||
data: {
|
||||
search: {
|
||||
query: {
|
||||
pagelimit: 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
act,
|
||||
renderHook,
|
||||
} from '@testing-library/react';
|
||||
import { MockConfigApi, TestApiProvider } from '@backstage/test-utils';
|
||||
import { mockApis, TestApiProvider } from '@backstage/test-utils';
|
||||
import React from 'react';
|
||||
import {
|
||||
SearchContextProvider,
|
||||
@@ -37,7 +37,7 @@ describe('SearchContext', () => {
|
||||
} satisfies typeof searchApiRef.T;
|
||||
|
||||
const wrapper = ({ children, initialState, config = {} }: any) => {
|
||||
const configApiMock = new MockConfigApi(config);
|
||||
const configApiMock = mockApis.config({ data: config });
|
||||
return (
|
||||
<TestApiProvider
|
||||
apis={[
|
||||
@@ -433,7 +433,7 @@ describe('SearchContext', () => {
|
||||
|
||||
const { result } = renderHook(() => useSearch(), {
|
||||
wrapper: ({ children }) => {
|
||||
const configApiMock = new MockConfigApi({});
|
||||
const configApiMock = mockApis.config();
|
||||
return (
|
||||
<TestApiProvider
|
||||
apis={[
|
||||
@@ -491,7 +491,7 @@ describe('SearchContext', () => {
|
||||
|
||||
const { result } = renderHook(() => useSearch(), {
|
||||
wrapper: ({ children }) => {
|
||||
const configApiMock = new MockConfigApi({});
|
||||
const configApiMock = mockApis.config();
|
||||
return (
|
||||
<TestApiProvider
|
||||
apis={[
|
||||
|
||||
Reference in New Issue
Block a user