Skip to content

Commit

Permalink
Merge pull request ringcentral#57 from huanhulan/RCINT-5049
Browse files Browse the repository at this point in the history
test(getConferenceCallReducer.test.js): add test suits
  • Loading branch information
Lex. Huang authored Jun 12, 2018
2 parents 79dc47c + 4f537cc commit 655000b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function getMergingStatusReducer(types) {
};
}

export function getMergingPairReduce(types) {
export function getMergingPairReducer(types) {
return (state = {}, { type, from, to }) => {
switch (type) {
case types.updateFromSession:
Expand All @@ -112,6 +112,6 @@ export default function getConferenceCallReducer(types) {
conferences: getMakeConferenceCallReducer(types),
conferenceCallStatus: getConferenceCallStatusReducer(types),
isMerging: getMergingStatusReducer(types),
mergingPair: getMergingPairReduce(types),
mergingPair: getMergingPairReducer(types),
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import actionTypes from './actionTypes';
import getConferenceCallReducer, {
getConferenceCallStatusReducer,
getMakeConferenceCallReducer,
getMergingStatusReducer,
getMergingPairReducer,
} from './getConferenceCallReducer';
import getModuleStatusReducer from '../../lib/getModuleStatusReducer';
import conferenceCallStatus from './conferenceCallStatus';
Expand All @@ -20,16 +22,89 @@ describe('ConferenceCall :: getConferenceCallReducer', () => {
const statusReducer = getModuleStatusReducer(actionTypes);
const conferenceCallStatusReducer = getConferenceCallStatusReducer(actionTypes);
const conferencesReducer = getMakeConferenceCallReducer(actionTypes);
const mergingPairReducer = getMergingPairReducer(actionTypes);
const isMergingReducer = getMergingStatusReducer(actionTypes);

it('should return the combined initialState', () => {
expect(reducer(undefined, {})).to.deep.equal({
status: statusReducer(undefined, {}),
conferences: conferencesReducer(undefined, {}),
conferenceCallStatus: conferenceCallStatusReducer(undefined, {}),
isMerging: isMergingReducer(undefined, {}),
mergingPair: mergingPairReducer(undefined, {}),
});
});
});
});

describe('ConferenceCall :: getMergingStatusReducer', () => {
const reducer = getMergingStatusReducer(actionTypes);
it('should have initial state of false', () => {
expect(reducer(undefined, {})).to.equal(false);
});
it('should have state of false', () => {
[
'mergeSucceeded',
'mergeFailed',
'resetSuccess',
].forEach((type) => {
expect(reducer(undefined, {
type: actionTypes[type]
})).to.equal(false);
});
});
it('should have state of true', () => {
[
'mergeStart',
].forEach((type) => {
expect(reducer(undefined, {
type: actionTypes[type]
})).to.equal(true);
});
});
});

describe('ConferenceCall :: getMergingPairReducer', () => {
const reducer = getMergingPairReducer(actionTypes);
it('should have initial state of empty', () => {
// eslint-disable-next-line no-unused-expressions
expect(reducer(undefined, {})).to.be.an('object').that.is.empty;
});
it('should have the from field', () => {
const from = {};

expect(reducer(undefined, {
type: actionTypes.updateFromSession,
from,
})).to.deep.equal({
from
});
});

it('should have the to field', () => {
const to = {};

expect(reducer(undefined, {
type: actionTypes.updateToSession,
to,
})).to.deep.equal({
to
});
});

it('should reset to empty when reseting or merging successfully', () => {
[
'resetSuccess',
'mergeSucceeded',
].forEach((type) => {
// eslint-disable-next-line no-unused-expressions
expect(reducer(undefined, {
type: actionTypes[type]
})).to.be.an('object').that.is.empty;
});
});
});

describe('ConferenceCall :: getConferenceCallStatusReducer', () => {
const reducer = getConferenceCallStatusReducer(actionTypes);
it('should have initial state of idle', () => {
Expand Down

0 comments on commit 655000b

Please sign in to comment.