-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from flowforge/feat-table-row-extra-props
Add extraProps option to table rows
- Loading branch information
Showing
3 changed files
with
121 additions
and
2 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { mount } from '@vue/test-utils' | ||
import DataTableRow from '@/components/data-table/DataTableRow.vue' | ||
|
||
const TestComponent = { | ||
template: '{{name}}: {{value}}', | ||
props: ['name', 'value'] | ||
} | ||
|
||
describe('DataTableRow', () => { | ||
describe('subcomponents', () => { | ||
it('render if set in the column', async () => { | ||
const wrapper = mount(DataTableRow, { | ||
props: { | ||
columns: [{ | ||
component: { | ||
is: TestComponent | ||
} | ||
}], | ||
data: { | ||
name: 'Film', | ||
value: 'Star Wars' | ||
} | ||
} | ||
}) | ||
|
||
expect(wrapper.text()).toMatch('Film: Star Wars') | ||
|
||
await wrapper.setProps({ | ||
data: { | ||
name: 'TV', | ||
value: 'Black Mirror' | ||
} | ||
}) | ||
|
||
expect(wrapper.text()).toMatch('TV: Black Mirror') | ||
}) | ||
|
||
it('support receiving extra properties', async () => { | ||
const wrapper = mount(DataTableRow, { | ||
props: { | ||
columns: [{ | ||
component: { | ||
is: TestComponent, | ||
extraProps: { | ||
value: 'Star wars' | ||
} | ||
} | ||
}], | ||
data: { | ||
name: 'Film' | ||
} | ||
} | ||
}) | ||
|
||
expect(wrapper.text()).toMatch('Film: Star Wars') | ||
|
||
await wrapper.setProps({ | ||
columns: [{ | ||
component: { | ||
is: TestComponent, | ||
extraProps: { | ||
value: 'Return of the Jedi' | ||
} | ||
} | ||
}] | ||
}) | ||
|
||
expect(wrapper.text()).toMatch('Film: Return of the Jedi') | ||
|
||
// Props from data override extraProps | ||
await wrapper.setProps({ | ||
data: { | ||
name: 'TV', | ||
value: 'Black Mirror' | ||
} | ||
}) | ||
|
||
expect(wrapper.text()).toMatch('TV: Black Mirror') | ||
}) | ||
}) | ||
}) |