From f63779cb15c63956854559aacf60e1b207af64ab Mon Sep 17 00:00:00 2001 From: Anton Ramanovich Date: Mon, 23 Jun 2025 10:03:37 +0200 Subject: [PATCH] ACS-8770: refactor; moved mock to separate file --- .../src/lib/mock/adf-http-client.mock.ts | 31 +++++++++++++++++++ .../src/lib/testing/content.testing.module.ts | 20 ++---------- 2 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 lib/content-services/src/lib/mock/adf-http-client.mock.ts diff --git a/lib/content-services/src/lib/mock/adf-http-client.mock.ts b/lib/content-services/src/lib/mock/adf-http-client.mock.ts new file mode 100644 index 0000000000..fbc700f857 --- /dev/null +++ b/lib/content-services/src/lib/mock/adf-http-client.mock.ts @@ -0,0 +1,31 @@ +/*! + * @license + * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved. + * + * 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 { Injectable } from '@angular/core'; + +@Injectable() +export class AdfHttpClientMock { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + post(..._args): Promise { + return Promise.resolve({ success: true, mockData: 'default response' }); + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + get(..._args): Promise { + return Promise.resolve({ success: true, mockData: 'default get response' }); + } +} diff --git a/lib/content-services/src/lib/testing/content.testing.module.ts b/lib/content-services/src/lib/testing/content.testing.module.ts index 88d493ad75..3f1c8be02e 100644 --- a/lib/content-services/src/lib/testing/content.testing.module.ts +++ b/lib/content-services/src/lib/testing/content.testing.module.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { NgModule, APP_INITIALIZER, Injectable } from '@angular/core'; +import { NgModule, APP_INITIALIZER } from '@angular/core'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { CoreModule, NoopTranslateModule, NoopAuthModule } from '@alfresco/adf-core'; import { ContentModule } from '../content.module'; @@ -25,21 +25,7 @@ import { VersionCompatibilityService } from '../version-compatibility/version-co import { MatIconTestingModule } from '@angular/material/icon/testing'; import { AlfrescoApiServiceMock } from '../mock'; import { AdfHttpClient } from '@alfresco/adf-core/api'; - -@Injectable() -export class MockAdfHttpClient { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - post(_url: string, _body: any): Promise { - return Promise.resolve({ success: true, mockData: 'default response' }); - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - get(_url: string): Promise { - return Promise.resolve({ success: true, mockData: 'default get response' }); - } - - // Add other methods (put, delete, etc.) as needed with default mock behavior -} +import { AdfHttpClientMock } from 'lib/mock/adf-http-client.mock'; @NgModule({ imports: [NoopAnimationsModule, CoreModule, NoopAuthModule, NoopTranslateModule, ContentModule, MatIconTestingModule], @@ -51,7 +37,7 @@ export class MockAdfHttpClient { deps: [VersionCompatibilityService], multi: true }, - { provide: AdfHttpClient, useClass: MockAdfHttpClient } + { provide: AdfHttpClient, useClass: AdfHttpClientMock } ], exports: [NoopAnimationsModule, CoreModule, ContentModule] })