Skip to content

Commit

Permalink
#2841 remove occurences of "all" property in data-iterable mixin (#2972)
Browse files Browse the repository at this point in the history
* #2841 remove occurences of "all" property in data-iterable mixin as it duplicates"everyItem"

* #2841 add tests for usage of 'everyItem'
  • Loading branch information
ReneU authored and johnleider committed Jan 11, 2018
1 parent d2c0af0 commit a7bbe4d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
24 changes: 24 additions & 0 deletions src/components/VDataTable/VDataTable.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,28 @@ test('VDataTable.vue', ({ mount, compileToFunctions }) => {

expect('Unable to locate target [data-app]').toHaveBeenTipped()
})

it('should initialize everyItem state', async () => {
const data = dataTableTestData()
data.propsData.value = data.propsData.items
const wrapper = mount(VDataTable, data)

expect(wrapper.vm.everyItem).toBe(true);
expect('Unable to locate target [data-app]').toHaveBeenTipped()
})

it('should update everyItem state', async () => {
const data = dataTableTestData()
data.propsData.itemKey = 'other';
const wrapper = mount(VDataTable, data)

expect(wrapper.vm.everyItem).toBe(false);
wrapper.vm.value.push(wrapper.vm.items[0]);
expect(wrapper.vm.everyItem).toBe(false);

wrapper.vm.value.push(wrapper.vm.items[1]);
wrapper.vm.value.push(wrapper.vm.items[2]);
expect(wrapper.vm.everyItem).toBe(true);
expect('Unable to locate target [data-app]').toHaveBeenTipped()
})
})
4 changes: 2 additions & 2 deletions src/components/VDataTable/mixins/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
const row = this.$scopedSlots.headers({
headers: this.headers,
indeterminate: this.indeterminate,
all: this.all
all: this.everyItem
})

children = [this.needsTR(row) ? this.genTR(row) : row, this.genTProgress()]
Expand All @@ -23,7 +23,7 @@ export default {
light: this.light,
color: this.selectAll === true ? '' : this.selectAll,
hideDetails: true,
inputValue: this.all,
inputValue: this.everyItem,
indeterminate: this.indeterminate
},
on: { change: this.toggle }
Expand Down
10 changes: 0 additions & 10 deletions src/mixins/data-iterable.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default {

data () {
return {
all: false,
searchLength: 0,
defaultPagination: {
descending: false,
Expand Down Expand Up @@ -211,17 +210,8 @@ export default {
},

watch: {
indeterminate (val) {
if (val) this.all = true
},
someItems (val) {
if (!val) this.all = false
},
search () {
this.updatePagination({ page: 1, totalItems: this.itemsLength })
},
everyItem (val) {
if (val) this.all = true
}
},

Expand Down

0 comments on commit a7bbe4d

Please sign in to comment.