renamed section upload inner components

This commit is contained in:
Giuseppe Digilio
2019-03-17 17:16:53 +01:00
parent c6d16abbbd
commit d90f69d15e
15 changed files with 20 additions and 20 deletions

View File

@@ -0,0 +1,100 @@
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { createTestComponent } from '../../../../../shared/testing/utils';
import { mockUploadFiles } from '../../../../../shared/mocks/mock-submission';
import { FormComponent } from '../../../../../shared/form/form.component';
import { UploadSectionFileViewComponent } from './section-upload-file-view.component';
import { TruncatePipe } from '../../../../../shared/utils/truncate.pipe';
import { Metadata } from '../../../../../core/shared/metadata.utils';
describe('UploadSectionFileViewComponent test suite', () => {
let comp: UploadSectionFileViewComponent;
let compAsAny: any;
let fixture: ComponentFixture<UploadSectionFileViewComponent>;
const fileData: any = mockUploadFiles[0];
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot()
],
declarations: [
TruncatePipe,
FormComponent,
UploadSectionFileViewComponent,
TestComponent
],
providers: [
UploadSectionFileViewComponent
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents().then();
}));
describe('', () => {
let testComp: TestComponent;
let testFixture: ComponentFixture<TestComponent>;
// synchronous beforeEach
beforeEach(() => {
const html = `
<ds-submission-upload-section-file-view [fileData]="fileData"></ds-submission-upload-section-file-view>`;
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
testComp = testFixture.componentInstance;
});
afterEach(() => {
testFixture.destroy();
});
it('should create UploadSectionFileViewComponent', inject([UploadSectionFileViewComponent], (app: UploadSectionFileViewComponent) => {
expect(app).toBeDefined();
}));
});
describe('', () => {
beforeEach(() => {
fixture = TestBed.createComponent(UploadSectionFileViewComponent);
comp = fixture.componentInstance;
compAsAny = comp;
});
afterEach(() => {
fixture.destroy();
comp = null;
compAsAny = null;
});
it('should init metadata array properly', () => {
comp.fileData = fileData;
const expectMetadataMap = {
[comp.fileTitleKey]: Metadata.all(fileData.metadata, 'dc.title'),
[comp.fileDescrKey]: [],
};
fixture.detectChanges();
expect(comp.metadata).toEqual(expectMetadataMap);
});
});
});
// declare a test component
@Component({
selector: 'ds-test-cmp',
template: ``
})
class TestComponent {
fileData;
}