Skip to content

Commit

Permalink
Small update to a test to check the tree expands when new data arrive…
Browse files Browse the repository at this point in the history
…s with more then one child
  • Loading branch information
Aaron Cole committed May 29, 2022
1 parent 91a056b commit 9905273
Showing 1 changed file with 145 additions and 134 deletions.
279 changes: 145 additions & 134 deletions tests/unit/components/cylc/tree/treeitem.vue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ describe('TreeItem component', () => {
})
expect(wrapper).not.to.be.expanded()
})
it('should not display the cycle point expanded by default, but should update to expanded when new data arrives with more then one child', async () => {
const wrapper = mountFunction({
propsData: {
node: simpleCyclepointNode,
depth: 0
}
})
expect(wrapper).not.to.be.expanded()
await wrapper.setProps({ node: simpleCyclepointNodeMultiChild })
expect(wrapper).to.be.expanded()
})
it('should display the cycle point expanded by default (if more then one child is present)', () => {
const wrapper = mountFunction({
propsData: {
Expand Down Expand Up @@ -131,141 +142,141 @@ describe('TreeItem component', () => {
})
})

describe('expand/collapse button click', () => {
const wrapper = mountFunction({
propsData: {
node: simpleTaskNode,
initialExpanded: false
}
})
expect(wrapper).to.not.be.expanded()
const expandCollapseBtn = wrapper.find('.node-expand-collapse-button')
it('should expand if currently collapsed', async () => {
await expandCollapseBtn.trigger('click')
expect(wrapper).to.be.expanded()
})
it('should collapse if currently expanded', async () => {
await expandCollapseBtn.trigger('click')
expect(wrapper).to.not.be.expanded()
})
})

describe('children', () => {
it('should recursively include other TreeItem components for its children', () => {
const wrapper = mountFunction({
propsData: {
node: simpleWorkflowNode
}
})
const task = wrapper.findAllComponents({ name: 'TreeItem' })
// 4 TreeItem components, 1 for workflow, 1 for cyclepoint, 1 for task, 1 for job
expect(task.length).to.equal(9)
})
// })
// describe('mixin', () => {
// const sortTestsData = [
// // invalid values
// {
// args: {
// type: '',
// children: []
// },
// expected: []
// },
// {
// args: {
// type: null,
// children: null
// },
// expected: null
// },
// // workflow children (cycle points) are sorted by ID in descending order
// {
// args: {
// type: 'workflow',
// children: [
// { id: 'workflow//1' },
// { id: 'workflow//2' }
// ]
// },
// expected: [
// { id: 'workflow//2' },
// { id: 'workflow//1' }
// ]
// },
// // cycle point children (family proxies and task proxies) are sorted by type in ascending order, and then name in ascending order
// {
// args: {
// type: 'cyclepoint',
// children: [
// { node: { name: 'foo' }, type: 'task-proxy' },
// { node: { name: 'FAM1' }, type: 'family-proxy' },
// { node: { name: 'bar' }, type: 'task-proxy' }
// ]
// },
// expected: [
// { node: { name: 'FAM1' }, type: 'family-proxy' },
// { node: { name: 'bar' }, type: 'task-proxy' },
// { node: { name: 'foo' }, type: 'task-proxy' }
// ]
// },
// // family proxy children (family proxies and task proxies) are sorted by type in ascending order, and then name in ascending order
// {
// args: {
// type: 'family-proxy',
// children: [
// { node: { name: 'foo' }, type: 'task-proxy' },
// { node: { name: 'FAM1' }, type: 'family-proxy' },
// { node: { name: 'bar' }, type: 'task-proxy' }
// ]
// },
// expected: [
// { node: { name: 'FAM1' }, type: 'family-proxy' },
// { node: { name: 'bar' }, type: 'task-proxy' },
// { node: { name: 'foo' }, type: 'task-proxy' }
// ]
// },
// {
// args: {
// type: 'family-proxy',
// children: [
// { node: { name: 'f01' }, type: 'task-proxy' },
// { node: { name: 'f1' }, type: 'task-proxy' },
// { node: { name: 'f10' }, type: 'task-proxy' },
// { node: { name: 'f0' }, type: 'task-proxy' },
// { node: { name: 'f2' }, type: 'task-proxy' }
// ]
// },
// expected: [
// { node: { name: 'f0' }, type: 'task-proxy' },
// { node: { name: 'f01' }, type: 'task-proxy' },
// { node: { name: 'f1' }, type: 'task-proxy' },
// { node: { name: 'f2' }, type: 'task-proxy' },
// { node: { name: 'f10' }, type: 'task-proxy' }
// ]
// },
// // task proxy children (jobs) are sorted by job submit number in descending order
// {
// args: {
// type: 'task-proxy',
// children: [
// { node: { submitNum: '2' } },
// { node: { submitNum: '1' } },
// { node: { submitNum: '3' } }
// ]
// },
// expected: [
// { node: { submitNum: '3' } },
// { node: { submitNum: '2' } },
// { node: { submitNum: '1' } }
// ]
// describe('expand/collapse button click', () => {
// const wrapper = mountFunction({
// propsData: {
// node: simpleTaskNode,
// initialExpanded: false
// }
// ]
// sortTestsData.forEach((test) => {
// it('should order elements correctly', () => {
// const sorted = treeitem.methods.sortedChildren(test.args.type, test.args.children)
// expect(sorted).to.deep.equal(test.expected)
// })
// expect(wrapper).to.not.be.expanded()
// const expandCollapseBtn = wrapper.find('.node-expand-collapse-button')
// it('should expand if currently collapsed', async () => {
// await expandCollapseBtn.trigger('click')
// expect(wrapper).to.be.expanded()
// })
// it('should collapse if currently expanded', async () => {
// await expandCollapseBtn.trigger('click')
// expect(wrapper).to.not.be.expanded()
// })
// })
//
// describe('children', () => {
// it('should recursively include other TreeItem components for its children', () => {
// const wrapper = mountFunction({
// propsData: {
// node: simpleWorkflowNode
// }
// })
// const task = wrapper.findAllComponents({ name: 'TreeItem' })
// // 4 TreeItem components, 1 for workflow, 1 for cyclepoint, 1 for task, 1 for job
// expect(task.length).to.equal(9)
// })
})
// // })
// // describe('mixin', () => {
// // const sortTestsData = [
// // // invalid values
// // {
// // args: {
// // type: '',
// // children: []
// // },
// // expected: []
// // },
// // {
// // args: {
// // type: null,
// // children: null
// // },
// // expected: null
// // },
// // // workflow children (cycle points) are sorted by ID in descending order
// // {
// // args: {
// // type: 'workflow',
// // children: [
// // { id: 'workflow//1' },
// // { id: 'workflow//2' }
// // ]
// // },
// // expected: [
// // { id: 'workflow//2' },
// // { id: 'workflow//1' }
// // ]
// // },
// // // cycle point children (family proxies and task proxies) are sorted by type in ascending order, and then name in ascending order
// // {
// // args: {
// // type: 'cyclepoint',
// // children: [
// // { node: { name: 'foo' }, type: 'task-proxy' },
// // { node: { name: 'FAM1' }, type: 'family-proxy' },
// // { node: { name: 'bar' }, type: 'task-proxy' }
// // ]
// // },
// // expected: [
// // { node: { name: 'FAM1' }, type: 'family-proxy' },
// // { node: { name: 'bar' }, type: 'task-proxy' },
// // { node: { name: 'foo' }, type: 'task-proxy' }
// // ]
// // },
// // // family proxy children (family proxies and task proxies) are sorted by type in ascending order, and then name in ascending order
// // {
// // args: {
// // type: 'family-proxy',
// // children: [
// // { node: { name: 'foo' }, type: 'task-proxy' },
// // { node: { name: 'FAM1' }, type: 'family-proxy' },
// // { node: { name: 'bar' }, type: 'task-proxy' }
// // ]
// // },
// // expected: [
// // { node: { name: 'FAM1' }, type: 'family-proxy' },
// // { node: { name: 'bar' }, type: 'task-proxy' },
// // { node: { name: 'foo' }, type: 'task-proxy' }
// // ]
// // },
// // {
// // args: {
// // type: 'family-proxy',
// // children: [
// // { node: { name: 'f01' }, type: 'task-proxy' },
// // { node: { name: 'f1' }, type: 'task-proxy' },
// // { node: { name: 'f10' }, type: 'task-proxy' },
// // { node: { name: 'f0' }, type: 'task-proxy' },
// // { node: { name: 'f2' }, type: 'task-proxy' }
// // ]
// // },
// // expected: [
// // { node: { name: 'f0' }, type: 'task-proxy' },
// // { node: { name: 'f01' }, type: 'task-proxy' },
// // { node: { name: 'f1' }, type: 'task-proxy' },
// // { node: { name: 'f2' }, type: 'task-proxy' },
// // { node: { name: 'f10' }, type: 'task-proxy' }
// // ]
// // },
// // // task proxy children (jobs) are sorted by job submit number in descending order
// // {
// // args: {
// // type: 'task-proxy',
// // children: [
// // { node: { submitNum: '2' } },
// // { node: { submitNum: '1' } },
// // { node: { submitNum: '3' } }
// // ]
// // },
// // expected: [
// // { node: { submitNum: '3' } },
// // { node: { submitNum: '2' } },
// // { node: { submitNum: '1' } }
// // ]
// // }
// // ]
// // sortTestsData.forEach((test) => {
// // it('should order elements correctly', () => {
// // const sorted = treeitem.methods.sortedChildren(test.args.type, test.args.children)
// // expect(sorted).to.deep.equal(test.expected)
// // })
// // })
// })
})

0 comments on commit 9905273

Please sign in to comment.