-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIO-9021: fixed eachComponentData iteration for nested forms
- Loading branch information
1 parent
8c0bf26
commit abca676
Showing
3 changed files
with
58 additions
and
4 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,54 @@ | ||
import { expect } from 'chai'; | ||
|
||
import { eachComponentData } from '../eachComponentData'; | ||
import { Component } from 'types'; | ||
|
||
describe('eachComponentData', function () { | ||
const components = [ | ||
{ | ||
key: 'form', | ||
type: 'form', | ||
order: 1, | ||
input: true, | ||
components: [ | ||
{ | ||
type: 'textfield', | ||
key: 'textField1', | ||
order: 2, | ||
}, | ||
{ | ||
type: 'textfield', | ||
key: 'textField2', | ||
order: 3, | ||
}, | ||
], | ||
}, | ||
{ | ||
key: 'textField', | ||
type: 'textfield', | ||
order: 4, | ||
input: true, | ||
}, | ||
]; | ||
|
||
const data = { | ||
form: { | ||
data: { | ||
textField1: 'textField1Value', | ||
textField2: 'textField2Value', | ||
}, | ||
metadata: {}, | ||
}, | ||
textField: 'textFieldValue', | ||
submit: true, | ||
}; | ||
|
||
it('Should iterate through nested form components in the right order', function () { | ||
let n = 1; | ||
|
||
eachComponentData(components, data, (component: Component) => { | ||
expect((component as any).order).to.equal(n); | ||
n += 1; | ||
}); | ||
}); | ||
}); |
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