-
Notifications
You must be signed in to change notification settings - Fork 312
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
e7a8c17
commit a387f2d
Showing
5 changed files
with
115 additions
and
21 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
__tests__/components/Inputs/LanguageSelect/LanguageSelect.test.js
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,73 @@ | ||
import React, { Component } from 'react' | ||
import { shallow, mount } from 'enzyme' | ||
|
||
import LanguageSelect from '../../../../app/components/Inputs/LanguageSelect' | ||
import { LANGUAGES } from '../../../../app/core/constants' | ||
|
||
describe('LanguageSelect', () => { | ||
const props = { | ||
value: LANGUAGES.VIETNAMESE.value, | ||
items: Object.keys(LANGUAGES).map(key => LANGUAGES[key]), | ||
} | ||
|
||
test('should render without crashing', () => { | ||
const wrapper = shallow(<LanguageSelect {...props} />) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
test('should render the VIETNAMESE flag when passed VIETNAMESE value', () => { | ||
const wrapper = shallow(<LanguageSelect {...props} />) | ||
expect( | ||
wrapper | ||
.find('#selected-lang-country-flag') | ||
.children() | ||
|
||
.props().alt, | ||
).toEqual(LANGUAGES.VIETNAMESE.label) | ||
}) | ||
|
||
test('should render the CHINESE flag when passed CHINESE value', () => { | ||
const chinaProps = { | ||
...props, | ||
value: LANGUAGES.CHINESE.value, | ||
} | ||
const wrapper = shallow(<LanguageSelect {...chinaProps} />) | ||
expect( | ||
wrapper | ||
.find('#selected-lang-country-flag') | ||
.children() | ||
|
||
.props().alt, | ||
).toEqual('中文') | ||
}) | ||
|
||
test('should render the CHINESE flag when passed CHINESE value', () => { | ||
const props = { | ||
...props, | ||
value: LANGUAGES.CHINESE.value, | ||
} | ||
const wrapper = shallow(<LanguageSelect {...props} />) | ||
expect( | ||
wrapper | ||
.find('#selected-lang-country-flag') | ||
.children() | ||
|
||
.props().alt, | ||
).toEqual('中文') | ||
}) | ||
|
||
test('should render the default flag (ENGLISH) when passed undefined value', () => { | ||
const props = { | ||
...props, | ||
value: undefined, | ||
} | ||
const wrapper = shallow(<LanguageSelect {...props} />) | ||
expect( | ||
wrapper | ||
.find('#selected-lang-country-flag') | ||
.children() | ||
|
||
.props().alt, | ||
).toEqual(LANGUAGES.ENGLISH.label) | ||
}) | ||
}) |
21 changes: 21 additions & 0 deletions
21
__tests__/components/Inputs/LanguageSelect/__snapshots__/LanguageSelect.test.js.snap
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,21 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`LanguageSelect should render without crashing 1`] = ` | ||
<div | ||
id="flagDropdownContainer" | ||
onClick={[Function]} | ||
> | ||
<div | ||
id="flagButtonContainer" | ||
> | ||
<div | ||
id="selected-lang-country-flag" | ||
onClick={[Function]} | ||
> | ||
<Component | ||
alt="Tiếng Việt" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
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