refactor(test-utils): rename setupRequestMockHandlers to setupMswHandler

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2024-07-10 13:28:48 +02:00
parent 2414d86668
commit 95a3a0b91c
96 changed files with 285 additions and 244 deletions
+7
View File
@@ -210,6 +210,13 @@ export function renderWithEffects(
): Promise<RenderResult>;
// @public
export function setupMswHandlers(worker: {
listen: (t: any) => void;
close: () => void;
resetHandlers: () => void;
}): void;
// @public @deprecated (undocumented)
export function setupRequestMockHandlers(worker: {
listen: (t: any) => void;
close: () => void;
+29
View File
@@ -0,0 +1,29 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { setupMswHandlers } from './testUtils/msw';
/**
* @public
* @deprecated Use `CreateMockDirectoryOptions` from `@backstage/backend-test-utils` instead.
*/
export function setupRequestMockHandlers(worker: {
listen: (t: any) => void;
close: () => void;
resetHandlers: () => void;
}): void {
setupMswHandlers(worker);
}
+1
View File
@@ -20,4 +20,5 @@
* @packageDocumentation
*/
export * from './deprecated';
export * from './testUtils';
@@ -16,12 +16,12 @@
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import { setupRequestMockHandlers } from '../../msw';
import { setupMswHandlers } from '../../msw';
import { MockFetchApi } from './MockFetchApi';
describe('MockFetchApi', () => {
const worker = setupServer();
setupRequestMockHandlers(worker);
setupMswHandlers(worker);
it('works with default constructor', async () => {
worker.use(
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { setupRequestMockHandlers } from './setupRequestMockHandlers';
export { setupMswHandlers } from './setupMswHandlers';
@@ -19,7 +19,7 @@
* @public
* @param worker - service worker
*/
export function setupRequestMockHandlers(worker: {
export function setupMswHandlers(worker: {
listen: (t: any) => void;
close: () => void;
resetHandlers: () => void;