mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 02:54:13 +00:00
added tests
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { FormFieldModel } from '../models/form-field.model';
|
||||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-value.model';
|
||||
import { ParserOptions } from './parser-options';
|
||||
import { DisabledFieldParser } from './disabled-field-parser';
|
||||
import { DynamicDisabledModel } from '../ds-dynamic-form-ui/models/disabled/dynamic-disabled.model';
|
||||
|
||||
describe('DisabledFieldParser test suite', () => {
|
||||
let field: FormFieldModel;
|
||||
let initFormValues: any = {};
|
||||
|
||||
const submissionId = '1234';
|
||||
const parserOptions: ParserOptions = {
|
||||
readOnly: false,
|
||||
submissionScope: null,
|
||||
authorityUuid: null
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
field = {
|
||||
input: {
|
||||
type: ''
|
||||
},
|
||||
label: 'Description',
|
||||
mandatory: 'false',
|
||||
repeatable: false,
|
||||
hints: 'Enter a description.',
|
||||
selectableMetadata: [
|
||||
{
|
||||
metadata: 'description'
|
||||
}
|
||||
],
|
||||
languageCodes: []
|
||||
} as FormFieldModel;
|
||||
|
||||
});
|
||||
|
||||
it('should init parser properly', () => {
|
||||
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions);
|
||||
|
||||
expect(parser instanceof DisabledFieldParser).toBe(true);
|
||||
});
|
||||
|
||||
it('should return a DynamicDisabledModel object when repeatable option is false', () => {
|
||||
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions);
|
||||
|
||||
const fieldModel = parser.parse();
|
||||
|
||||
expect(fieldModel instanceof DynamicDisabledModel).toBe(true);
|
||||
});
|
||||
|
||||
it('should set init value properly', () => {
|
||||
initFormValues = {
|
||||
description: [
|
||||
new FormFieldMetadataValueObject('test description'),
|
||||
],
|
||||
};
|
||||
const expectedValue ='test description';
|
||||
|
||||
const parser = new DisabledFieldParser(submissionId, field, initFormValues, parserOptions);
|
||||
|
||||
const fieldModel = parser.parse();
|
||||
console.log(fieldModel);
|
||||
expect(fieldModel.value).toEqual(expectedValue);
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user