packages,plugins: migrate to using TestApiProvider and Registry

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-11-17 18:56:22 +01:00
parent 7ff56c2330
commit 29ef695410
118 changed files with 991 additions and 1112 deletions
@@ -14,22 +14,24 @@
* limitations under the License.
*/
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
import {
renderWithEffects,
TestApiRegistry,
wrapInTestApp,
} from '@backstage/test-utils';
import { fireEvent } from '@testing-library/react';
import React from 'react';
import { UserSettingsAuthProviders } from './UserSettingsAuthProviders';
import {
ApiProvider,
ApiRegistry,
ConfigReader,
} from '@backstage/core-app-api';
import { ApiProvider, ConfigReader } from '@backstage/core-app-api';
import { configApiRef, googleAuthApiRef } from '@backstage/core-plugin-api';
const mockSignInHandler = jest.fn().mockReturnValue('');
const mockGoogleAuth = {
sessionState$: () => ({
[Symbol.observable]: jest.fn(),
subscribe: () => ({
closed: false,
unsubscribe: () => null,
}),
}),
@@ -47,10 +49,10 @@ const createConfig = () =>
const config = createConfig();
const apiRegistry = ApiRegistry.from([
const apiRegistry = TestApiRegistry.from(
[configApiRef, config],
[googleAuthApiRef, mockGoogleAuth],
]);
);
describe('<UserSettingsAuthProviders />', () => {
it('displays a provider and calls its sign-in handler on click', async () => {
@@ -15,16 +15,16 @@
*/
import { AppTheme, appThemeApiRef } from '@backstage/core-plugin-api';
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
import {
renderWithEffects,
TestApiRegistry,
wrapInTestApp,
} from '@backstage/test-utils';
import { lightTheme } from '@backstage/theme';
import { fireEvent } from '@testing-library/react';
import React from 'react';
import { UserSettingsThemeToggle } from './UserSettingsThemeToggle';
import {
ApiProvider,
ApiRegistry,
AppThemeSelector,
} from '@backstage/core-app-api';
import { ApiProvider, AppThemeSelector } from '@backstage/core-app-api';
const mockTheme: AppTheme = {
id: 'light-theme',
@@ -33,8 +33,9 @@ const mockTheme: AppTheme = {
theme: lightTheme,
};
const apiRegistry = ApiRegistry.from([
[appThemeApiRef, AppThemeSelector.createWithStorage([mockTheme])],
const apiRegistry = TestApiRegistry.from([
appThemeApiRef,
AppThemeSelector.createWithStorage([mockTheme]),
]);
describe('<UserSettingsThemeToggle />', () => {