Skip to content

Commit

Permalink
chore: change test
Browse files Browse the repository at this point in the history
  • Loading branch information
DaiQiangReal committed Mar 25, 2024
1 parent e104fe4 commit de0b0ba
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 14 deletions.
44 changes: 31 additions & 13 deletions packages/semi-ui/collapsible/__test__/collapsible.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,47 @@ describe('collapsible', () => {
clear();
});

it('keepDOM = true', async () => {
it('keepDOM = true', () => {
let component = getCollapsible({ keepDOM: true, motion: false, lazyRender:true });
let collapsible = mount(component, { attachTo: document.getElementById('container') })
expect(collapsible.exists(`.collapsible-test-content`)).toEqual(false);
// set true
collapsible.setProps({ isOpen: true });
collapsible.update(); // 必须调用一次update
collapsible.setProps({keepDOM: true, motion: false, lazyRender:false,isOpen:true})
collapsible.update();
expect(collapsible.exists(`.collapsible-test-content`)).toEqual(true);
collapsible.setProps({ isOpen: false });
collapsible.update(); // 必须调用一次update
expect(collapsible.exists(`.collapsible-test-content`)).toEqual(false);
collapsible.unmount()
});

it('keepDOM + lazyRender = false', () => {
let component = getCollapsible({ keepDOM: true, lazyRender: false });
let collapsible = mount(component);

it('keepDOM = true lazyRender=false', ()=>{
let component = getCollapsible({ keepDOM: true, motion: false, lazyRender:false });
let collapsible = mount(component, { attachTo: document.getElementById('container') })
expect(collapsible.exists(`.collapsible-test-content`)).toEqual(true);
collapsible.setProps({keepDOM: true, motion: false, lazyRender:false,isOpen:true})
collapsible.update();
expect(collapsible.exists(`.collapsible-test-content`)).toEqual(true);
collapsible.setProps({keepDOM: true, motion: false, lazyRender:false,isOpen:false})
collapsible.update();
expect(collapsible.exists(`.collapsible-test-content`)).toEqual(true);
collapsible.unmount()
})






it('keepDOM lazyRender = false', () => {
let component = getCollapsible({ keepDOM: false,motion:false, lazyRender: false });
let collapsible = mount(component);
expect(collapsible.exists(`.collapsible-test-content`)).toEqual(false);
// set true
collapsible.setProps({ isOpen: true });
collapsible.setProps({ isOpen: true,motion:false,keepDOM: false, lazyRender: false });
collapsible.update(); // 必须调用一次update
expect(collapsible.exists(`.collapsible-test-content`)).toEqual(true);
collapsible.setProps({ isOpen: false });
collapsible.setProps({ isOpen: false,motion:false,keepDOM: false, lazyRender: false });
collapsible.update(); // 必须调用一次update
expect(collapsible.exists(`.collapsible-test-content`)).toEqual(true);

expect(collapsible.exists(`.collapsible-test-content`)).toEqual(false);
collapsible.unmount()
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Collapsible 1`] = `
<Demo>
<div>
<Button
block={false}
disabled={false}
htmlType="button"
onClick={[Function]}
onMouseDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
prefixCls="semi-button"
size="default"
theme="light"
type="primary"
>
<button
aria-disabled={false}
className="semi-button semi-button-primary semi-button-light"
disabled={false}
onClick={[Function]}
onMouseDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
type="button"
>
<span
className="semi-button-content"
onClick={[Function]}
x-semi-prop="children"
>
显示更多
</span>
</button>
</Button>
<Collapsible
collapseHeight={0}
duration={250}
fade={false}
isOpen={false}
keepDOM={false}
lazyRender={false}
motion={true}
>
<div
className="semi-collapsible-wrapper"
onTransitionEnd={[Function]}
style={
Object {
"height": 0,
"opacity": 1,
"overflow": "hidden",
"transitionDuration": "0ms",
}
}
>
<div
style={
Object {
"overflow": "hidden",
}
}
x-semi-prop="children"
/>
</div>
</Collapsible>
</div>
</Demo>
`;
1 change: 0 additions & 1 deletion test.txt

This file was deleted.

0 comments on commit de0b0ba

Please sign in to comment.