Skip to content

Commit

Permalink
test(Cascader): fix test unit
Browse files Browse the repository at this point in the history
  • Loading branch information
myronliu347 committed Nov 23, 2018
1 parent 1f7f5fe commit c721069
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions test/cascader/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ describe('Cascader', () => {
let wrapper;

afterEach(() => {
const overlay = document.querySelectorAll('.next-overlay-wrapper');
overlay.forEach(dom => {
document.body.removeChild(dom);
});
if (wrapper) {
wrapper.unmount();
wrapper = null;
}
const overlay = document.querySelectorAll('.next-overlay-wrapper');
overlay.forEach(dom => {
document.body.removeChild(dom);
});
if (wrapper) {
wrapper.unmount();
wrapper = null;
}
});

it('should render single cascader', () => {
Expand All @@ -60,12 +60,16 @@ describe('Cascader', () => {
changeCalled = true;
assert(v === '2980');
delete d.children;
delete d._source;
assert.deepEqual(d, {
value: '2980',
label: '铜川',
pos: '0-0-1'
});
e.selectedPath.forEach(d => delete d.children);
e.selectedPath.forEach(d => {
delete d.children;
delete d._source;
});
assert.deepEqual(e, {
selectedPath: [{
value: '2973',
Expand Down Expand Up @@ -100,12 +104,16 @@ describe('Cascader', () => {
changeCalled = true;
assert(v === '2980');
delete d.children;
delete d._source;
assert.deepEqual(d, {
value: '2980',
label: '铜川',
pos: '0-0-1'
});
e.selectedPath.forEach(d => delete d.children);
e.selectedPath.forEach(d => {
delete d.children;
delete d._source;
});
assert.deepEqual(e, {
selectedPath: [{
value: '2973',
Expand Down Expand Up @@ -208,6 +216,8 @@ describe('Cascader', () => {
let data;
let extra;
const handleChange = (v, d, e) => {
d.forEach(d => delete d._source);
e.checkedData.forEach(d => delete d._source);
assert.deepEqual(value, sortByValue(v, true));
assert.deepEqual(data, sortByValue(d));
e.checkedData = sortByValue(e.checkedData);
Expand Down Expand Up @@ -270,6 +280,8 @@ describe('Cascader', () => {
let data;
let extra;
const handleChange = (v, d, e) => {
d.forEach(d => delete d._source);
e.checkedData.forEach(d => delete d._source);
assert.deepEqual(value, sortByValue(v, true));
assert.deepEqual(data, sortByValue(d));
e.checkedData = sortByValue(e.checkedData);
Expand Down

0 comments on commit c721069

Please sign in to comment.