diff --git a/lib/core/src/lib/pipes/date-time.pipe.spec.ts b/lib/core/src/lib/pipes/date-time.pipe.spec.ts index 3d26a0d889..8feb3a4eaa 100644 --- a/lib/core/src/lib/pipes/date-time.pipe.spec.ts +++ b/lib/core/src/lib/pipes/date-time.pipe.spec.ts @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { DateTimePipe } from './date-time.pipe'; import { addMinutes, isValid } from 'date-fns'; diff --git a/lib/extensions/src/lib/services/extension-loader.service.spec.ts b/lib/extensions/src/lib/services/extension-loader.service.spec.ts index 4f53f1cb16..7ed4de0589 100644 --- a/lib/extensions/src/lib/services/extension-loader.service.spec.ts +++ b/lib/extensions/src/lib/services/extension-loader.service.spec.ts @@ -15,16 +15,14 @@ * limitations under the License. */ -import { TestBed } from '@angular/core/testing'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { TestBed, fakeAsync, flushMicrotasks, tick } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { ExtensionConfig } from '../config/extension.config'; import { ExtensionLoaderService } from './extension-loader.service'; -import { HttpClient } from '@angular/common/http'; -import { of } from 'rxjs'; describe('ExtensionLoaderService', () => { let extensionLoaderService: ExtensionLoaderService; - let httpClient: HttpClient; + let httpMock: HttpTestingController; let appExtensionsConfig: ExtensionConfig; const pluginConfig1: ExtensionConfig = { $id: 'test1', @@ -34,33 +32,16 @@ describe('ExtensionLoaderService', () => { $license: 'MIT', $runtime: '2.6.1' }; - const pluginConfig2: ExtensionConfig = { - $id: 'test2', - $name: 'test.extension.2', - $version: '1.0.0', - $vendor: 'Alfresco', - $license: 'MIT', - $runtime: '2.6.1' - }; - const pluginConfig3: ExtensionConfig = { - $id: 'test3', - $name: 'test.extension.3', - $version: '1.0.0', - $vendor: 'Alfresco', - $license: 'MIT', - $runtime: '2.6.1' - }; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], providers: [ - HttpClient, ExtensionLoaderService ] }); extensionLoaderService = TestBed.inject(ExtensionLoaderService); - httpClient = TestBed.inject(HttpClient); + httpMock = TestBed.inject(HttpTestingController); appExtensionsConfig = { $id: 'test', @@ -72,35 +53,22 @@ describe('ExtensionLoaderService', () => { $references: [], $ignoreReferenceList: [] }; - - spyOn(httpClient, 'get').and.callFake((url: string) => { - if (url === 'assets/app.extensions.json') { - return of(appExtensionsConfig); - } - - if (url === 'assets/plugins/test.extension.1.json') { - return of(pluginConfig1); - } - - if (url === 'assets/plugins/test.extension.2.json') { - return of(pluginConfig2); - } - - if (url === 'assets/plugins/test.extension.3.json') { - return of(pluginConfig3); - } - - return of(null); - }); }); - it('should load default registered app extensions when no custom $references defined', (done) => { + afterEach(() => { + httpMock.verify(); + }); + + it('should load default registered app extensions when no custom $references defined', fakeAsync(() => { extensionLoaderService.load('assets/app.extensions.json', 'assets/plugins', ['test.extension.1.json']).then((config: ExtensionConfig) => { const pluginsReference = config.$references.map((entry: ExtensionConfig) => entry.$name); expect(pluginsReference).toEqual(['test.extension.1']); - done(); }); - }); + httpMock.expectOne('assets/app.extensions.json').flush(appExtensionsConfig); + tick(); + httpMock.expectOne('assets/plugins/test.extension.1.json').flush(pluginConfig1); + flushMicrotasks(); + })); it('should ignore default registered app extension if defined in $ignoreReferenceList', (done) => { appExtensionsConfig.$ignoreReferenceList = ['test.extension.1.json']; @@ -110,15 +78,16 @@ describe('ExtensionLoaderService', () => { expect(pluginsReference).toEqual([]); done(); }); + + httpMock.expectOne('assets/app.extensions.json').flush(appExtensionsConfig); }); - it('should load only extensions defined by $references', (done) => { + it('should load only extensions defined by $references', fakeAsync(() => { appExtensionsConfig.$references = ['test.extension.1.json']; extensionLoaderService.load('assets/app.extensions.json', 'assets/plugins', ['test.extension.2.json, test.extension.3.json']).then((config: ExtensionConfig) => { const pluginsReference = config.$references.map((entry: ExtensionConfig) => entry.$name); expect(pluginsReference).toEqual(['test.extension.1']); - done(); }); }); diff --git a/lib/process-services/src/lib/attachment/create-process-attachment.component.spec.ts b/lib/process-services/src/lib/attachment/create-process-attachment.component.spec.ts index ca1c938f87..c8a150cc37 100644 --- a/lib/process-services/src/lib/attachment/create-process-attachment.component.spec.ts +++ b/lib/process-services/src/lib/attachment/create-process-attachment.component.spec.ts @@ -59,7 +59,7 @@ describe('CreateProcessAttachmentComponent', () => { MatButtonModule, MatIconModule ], - providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },] + providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }] }); fixture = TestBed.createComponent(CreateProcessAttachmentComponent); component = fixture.componentInstance; diff --git a/package.json b/package.json index 4580cce35e..937680d175 100644 --- a/package.json +++ b/package.json @@ -130,6 +130,7 @@ "@types/jasminewd2": "~2.0.2", "@types/jsdom": "^21.1.5", "@types/minimatch": "^3.0.3", + "@types/mocha": "^10.0.6", "@types/node": "18.7.1", "@types/pdfjs-dist": "^2.10.378", "@types/selenium-webdriver": "^4.0.11", @@ -180,6 +181,7 @@ "nock": "^13.5.4", "npm-run-all": "^4.1.5", "ng-packagr": "15.2.2", + "nock": "^13.3.8", "nx": "15.9.3", "postcss": "^8.4.31", "postcss-sass": "^0.5.0",