mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-11 12:03:03 +00:00
added tests and typedoc
This commit is contained in:
@@ -1,12 +1,29 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ScriptHelpComponent } from './script-help.component';
|
||||
import { ScriptParameter } from '../../scripts/script-parameter.model';
|
||||
import { Script } from '../../scripts/script.model';
|
||||
import { ScriptParameterType } from '../../scripts/script-parameter-type.model';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
describe('ScriptHelpComponent', () => {
|
||||
let component: ScriptHelpComponent;
|
||||
let fixture: ComponentFixture<ScriptHelpComponent>;
|
||||
let script;
|
||||
|
||||
function init() {
|
||||
const param1 = Object.assign(
|
||||
new ScriptParameter(),
|
||||
{name: '-d', description: 'Lorem ipsum dolor sit amet,', type: ScriptParameterType.DATE}
|
||||
);
|
||||
const param2 = Object.assign(
|
||||
new ScriptParameter(),
|
||||
{name: '-f', description: 'consetetur sadipscing elitr', type: ScriptParameterType.BOOLEAN}
|
||||
);
|
||||
script = Object.assign(new Script(), { parameters: [param1, param2] });
|
||||
}
|
||||
beforeEach(async(() => {
|
||||
init();
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ScriptHelpComponent ]
|
||||
})
|
||||
@@ -16,10 +33,20 @@ describe('ScriptHelpComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ScriptHelpComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.script = script;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should show the name and description for each parameter of the script', () => {
|
||||
const rows = fixture.debugElement.queryAll(By.css('tr'));
|
||||
expect(rows.length).toBe(script.parameters.length);
|
||||
script.parameters.forEach((parameter, index) => {
|
||||
expect(rows[index].queryAll(By.css('td'))[0].nativeElement.textContent).toContain(parameter.name);
|
||||
expect(rows[index].queryAll(By.css('td'))[1].nativeElement.textContent.trim()).toEqual(parameter.description);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user