-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bea033
commit c1a37e3
Showing
4 changed files
with
287 additions
and
12 deletions.
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,47 @@ | ||
import React from 'react' | ||
import { shallow, configure } from 'enzyme' | ||
import Adapter from 'enzyme-adapter-react-16' | ||
import SkinsDot from '../skins-dot' | ||
|
||
configure({ adapter: new Adapter() }) | ||
|
||
test('click dot to expand the menu', () => { | ||
let currentSkin | ||
const onChange = (skin) => { | ||
currentSkin = skin | ||
} | ||
const i18n = { | ||
skintones: { | ||
1: 'Default Skin Tone', | ||
2: 'Light Skin Tone', | ||
3: 'Medium-Light Skin Tone', | ||
4: 'Medium Skin Tone', | ||
5: 'Medium-Dark Skin Tone', | ||
6: 'Dark Skin Tone', | ||
}, | ||
} | ||
|
||
const skins = shallow(<SkinsDot skin={1} onChange={onChange} i18n={i18n} />) | ||
|
||
// component should be un-expanded by default | ||
expect(skins.find('[aria-haspopup]').prop('aria-label')).toEqual( | ||
'Default Skin Tone', | ||
) | ||
expect(skins.find('[aria-haspopup]').prop('aria-expanded')).toEqual(false) | ||
|
||
// simulate click | ||
skins.find('[aria-haspopup]').simulate('click', { | ||
currentTarget: { | ||
getAttribute(name) { | ||
if (name === 'data-skin') { | ||
return 1 | ||
} | ||
}, | ||
}, | ||
}) | ||
|
||
// component should now be expanded | ||
expect(skins.find('[aria-haspopup]').prop('aria-expanded')).toEqual(true) | ||
expect(skins.find('[data-skin=1]').prop('aria-pressed')).toEqual(true) | ||
expect(skins.find('[data-skin=2]').prop('aria-pressed')).toEqual(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
Oops, something went wrong.