Use rewire to test unexported functions

This commit is contained in:
Ken-Håvard Lieng 2017-06-23 03:06:44 +02:00
parent 0dcfcbbafd
commit 6c7bf0d81a
5 changed files with 13 additions and 3 deletions

View File

@ -20,7 +20,10 @@
"plugins": ["react-hot-loader/babel"]
},
"test": {
"plugins": ["transform-es2015-modules-commonjs"]
"plugins": [
"rewire",
"transform-es2015-modules-commonjs"
]
},
"production": {
"plugins": [

View File

@ -10,6 +10,7 @@
"babel-jest": "^20.0.0",
"babel-loader": "^7.0.0",
"babel-plugin-module-resolver": "^2.7.1",
"babel-plugin-rewire": "^1.1.0",
"babel-plugin-transform-react-constant-elements": "^6.23.0",
"babel-plugin-transform-react-inline-elements": "^6.22.0",
"babel-preset-es2015": "^6.22.0",

View File

@ -1,5 +1,5 @@
import { Map, fromJS } from 'immutable';
import reducer, { broadcast, getMessageTab } from '../messages';
import reducer, { broadcast } from '../messages';
import * as actions from '../actions';
import appReducer from '../app';
@ -178,6 +178,8 @@ describe('message reducer', () => {
});
describe('getMessageTab()', () => {
const getMessageTab = reducer.__get__('getMessageTab');
it('returns the correct tab', () => {
const srv = 'chat.freenode.net';
[

View File

@ -117,7 +117,7 @@ function initMessage(message, tab, state) {
return message;
}
export function getMessageTab(server, to) {
function getMessageTab(server, to) {
if (!to || to === '*' || (!isChannel(to) && to.indexOf('.') !== -1)) {
return server;
}

View File

@ -522,6 +522,10 @@ babel-plugin-module-resolver@^2.7.1:
glob "^7.1.1"
resolve "^1.2.0"
babel-plugin-rewire@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/babel-plugin-rewire/-/babel-plugin-rewire-1.1.0.tgz#a6b966d9d8c06c03d95dcda2eec4e2521519549b"
babel-plugin-syntax-async-functions@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"