added tests and typedoc

This commit is contained in:
lotte
2020-03-25 13:18:46 +01:00
committed by Art Lowel
parent e38aec831f
commit ef3a235178
36 changed files with 701 additions and 46 deletions

View File

@@ -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);
})
});
});