Skip to content

Commit

Permalink
add test and fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyoung committed Aug 27, 2019
1 parent 21e26f0 commit 6c73616
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/checkbox/src/checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'is-focus': focus
}"
:tabindex="indeterminate ? 0 : false"
:role="indeterminate ? checkbox : false"
:role="indeterminate ? 'checkbox' : false"
:aria-checked="indeterminate ? 'mixed' : false"
>
<span class="el-checkbox__inner"></span>
Expand Down
50 changes: 46 additions & 4 deletions test/unit/specs/table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,12 @@ describe('Table', () => {
</el-table>
`,

created() {
this.testData = getTestData();
},
// created() {
// this.testData = getTestData();
// },

data() {
return { testData: this.testData };
return { testData: getTestData() };
}
});

Expand Down Expand Up @@ -1716,6 +1716,48 @@ describe('Table', () => {
}, 50);
});

it('toggleAllSelection debounce', async() => {
const spy = sinon.spy();
const vm = createVue({
template: `
<div>
<el-table ref="table" :data="testData" @selection-change="change">
<el-table-column type="selection" />
<el-table-column prop="name" />
</el-table>
<el-table ref="table1" :data="testData1" @selection-change="change">
<el-table-column type="selection" />
<el-table-column prop="name" />
</el-table>
</div>
`,

data() {
return {
testData: getTestData(),
testData1: getTestData()
};
},

methods: {
change(selection) {
spy(selection);
}
},

mounted() {
this.$refs.table.toggleAllSelection();
this.$refs.table1.toggleAllSelection();
}
}, true);

await wait(50);
expect(spy.callCount).to.be.equal(2);
expect(spy.args[0][0].length).to.be.equal(5);
expect(spy.args[1][0].length).to.be.equal(5);
destroyVM(vm);
});

it('clearSelection', () => {
const vm = createTable('selection-change');
vm.$refs.table.toggleRowSelection(vm.testData[0]);
Expand Down

0 comments on commit 6c73616

Please sign in to comment.