forked from video-react/video-react
-
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.
- Loading branch information
Showing
29 changed files
with
230 additions
and
102 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,60 @@ | ||
import React from 'react'; | ||
import { shallow, mount } from 'enzyme'; | ||
import ClosedCaptionButton from '../components/control-bar/ClosedCaptionButton'; | ||
import MenuButton from '../components/menu/MenuButton'; | ||
|
||
const playerState = { | ||
hasStarted: false, | ||
textTracks: [ | ||
{ | ||
kind: 'captions', | ||
label: 'English', | ||
language: 'en', | ||
mode: 'showing' | ||
}, | ||
{ | ||
kind: 'captions', | ||
label: 'Swedish', | ||
language: 'sv', | ||
mode: 'hidden' | ||
}, | ||
{ | ||
kind: 'captions', | ||
label: 'Russian', | ||
language: 'ru', | ||
mode: 'hidden' | ||
}, | ||
{ | ||
kind: 'descriptions', | ||
label: 'English', | ||
language: 'en', | ||
mode: 'hidden' | ||
} | ||
], | ||
currentTextTrack: null | ||
}; | ||
|
||
describe('ClosedCaptionButton', () => { | ||
it('should render with "MenuButton" tag', () => { | ||
const wrapper = shallow( | ||
<ClosedCaptionButton | ||
player={playerState} | ||
/> | ||
); | ||
|
||
expect(wrapper.type()).toBe(MenuButton); | ||
}); | ||
|
||
it('should show menu items after click', () => { | ||
const wrapper = mount( | ||
<ClosedCaptionButton | ||
player={playerState} | ||
/> | ||
); | ||
|
||
expect(wrapper.find('.video-react-menu-item').length).toEqual(0); | ||
expect(wrapper.find('div.video-react-closed-caption').length).toEqual(1); | ||
wrapper.find('div.video-react-closed-caption').simulate('click'); | ||
expect(wrapper.find('.video-react-menu-item').length).toEqual(4); | ||
}); | ||
}); |
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,40 @@ | ||
import React from 'react'; | ||
import { shallow, mount } from 'enzyme'; | ||
import ClickableComponent from '../components/ClickableComponent'; | ||
import MenuButton from '../components/menu/MenuButton'; | ||
|
||
const items = [1, 2, 3, 4].map(i => ({ | ||
label: `item${i}`, | ||
value: `item${i}` | ||
})); | ||
|
||
describe('ClosedCaptionButton', () => { | ||
it('should render with "MenuButton" tag', () => { | ||
const wrapper = shallow( | ||
<MenuButton | ||
items={items} | ||
selectedIndex={0} | ||
> | ||
<span className="video-react-control-text">Button</span> | ||
</MenuButton> | ||
); | ||
|
||
expect(wrapper.type()).toBe(ClickableComponent); | ||
}); | ||
|
||
it('should show menu items after click', () => { | ||
const wrapper = mount( | ||
<MenuButton | ||
items={items} | ||
selectedIndex={0} | ||
> | ||
<span className="video-react-control-text">Button</span> | ||
</MenuButton> | ||
); | ||
|
||
expect(wrapper.find('.video-react-menu-item').length).toEqual(0); | ||
expect(wrapper.find('div.video-react-menu-button').length).toEqual(1); | ||
wrapper.find('div.video-react-menu-button').simulate('click'); | ||
expect(wrapper.find('.video-react-menu-item').length).toEqual(4); | ||
}); | ||
}); |
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,36 @@ | ||
import React from 'react'; | ||
import { shallow, mount } from 'enzyme'; | ||
import MenuItem from '../components/menu/MenuItem'; | ||
|
||
const items = [1, 2, 3, 4].map(i => ({ | ||
label: `item${i}`, | ||
value: `item${i}` | ||
})); | ||
|
||
describe('ClosedCaptionButton', () => { | ||
it('should render with "MenuButton" tag', () => { | ||
const wrapper = shallow( | ||
<MenuItem | ||
item={items[0]} | ||
index={0} | ||
/> | ||
); | ||
|
||
expect(wrapper.type()).toBe('li'); | ||
}); | ||
|
||
it('should call onSelectItem after click', () => { | ||
const handleSelectItem = jest.fn(); | ||
const wrapper = mount( | ||
<MenuItem | ||
item={items[0]} | ||
index={0} | ||
onSelectItem={handleSelectItem} | ||
/> | ||
); | ||
|
||
expect(wrapper.find('.video-react-menu-item').length).toEqual(1); | ||
wrapper.find('.video-react-menu-item').simulate('click'); | ||
expect(handleSelectItem).toHaveBeenCalled(); | ||
}); | ||
}); |
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
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
Oops, something went wrong.