mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Fixed linting and js-api tests
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { DateTimePipe } from './date-time.pipe';
|
import { DateTimePipe } from './date-time.pipe';
|
||||||
import { addMinutes, isValid } from 'date-fns';
|
import { addMinutes, isValid } from 'date-fns';
|
||||||
|
|
||||||
|
@@ -15,16 +15,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed, fakeAsync, flushMicrotasks, tick } from '@angular/core/testing';
|
||||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
|
||||||
import { ExtensionConfig } from '../config/extension.config';
|
import { ExtensionConfig } from '../config/extension.config';
|
||||||
import { ExtensionLoaderService } from './extension-loader.service';
|
import { ExtensionLoaderService } from './extension-loader.service';
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { of } from 'rxjs';
|
|
||||||
|
|
||||||
describe('ExtensionLoaderService', () => {
|
describe('ExtensionLoaderService', () => {
|
||||||
let extensionLoaderService: ExtensionLoaderService;
|
let extensionLoaderService: ExtensionLoaderService;
|
||||||
let httpClient: HttpClient;
|
let httpMock: HttpTestingController;
|
||||||
let appExtensionsConfig: ExtensionConfig;
|
let appExtensionsConfig: ExtensionConfig;
|
||||||
const pluginConfig1: ExtensionConfig = {
|
const pluginConfig1: ExtensionConfig = {
|
||||||
$id: 'test1',
|
$id: 'test1',
|
||||||
@@ -34,33 +32,16 @@ describe('ExtensionLoaderService', () => {
|
|||||||
$license: 'MIT',
|
$license: 'MIT',
|
||||||
$runtime: '2.6.1'
|
$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(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [HttpClientTestingModule],
|
imports: [HttpClientTestingModule],
|
||||||
providers: [
|
providers: [
|
||||||
HttpClient,
|
|
||||||
ExtensionLoaderService
|
ExtensionLoaderService
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
extensionLoaderService = TestBed.inject(ExtensionLoaderService);
|
extensionLoaderService = TestBed.inject(ExtensionLoaderService);
|
||||||
httpClient = TestBed.inject(HttpClient);
|
httpMock = TestBed.inject(HttpTestingController);
|
||||||
|
|
||||||
appExtensionsConfig = {
|
appExtensionsConfig = {
|
||||||
$id: 'test',
|
$id: 'test',
|
||||||
@@ -72,35 +53,22 @@ describe('ExtensionLoaderService', () => {
|
|||||||
$references: [],
|
$references: [],
|
||||||
$ignoreReferenceList: []
|
$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) => {
|
extensionLoaderService.load('assets/app.extensions.json', 'assets/plugins', ['test.extension.1.json']).then((config: ExtensionConfig) => {
|
||||||
const pluginsReference = config.$references.map((entry: ExtensionConfig) => entry.$name);
|
const pluginsReference = config.$references.map((entry: ExtensionConfig) => entry.$name);
|
||||||
expect(pluginsReference).toEqual(['test.extension.1']);
|
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) => {
|
it('should ignore default registered app extension if defined in $ignoreReferenceList', (done) => {
|
||||||
appExtensionsConfig.$ignoreReferenceList = ['test.extension.1.json'];
|
appExtensionsConfig.$ignoreReferenceList = ['test.extension.1.json'];
|
||||||
@@ -110,15 +78,16 @@ describe('ExtensionLoaderService', () => {
|
|||||||
expect(pluginsReference).toEqual([]);
|
expect(pluginsReference).toEqual([]);
|
||||||
done();
|
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'];
|
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) => {
|
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);
|
const pluginsReference = config.$references.map((entry: ExtensionConfig) => entry.$name);
|
||||||
expect(pluginsReference).toEqual(['test.extension.1']);
|
expect(pluginsReference).toEqual(['test.extension.1']);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -59,7 +59,7 @@ describe('CreateProcessAttachmentComponent', () => {
|
|||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatIconModule
|
MatIconModule
|
||||||
],
|
],
|
||||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },]
|
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(CreateProcessAttachmentComponent);
|
fixture = TestBed.createComponent(CreateProcessAttachmentComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
@@ -130,6 +130,7 @@
|
|||||||
"@types/jasminewd2": "~2.0.2",
|
"@types/jasminewd2": "~2.0.2",
|
||||||
"@types/jsdom": "^21.1.5",
|
"@types/jsdom": "^21.1.5",
|
||||||
"@types/minimatch": "^3.0.3",
|
"@types/minimatch": "^3.0.3",
|
||||||
|
"@types/mocha": "^10.0.6",
|
||||||
"@types/node": "18.7.1",
|
"@types/node": "18.7.1",
|
||||||
"@types/pdfjs-dist": "^2.10.378",
|
"@types/pdfjs-dist": "^2.10.378",
|
||||||
"@types/selenium-webdriver": "^4.0.11",
|
"@types/selenium-webdriver": "^4.0.11",
|
||||||
@@ -180,6 +181,7 @@
|
|||||||
"nock": "^13.5.4",
|
"nock": "^13.5.4",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"ng-packagr": "15.2.2",
|
"ng-packagr": "15.2.2",
|
||||||
|
"nock": "^13.3.8",
|
||||||
"nx": "15.9.3",
|
"nx": "15.9.3",
|
||||||
"postcss": "^8.4.31",
|
"postcss": "^8.4.31",
|
||||||
"postcss-sass": "^0.5.0",
|
"postcss-sass": "^0.5.0",
|
||||||
|
Reference in New Issue
Block a user