-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79ce526
commit 8afea63
Showing
7 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import createConfigContext from '../../../../../src/helpers/createConfigContext'; | ||
import advancedSearch from '../../../../../src/plugins/recordTypes/deaccession/advancedSearch'; | ||
|
||
chai.should(); | ||
|
||
describe('deaccession record advanced search', () => { | ||
const configContext = createConfigContext(); | ||
|
||
it('should contain a top level property `op`', () => { | ||
advancedSearch(configContext).should.have.property('op'); | ||
}); | ||
|
||
it('should contain a top level property `value` that is an array', () => { | ||
advancedSearch(configContext).should.have.property('value').that.is.an('array'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import deaccessionRecordTypePluginFactory from '../../../../../src/plugins/recordTypes/deaccession'; | ||
import createColumns from '../../../../../src/plugins/recordTypes/deaccession/columns'; | ||
import createConfigContext from '../../../../../src/helpers/createConfigContext'; | ||
|
||
chai.should(); | ||
|
||
describe('deaccession record columns', () => { | ||
const deaccessionRecordTypePlugin = deaccessionRecordTypePluginFactory({}); | ||
const configContext = createConfigContext(deaccessionRecordTypePlugin); | ||
const columns = createColumns(configContext); | ||
|
||
it('should have the correct shape', () => { | ||
columns.should.have.property('default').that.is.an('object'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Field from '../../../../../../src/components/record/Field'; | ||
import form from '../../../../../../src/plugins/recordTypes/deaccession/forms/default'; | ||
import createConfigContext from '../../../../../../src/helpers/createConfigContext'; | ||
|
||
chai.should(); | ||
|
||
describe('deaccession record default form', () => { | ||
it('should be a Field', () => { | ||
const configContext = createConfigContext(); | ||
const { template } = form(configContext); | ||
|
||
template.type.should.equal(Field); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import deaccessionRecordTypePluginFactory from '../../../../../src/plugins/recordTypes/deaccession'; | ||
import createConfigContext from '../../../../../src/helpers/createConfigContext'; | ||
|
||
chai.should(); | ||
|
||
describe('deaccession record plugin', () => { | ||
const config = {}; | ||
const deaccessionRecordTypePlugin = deaccessionRecordTypePluginFactory(config); | ||
const configContext = createConfigContext(deaccessionRecordTypePlugin); | ||
|
||
it('should have the correct shape', () => { | ||
const pluginConfiguration = deaccessionRecordTypePlugin(configContext); | ||
|
||
const { | ||
recordTypes, | ||
} = pluginConfiguration; | ||
|
||
recordTypes.should.have.property('deaccession'); | ||
|
||
const deaccessionRecordType = recordTypes.deaccession; | ||
|
||
deaccessionRecordType.should.have.property('title').that.is.a('function'); | ||
deaccessionRecordType.should.have.property('forms').that.is.an('object'); | ||
deaccessionRecordType.should.have.property('messages').that.is.an('object'); | ||
deaccessionRecordType.should.have.property('serviceConfig').that.is.an('object'); | ||
|
||
deaccessionRecordType.title().should.be.a('string'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import messages from '../../../../../src/plugins/recordTypes/deaccession/messages'; | ||
|
||
chai.should(); | ||
|
||
describe('deaccession record messages', () => { | ||
it('should contain properties with an id and defaultMessage properties', () => { | ||
messages.should.be.an('object'); | ||
|
||
Object.keys(messages).forEach((deaccessionName) => { | ||
const deaccessionMessages = messages[deaccessionName]; | ||
|
||
Object.keys(deaccessionMessages).forEach((name) => { | ||
deaccessionMessages[name].should.contain.all.keys(['id', 'defaultMessage']); | ||
}); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import serviceConfig from '../../../../../src/plugins/recordTypes/deaccession/serviceConfig'; | ||
|
||
chai.should(); | ||
|
||
describe('deaccession record serviceConfig', () => { | ||
it('should have a servicePath property', () => { | ||
serviceConfig.should.have.property('servicePath').that.is.a('string'); | ||
serviceConfig.should.have.property('serviceName').that.is.a('string'); | ||
serviceConfig.should.have.property('serviceType').that.is.a('string'); | ||
serviceConfig.should.have.property('objectName').that.is.a('string'); | ||
serviceConfig.should.have.property('documentName').that.is.a('string'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import Immutable from 'immutable'; | ||
import createTitleGetter from '../../../../../src/plugins/recordTypes/deaccession/title'; | ||
import createConfigContext from '../../../../../src/helpers/createConfigContext'; | ||
|
||
chai.should(); | ||
|
||
describe('deaccession record title', () => { | ||
const configContext = createConfigContext(); | ||
const title = createTitleGetter(configContext); | ||
|
||
it('should return the deaccession number and deaccessionTitle when both are present', () => { | ||
const data = Immutable.fromJS({ | ||
document: { | ||
'ns2:deaccessions_common': { | ||
deaccessionNumber: 'DE', | ||
// deaccessionTitle: 'Title', | ||
}, | ||
}, | ||
}); | ||
|
||
title(data).should.equal('DE – Title'); | ||
}); | ||
|
||
it('should return the deaccession number only when the deaccessionTitle is missing', () => { | ||
const data = Immutable.fromJS({ | ||
document: { | ||
'ns2:deaccessions_common': { | ||
deaccessionNumber: 'DE', | ||
}, | ||
}, | ||
}); | ||
|
||
title(data).should.equal('DE'); | ||
}); | ||
|
||
it('should return the deaccessionTitle only when the deaccession number is missing', () => { | ||
const data = Immutable.fromJS({ | ||
document: { | ||
'ns2:deaccessions_common': { | ||
// deaccessionTitle: 'Title', | ||
}, | ||
}, | ||
}); | ||
|
||
title(data).should.equal(''); | ||
}); | ||
|
||
it('should return an empty string if no document is passed', () => { | ||
title(null).should.equal(''); | ||
title(undefined).should.equal(''); | ||
}); | ||
|
||
it('should return an empty string if the common part is not present', () => { | ||
const data = Immutable.fromJS({ | ||
document: { | ||
'ns2:deaccessions_extension': { | ||
deaccessionAltTitle: 'Alt deaccession title', | ||
}, | ||
}, | ||
}); | ||
|
||
title(data).should.equal(''); | ||
}); | ||
}); |