mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
Added more tests
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { FormFieldModel } from '../models/form-field.model';
|
||||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
||||
import { TextareaFieldParser } from './textarea-field-parser';
|
||||
import { DsDynamicTextAreaModel } from '../ds-dynamic-form-ui/models/ds-dynamic-textarea.model';
|
||||
|
||||
describe('TextareaFieldParser test suite', () => {
|
||||
let field: FormFieldModel;
|
||||
let initFormValues: any = {};
|
||||
|
||||
const authorityUuid = 'testScopeUUID';
|
||||
const readOnly = false;
|
||||
|
||||
beforeEach(() => {
|
||||
field = {
|
||||
input: {
|
||||
type: 'textarea'
|
||||
},
|
||||
label: 'Description',
|
||||
mandatory: 'false',
|
||||
repeatable: false,
|
||||
hints: 'Enter a description.',
|
||||
selectableMetadata: [
|
||||
{
|
||||
metadata: 'description'
|
||||
}
|
||||
],
|
||||
languageCodes: []
|
||||
} as FormFieldModel;
|
||||
|
||||
});
|
||||
|
||||
it('should init parser properly', () => {
|
||||
const parser = new TextareaFieldParser(field, initFormValues, readOnly);
|
||||
|
||||
expect(parser instanceof TextareaFieldParser).toBe(true);
|
||||
});
|
||||
|
||||
it('should return a DsDynamicTextAreaModel object when repeatable option is false', () => {
|
||||
const parser = new TextareaFieldParser(field, initFormValues, readOnly);
|
||||
|
||||
const fieldModel = parser.parse();
|
||||
|
||||
expect(fieldModel instanceof DsDynamicTextAreaModel).toBe(true);
|
||||
});
|
||||
|
||||
it('should set init value properly', () => {
|
||||
initFormValues = {
|
||||
description: [
|
||||
new FormFieldMetadataValueObject('test description'),
|
||||
],
|
||||
};
|
||||
const expectedValue ='test description';
|
||||
|
||||
const parser = new TextareaFieldParser(field, initFormValues, readOnly);
|
||||
|
||||
const fieldModel = parser.parse();
|
||||
|
||||
expect(fieldModel.value).toEqual(expectedValue);
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user