forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test cases for Card and Breadcrumb
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import Card from '../index'; | ||
|
||
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout)); | ||
|
||
describe('Card', () => { | ||
function fakeResizeWindowTo(wrapper, width) { | ||
Object.defineProperties(wrapper.node.container, { | ||
offsetWidth: { | ||
get() { return width; }, | ||
configurable: true, | ||
}, | ||
}); | ||
window.resizeTo(width); | ||
} | ||
|
||
it('resize card will trigger different padding', async () => { | ||
const wrapper = mount(<Card title="xxx">xxx</Card>); | ||
fakeResizeWindowTo(wrapper, 1000); | ||
await delay(0); | ||
expect(wrapper.hasClass('ant-card-wider-padding')).toBe(true); | ||
fakeResizeWindowTo(wrapper, 800); | ||
await delay(0); | ||
expect(wrapper.hasClass('ant-card-wider-padding')).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters