[ADF-3630] fix i18n fallback behaviour (#3851)

* fix i18n fallback behaviour

* update tests

* update tests

* configuration fixes

* test configuration fix
This commit is contained in:
Denys Vuika
2018-10-04 10:11:30 +01:00
committed by Eugenio Romano
parent d1f87837ac
commit 54cca45ec1
12 changed files with 126 additions and 92 deletions

View File

@@ -16,7 +16,7 @@
*/
import { Component, SimpleChange, ViewChild, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { AppConfigService, setupTestBed, CoreModule } from '@alfresco/adf-core';
import { DataRowEvent, ObjectDataRow } from '@alfresco/adf-core';
@@ -24,6 +24,8 @@ import { TaskListService } from '../services/tasklist.service';
import { TaskListComponent } from './task-list.component';
import { ProcessTestingModule } from '../../testing/process.testing.module';
import { fakeGlobalTask, fakeCutomSchema } from '../../mock';
import { TranslateService } from '@ngx-translate/core';
import { of } from 'rxjs';
declare let jasmine: any;
@@ -74,6 +76,7 @@ describe('TaskListComponent', () => {
afterEach(() => {
jasmine.Ajax.uninstall();
fixture.destroy();
});
it('should use the default schemaColumn as default', () => {
@@ -543,6 +546,10 @@ describe('CustomTaskListComponent', () => {
component = fixture.componentInstance;
});
afterEach(() => {
fixture.destroy();
});
it('should create instance of CustomTaskListComponent', () => {
expect(component instanceof CustomTaskListComponent).toBe(true, 'should create CustomTaskListComponent');
});
@@ -568,8 +575,9 @@ describe('CustomTaskListComponent', () => {
class EmptyTemplateComponent {
}
describe('Custom EmptyTemplateComponent', () => {
describe('Task List: Custom EmptyTemplateComponent', () => {
let fixture: ComponentFixture<EmptyTemplateComponent>;
let translateService: TranslateService;
setupTestBed({
imports: [ProcessTestingModule],
@@ -578,15 +586,23 @@ describe('Custom EmptyTemplateComponent', () => {
});
beforeEach(() => {
translateService = TestBed.get(TranslateService);
spyOn(translateService, 'get').and.callFake((key) => {
return of(key);
});
fixture = TestBed.createComponent(EmptyTemplateComponent);
fixture.detectChanges();
});
it('should render the custom template', async(() => {
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(fixture.debugElement.query(By.css('#custom-id'))).not.toBeNull();
expect(fixture.debugElement.query(By.css('.adf-empty-content'))).toBeNull();
});
afterEach(() => {
fixture.destroy();
});
it('should render the custom template', fakeAsync(() => {
fixture.detectChanges();
tick(100);
expect(fixture.debugElement.query(By.css('#custom-id'))).not.toBeNull();
expect(fixture.debugElement.query(By.css('.adf-empty-content'))).toBeNull();
}));
});

View File

@@ -31,12 +31,16 @@ describe('TaskStandaloneComponent', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
fixture = TestBed.createComponent(TaskStandaloneComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;
fixture.detectChanges();
}));
});
afterEach(() => {
fixture.destroy();
});
it('should show Completed message if isCompleted is true', async(() => {
component.isCompleted = true;