Skip to content

Commit 21d84ea

Browse files
committed
完善单元格编辑单元测试
1 parent 6b157d0 commit 21d84ea

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

tests/unit/specs/ve-table-cell-edit.spec.js

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,4 +776,119 @@ describe("veTable cell edit", () => {
776776

777777
expect(mockFn).toHaveBeenCalled();
778778
});
779+
780+
it("editingFocusCell with full row edit", async () => {
781+
const mockFn = jest.fn();
782+
783+
const wrapper = mount(veTable, {
784+
propsData: {
785+
columns: COLUMNS,
786+
tableData: TABLE_DATA,
787+
editOption: {
788+
doubleClickEdit: true,
789+
fullRowEdit: true,
790+
},
791+
rowKeyFieldName: "rowKey",
792+
},
793+
});
794+
795+
wrapper
796+
.findAll(".ve-table-body-tr")
797+
.at(0)
798+
.findAll(".ve-table-body-td")
799+
.at(0)
800+
.trigger("dblclick");
801+
802+
expect(wrapper.vm.editingFocusCell).toEqual({
803+
rowKey: 0,
804+
colKey: "name",
805+
});
806+
807+
wrapper
808+
.findAll(".ve-table-body-tr")
809+
.at(0)
810+
.findAll(".ve-table-body-td")
811+
.at(1)
812+
.trigger("dblclick");
813+
814+
expect(wrapper.vm.editingFocusCell).toEqual({
815+
rowKey: 0,
816+
colKey: "date",
817+
});
818+
});
819+
820+
it("editingFocusCell data with cell edit", async () => {
821+
const wrapper = mount(veTable, {
822+
propsData: {
823+
columns: COLUMNS,
824+
tableData: TABLE_DATA,
825+
editOption: {
826+
doubleClickEdit: true,
827+
},
828+
rowKeyFieldName: "rowKey",
829+
},
830+
});
831+
832+
wrapper
833+
.findAll(".ve-table-body-tr")
834+
.at(0)
835+
.findAll(".ve-table-body-td")
836+
.at(0)
837+
.trigger("dblclick");
838+
839+
expect(wrapper.vm.editingFocusCell).toEqual({
840+
rowKey: 0,
841+
colKey: "name",
842+
});
843+
844+
wrapper
845+
.findAll(".ve-table-body-tr")
846+
.at(0)
847+
.findAll(".ve-table-body-td")
848+
.at(1)
849+
.trigger("dblclick");
850+
851+
expect(wrapper.vm.editingFocusCell).toEqual({
852+
rowKey: 0,
853+
colKey: "date",
854+
});
855+
});
856+
857+
it("editingFocusCell data with full row edit", async () => {
858+
const wrapper = mount(veTable, {
859+
propsData: {
860+
columns: COLUMNS,
861+
tableData: TABLE_DATA,
862+
editOption: {
863+
doubleClickEdit: true,
864+
fullRowEdit: true,
865+
},
866+
rowKeyFieldName: "rowKey",
867+
},
868+
});
869+
870+
wrapper
871+
.findAll(".ve-table-body-tr")
872+
.at(0)
873+
.findAll(".ve-table-body-td")
874+
.at(0)
875+
.trigger("dblclick");
876+
877+
expect(wrapper.vm.editingFocusCell).toEqual({
878+
rowKey: 0,
879+
colKey: "name",
880+
});
881+
882+
wrapper
883+
.findAll(".ve-table-body-tr")
884+
.at(0)
885+
.findAll(".ve-table-body-td")
886+
.at(1)
887+
.trigger("dblclick");
888+
889+
expect(wrapper.vm.editingFocusCell).toEqual({
890+
rowKey: 0,
891+
colKey: "date",
892+
});
893+
});
779894
});

0 commit comments

Comments
 (0)