implement the beginnings of mockApis
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -18,7 +18,7 @@ import { UrlPatternDiscovery } from '@backstage/core-app-api';
|
||||
import { IdentityApi } from '@backstage/core-plugin-api';
|
||||
import { NotFoundError } from '@backstage/errors';
|
||||
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
||||
import { MockConfigApi, MockFetchApi } from '@backstage/test-utils';
|
||||
import { mockApis, MockFetchApi } from '@backstage/test-utils';
|
||||
import { TechDocsStorageClient } from './client';
|
||||
|
||||
jest.mock('@microsoft/fetch-event-source');
|
||||
@@ -34,7 +34,7 @@ const mockEntity = {
|
||||
|
||||
describe('TechDocsStorageClient', () => {
|
||||
const mockBaseUrl = 'http://backstage:9191/api/techdocs';
|
||||
const configApi = new MockConfigApi({});
|
||||
const configApi = mockApis.config();
|
||||
const discoveryApi = UrlPatternDiscovery.compile(mockBaseUrl);
|
||||
const identityApi: jest.Mocked<IdentityApi> = {
|
||||
getCredentials: jest.fn(),
|
||||
|
||||
+4
-5
@@ -13,12 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { scmIntegrationsApiRef } from '@backstage/integration-react';
|
||||
|
||||
import { entityRouteRef } from '@backstage/plugin-catalog-react';
|
||||
import {
|
||||
MockConfigApi,
|
||||
mockApis,
|
||||
renderInTestApp,
|
||||
TestApiProvider,
|
||||
} from '@backstage/test-utils';
|
||||
@@ -106,10 +107,8 @@ jest.mock('@backstage/core-components', () => ({
|
||||
Page: jest.fn(),
|
||||
}));
|
||||
|
||||
const configApi = new MockConfigApi({
|
||||
app: {
|
||||
baseUrl: 'http://localhost:3000',
|
||||
},
|
||||
const configApi = mockApis.config({
|
||||
data: { app: { baseUrl: 'http://localhost:3000' } },
|
||||
});
|
||||
|
||||
const Wrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
+5
-31
@@ -13,9 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
MockConfigApi,
|
||||
mockApis,
|
||||
renderInTestApp,
|
||||
TestApiProvider,
|
||||
} from '@backstage/test-utils';
|
||||
@@ -55,16 +56,7 @@ describe('useNavigateUrl', () => {
|
||||
const baseUrl = 'http://localhost:3000';
|
||||
await renderInTestApp(
|
||||
<TestApiProvider
|
||||
apis={[
|
||||
[
|
||||
configApiRef,
|
||||
new MockConfigApi({
|
||||
app: {
|
||||
baseUrl,
|
||||
},
|
||||
}),
|
||||
],
|
||||
]}
|
||||
apis={[[configApiRef, mockApis.config({ data: { app: { baseUrl } } })]]}
|
||||
>
|
||||
<Component to={`${baseUrl}/test`} />
|
||||
</TestApiProvider>,
|
||||
@@ -75,16 +67,7 @@ describe('useNavigateUrl', () => {
|
||||
const baseUrl = 'http://localhost:3000/instance';
|
||||
await renderInTestApp(
|
||||
<TestApiProvider
|
||||
apis={[
|
||||
[
|
||||
configApiRef,
|
||||
new MockConfigApi({
|
||||
app: {
|
||||
baseUrl,
|
||||
},
|
||||
}),
|
||||
],
|
||||
]}
|
||||
apis={[[configApiRef, mockApis.config({ data: { app: { baseUrl } } })]]}
|
||||
>
|
||||
<Component to={`${baseUrl}/test`} />
|
||||
</TestApiProvider>,
|
||||
@@ -95,16 +78,7 @@ describe('useNavigateUrl', () => {
|
||||
const baseUrl = 'http://localhost:3000';
|
||||
await renderInTestApp(
|
||||
<TestApiProvider
|
||||
apis={[
|
||||
[
|
||||
configApiRef,
|
||||
new MockConfigApi({
|
||||
app: {
|
||||
baseUrl,
|
||||
},
|
||||
}),
|
||||
],
|
||||
]}
|
||||
apis={[[configApiRef, mockApis.config({ data: { app: { baseUrl } } })]]}
|
||||
>
|
||||
<Component to="/test" />
|
||||
</TestApiProvider>,
|
||||
|
||||
Reference in New Issue
Block a user