-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Bibliographic, Authority, Holdings FixedField to one FixedField
Replace Bibliographic, Authority, Holdings FixedField to one FixedField Refactory getFixedField without marcType Removed unnecessary tests, fixed current without using the marcType props
- Loading branch information
1 parent
c43a349
commit 4dd34d1
Showing
7 changed files
with
27 additions
and
135 deletions.
There are no files selected for viewing
24 changes: 0 additions & 24 deletions
24
src/QuickMarcEditor/QuickMarcEditorRows/FixedField/AuthorityFixedField.js
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
src/QuickMarcEditor/QuickMarcEditorRows/FixedField/BibliographicFixedField.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 19 additions & 52 deletions
71
src/QuickMarcEditor/QuickMarcEditorRows/FixedField/FixedFieldFactory.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,121 +1,88 @@ | ||
import '@folio/stripes-acq-components/test/jest/__mock__'; | ||
|
||
import { FixedFieldFactory } from './FixedFieldFactory'; | ||
|
||
import BibliographicFixedField from './BibliographicFixedField'; | ||
import HoldingsFixedField from './HoldingsFixedField'; | ||
import AuthorityFixedField from './AuthorityFixedField'; | ||
import { MARC_TYPES } from '../../../common/constants'; | ||
import fixedFieldSpecBib from '../../../../test/mocks/fixedFieldSpecBib'; | ||
import fixedFieldSpecAuth from '../../../../test/mocks/fixedFieldSpecAuth'; | ||
import fixedFieldSpecHold from '../../../../test/mocks/fixedFieldSpecHold'; | ||
|
||
describe('FixedFieldFactory', () => { | ||
it('should create correct marc type fixed field', () => { | ||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB).type.displayName, | ||
).toBe(BibliographicFixedField.displayName); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.AUTHORITY).type.displayName, | ||
).toBe(AuthorityFixedField.displayName); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.HOLDINGS).type.displayName, | ||
).toBe(HoldingsFixedField.displayName); | ||
}); | ||
|
||
it('should create correct fixed field type', () => { | ||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 'm').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 'm').props.config.type, | ||
).toBe('books'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 'a').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 'a').props.config.type, | ||
).toBe('books'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 'd').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 'd').props.config.type, | ||
).toBe('books'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 'x').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 'x').props.config.type, | ||
).toBe(undefined); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 't').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 't').props.config.type, | ||
).toBe('books'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'c').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'c').props.config.type, | ||
).toBe('scores'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'i').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'i').props.config.type, | ||
).toBe('sound_recordings'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 'b').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 'b').props.config.type, | ||
).toBe('continuing_resources'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 'i').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 'i').props.config.type, | ||
).toBe('continuing_resources'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'a', 's').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'a', 's').props.config.type, | ||
).toBe('continuing_resources'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 's').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 's').props.config.type, | ||
).toBe('continuing_resources'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'm').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'm').props.config.type, | ||
).toBe('computer_files'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'g').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'g').props.config.type, | ||
).toBe('visual_materials'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'e').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'e').props.config.type, | ||
).toBe('maps'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'f').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'f').props.config.type, | ||
).toBe('maps'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'p').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'p').props.config.type, | ||
).toBe('mixed_materials'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.AUTHORITY, fixedFieldSpecAuth, 'z').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecAuth, 'z').props.config.type, | ||
).toBe('unknown'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.AUTHORITY, fixedFieldSpecAuth, 'z').type.displayName, | ||
).toBe(AuthorityFixedField.displayName); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.HOLDINGS, fixedFieldSpecHold, 'u').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecHold, 'u').props.config.type, | ||
).toBe('unknown'); | ||
|
||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.HOLDINGS, fixedFieldSpecHold, 'u').type.displayName, | ||
).toBe(HoldingsFixedField.displayName); | ||
}); | ||
|
||
it('should return undefined type when there is no matched field', () => { | ||
expect( | ||
FixedFieldFactory.getFixedField('records', MARC_TYPES.BIB, fixedFieldSpecBib, 'l').props.config.type, | ||
FixedFieldFactory.getFixedField('records', fixedFieldSpecBib, 'l').props.config.type, | ||
).toBe(undefined); | ||
}); | ||
|
||
it('should return null when marc types is wrong', () => { | ||
expect( | ||
FixedFieldFactory.getFixedField('records', 'instance', fixedFieldSpecBib, 'l'), | ||
).toBe(null); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
export * from './FixedFieldFactory'; | ||
|
||
export { default as AutorityFixedField } from './AuthorityFixedField'; | ||
export { default as BibliographicFixedField } from './BibliographicFixedField'; | ||
export { default as HoldingsFixedField } from './HoldingsFixedField'; | ||
export { default as FixedField } from './FixedField'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters