Skip to content
Prev Previous commit
Next Next commit
test: add tests for populates as function and child paths
  • Loading branch information
javamonn committed May 14, 2017
commit fdbdbc594159cca1f164755f86ae2ed51d62cb60
40 changes: 39 additions & 1 deletion tests/unit/helpers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ const exampleData = {
ABC: true,
abc: true
}
},
QRS: {
owner: 'ABC',
nested: {
owner: 'ABC'
},
notes: {
123: true,
},
collaborators: {
ABC: true,
abc: true
}
}
},
users: {
Expand Down Expand Up @@ -152,7 +165,16 @@ describe('Helpers:', () => {
.have
.property('displayName', 'scott')
})

it('handles child path', () => {
const path = 'projects/QRS'
const rootName = 'users'
const populates = [{ child: 'nested.owner', root: rootName }]
const populatedData = helpers.populatedDataToJS(exampleState, path, populates)
expect(populatedData.nested.owner)
.to
.have
.property('displayName', 'scott')
})
it('populates childParam', () => {
const path = 'projects/CDF'
const rootName = 'users'
Expand Down Expand Up @@ -186,6 +208,22 @@ describe('Helpers:', () => {
})
})

describe('config as function', () => {
it('populates values', () => {
const path = 'projects/CDF'
const rootName = 'users'
const populates = (projectKey, projectData) => ([
// configure populates with key / data tuple...
{ child: 'owner', root: rootName }
])
const populatedData = helpers.populatedDataToJS(exampleState, path, populates)
expect(populatedData.owner)
.to
.have
.property('displayName', 'scott')
})
})

})

describe('list', () => {
Expand Down