Skip to content

Commit

Permalink
Fixed unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
VitoAlbano committed Jan 10, 2024
1 parent 4aec084 commit 602df38
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions lib/extensions/src/lib/services/extension-loader.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,16 @@ describe('ExtensionLoaderService', () => {
const pluginsReference = config.$references.map((entry: ExtensionConfig) => entry.$name);
expect(pluginsReference).toEqual(['test.extension.1']);
});
});

it('should load extensions from passed extension value', (done) => {
httpMock.expectOne('assets/app.extensions.json').flush(appExtensionsConfig);
tick();
httpMock.expectOne('assets/plugins/test.extension.1.json').flush(pluginConfig1);
httpMock.expectNone('assets/plugins/test.extension.2.json');
httpMock.expectNone('assets/plugins/test.extension.3.json');
flushMicrotasks();
}));

it('should load extensions from passed extension value',fakeAsync(() => {
appExtensionsConfig.$references = ['test.extension.1.json'];

extensionLoaderService.load(
Expand All @@ -107,11 +114,14 @@ describe('ExtensionLoaderService', () => {
}]).then((config: ExtensionConfig) => {
const hasExtensionValue = config.$references.some((entry: ExtensionConfig) => entry.$id === 'extension-value-id');
expect(hasExtensionValue).toBe(true);
done();
});
});
httpMock.expectOne('assets/app.extensions.json').flush(appExtensionsConfig);
tick();
httpMock.expectOne('assets/plugins/test.extension.1.json').flush(pluginConfig1);
flushMicrotasks();
}));

it('should load extensions if only extension value was passed', (done) => {
it('should load extensions if only extension value was passed', fakeAsync(() => {
extensionLoaderService.load(
'assets/app.extensions.json',
'assets/plugins',
Expand All @@ -125,11 +135,13 @@ describe('ExtensionLoaderService', () => {
}]).then((config: ExtensionConfig) => {
const hasExtensionValue = config.$references.some((entry: ExtensionConfig) => entry.$id === 'extension-value-id');
expect(hasExtensionValue).toBe(true);
done();
});
});
httpMock.expectOne('assets/app.extensions.json').flush(appExtensionsConfig);
tick();
flushMicrotasks();
}));

it('should load extensions with multiple extension values', (done) => {
it('should load extensions with multiple extension values', fakeAsync(() => {
appExtensionsConfig.$references = ['test.extension.1.json'];

extensionLoaderService.load(
Expand All @@ -153,7 +165,10 @@ describe('ExtensionLoaderService', () => {
expect(hasFirstExtensionValue).toBe(true);
const hasSecondExtensionValue = config.$references.some((entry: ExtensionConfig) => entry.$id === 'extension-value-id-2');
expect(hasSecondExtensionValue).toBe(true);
done();
});
});
httpMock.expectOne('assets/app.extensions.json').flush(appExtensionsConfig);
tick();
httpMock.expectOne('assets/plugins/test.extension.1.json').flush(pluginConfig1);
flushMicrotasks();
}));
});

0 comments on commit 602df38

Please sign in to comment.