-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/form builder identifier schema (#188)
Enhancement use new createIdentifier to append schema name Enhancement Add schema name to identifier using new createIdentifier function
- Loading branch information
Showing
3 changed files
with
82 additions
and
9 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
46 changes: 46 additions & 0 deletions
46
client/src/containers/FormBuilderLoader/tests/createIdentifier-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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* global jest, describe, beforeEach, it, expect */ | ||
|
||
jest.unmock('../FormBuilderLoader'); | ||
|
||
import { FormBuilderLoader } from '../FormBuilderLoader'; | ||
|
||
describe('createIdentifier', () => { | ||
it('concatenates the identifier prop with the schema name prop', () => { | ||
FormBuilderLoader.propTypes = {}; | ||
const form = new FormBuilderLoader(); | ||
let props = {}; | ||
expect(form.getIdentifier(props)).toBe(''); | ||
props = { identifier: 'one' }; | ||
expect(form.getIdentifier(props)).toBe('one'); | ||
props = { | ||
identifier: 'one.two', | ||
schema: 'three', | ||
}; | ||
expect(form.getIdentifier(props)).toBe('one.two'); | ||
props = { | ||
identifier: 'one.two', | ||
schema: { | ||
schema: 'three', | ||
}, | ||
}; | ||
expect(form.getIdentifier(props)).toBe('one.two'); | ||
props = { | ||
identifier: 'one.two', | ||
schema: { | ||
schema: { | ||
name: 'three', | ||
}, | ||
}, | ||
}; | ||
expect(form.getIdentifier(props)).toBe('one.two.three'); | ||
props = { | ||
identifier: null, | ||
schema: { | ||
schema: { | ||
name: 'three', | ||
}, | ||
}, | ||
}; | ||
expect(form.getIdentifier(props)).toBe('three'); | ||
}); | ||
}); |