forked from react-boilerplate/react-boilerplate
-
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.
Reorg some templates and add tests (react-boilerplate#1414)
* Reorg some templates and add tests - Also make sure that we keep LanguageProvider tests after clean * Move to container structure for internals * Remove old filename ref * Actually remove folders, thanks @Dattaya
- Loading branch information
1 parent
239d8b0
commit e660697
Showing
24 changed files
with
160 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { DEFAULT_LOCALE } from '../containers/App/constants'; | ||
import { formatTranslationMessages } from '../i18n'; | ||
|
||
jest.mock('../translations/en.json', () => ( | ||
{ | ||
message1: 'default message', | ||
message2: 'default message 2', | ||
} | ||
)); | ||
|
||
const esTranslationMessages = { | ||
message1: 'mensaje predeterminado', | ||
message2: '', | ||
}; | ||
|
||
describe('formatTranslationMessages', () => { | ||
it('should build only defaults when DEFAULT_LOCALE', () => { | ||
const result = formatTranslationMessages(DEFAULT_LOCALE, { a: 'a' }); | ||
|
||
expect(result).toEqual({ a: 'a' }); | ||
}); | ||
|
||
|
||
it('should combine default locale and current locale when not DEFAULT_LOCALE', () => { | ||
const result = formatTranslationMessages('', esTranslationMessages); | ||
|
||
expect(result).toEqual({ | ||
message1: 'mensaje predeterminado', | ||
message2: 'default message 2', | ||
}); | ||
}); | ||
}); |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,16 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import App from '../index'; | ||
|
||
describe('<App />', () => { | ||
it('should render its children', () => { | ||
const children = (<h1>Test</h1>); | ||
const renderedComponent = shallow( | ||
<App> | ||
{children} | ||
</App> | ||
); | ||
expect(renderedComponent.contains(children)).toBe(true); | ||
}); | ||
}); |
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
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
internals/templates/containers/HomePage/tests/index.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,17 @@ | ||
import React from 'react'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import HomePage from '../index'; | ||
import messages from '../messages'; | ||
|
||
describe('<HomePage />', () => { | ||
it('should render the page message', () => { | ||
const renderedComponent = shallow( | ||
<HomePage /> | ||
); | ||
expect(renderedComponent.contains( | ||
<FormattedMessage {...messages.header} /> | ||
)).toEqual(true); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
internals/templates/containers/NotFoundPage/tests/index.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,17 @@ | ||
import React from 'react'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { shallow } from 'enzyme'; | ||
|
||
import NotFoundPage from '../index'; | ||
import messages from '../messages'; | ||
|
||
describe('<NotFoundPage />', () => { | ||
it('should render the page message', () => { | ||
const renderedComponent = shallow( | ||
<NotFoundPage /> | ||
); | ||
expect(renderedComponent.contains( | ||
<FormattedMessage {...messages.header} /> | ||
)).toEqual(true); | ||
}); | ||
}); |
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
File renamed without changes.
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