Skip to content

Commit

Permalink
UIQM-698 update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanDenis committed Sep 26, 2024
1 parent 2f801ad commit 37b3365
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion src/QuickMarcEditor/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable max-lines */
import faker from 'faker';

import { v4 as uuid } from 'uuid';

import { FixedFieldFactory } from './QuickMarcEditorRows/FixedField';
import {
LEADER_TAG,
QUICK_MARC_ACTIONS,
Expand All @@ -19,6 +20,7 @@ import {
bibLeaderString,
holdingsLeader,
} from '../../test/jest/fixtures/leaders';
import { SUBFIELD_TYPES } from './QuickMarcEditorRows/BytesField';

jest.mock('uuid', () => {
return {
Expand Down Expand Up @@ -1811,4 +1813,62 @@ describe('QuickMarcEditor utils', () => {
});
});
});

describe('getFixedFieldStringPositions', () => {
beforeEach(() => {
jest.spyOn(FixedFieldFactory, 'getFixedFieldType').mockReturnValue({
items: [{
code: 'test1',
isArray: true,
}, {
code: 'test2',
isArray: false,
readOnly: false,
}],
});
});

describe('when a field is an 008', () => {
it('should return an 008 config', () => {
const field = { tag: '008' };

expect(utils.getFixedFieldStringPositions('a', 'm', field, fixedFieldSpecBib)).toEqual([
{
code: 'test2',
isArray: false,
readOnly: false,
},
]);
});
});

describe('when a field is an 007', () => {
it('should return an 007 config', () => {
const field = { tag: '007', content: { Category: 'c' } };

expect(utils.getFixedFieldStringPositions('a', 'm', field, fixedFieldSpecBib)).toEqual([
{
name: 'Image bit depth',
type: SUBFIELD_TYPES.STRING,
length: 3,
},
]);
});
});

describe('when a field is an 006', () => {
it('should return an 006 config', () => {
const field = { tag: '006', content: { Type: 'f' } };

expect(utils.getFixedFieldStringPositions('f', 'm', field, fixedFieldSpecBib)).toEqual([
{
name: 'Proj',
hint: 'Projection',
type: SUBFIELD_TYPES.STRING,
length: 2,
},
]);
});
});
});
});

0 comments on commit 37b3365

Please sign in to comment.