-
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.
Merge pull request #29 from KPMP/develop
Release v1.3
- Loading branch information
Showing
14 changed files
with
188 additions
and
45 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
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
6 changes: 4 additions & 2 deletions
6
src/components/PackageDashboard/PackageDashboardPageContainer.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
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,15 @@ | ||
export const getStateDisplayText = (state, stateDisplayMap) => { | ||
|
||
let stateDisplayText = stateDisplayMap.filter(function(stateDisplayItem) { | ||
if (stateDisplayItem.state === state.state) { | ||
return stateDisplayItem; | ||
} | ||
return undefined; | ||
}, state); | ||
|
||
if (stateDisplayText[0]) { | ||
return stateDisplayText[0].apps.dmd.text | ||
} else { | ||
return ''; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/components/PackageDashboard/stateDisplayHelper.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 { getStateDisplayText } from './stateDisplayHelper'; | ||
import React from 'react'; | ||
|
||
describe('getStateDisplayText', () => { | ||
it('should return empty string when no match', () => { | ||
expect(getStateDisplayText({},[])).toEqual(''); | ||
}); | ||
|
||
it('should return the correct state text', () => { | ||
let state = { state: 'alive' }; | ||
let stateDisplayMap = [ | ||
{ state: 'alive', apps: { dmd: { text: 'hey ho' }}}, | ||
{ state: 'dead', apps: { dmd: { text: 'oh no' }}} | ||
]; | ||
expect(getStateDisplayText(state, stateDisplayMap)).toEqual('hey ho'); | ||
}) | ||
}); |
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,13 @@ | ||
import actionNames from '../../actions/actionNames'; | ||
|
||
export const stateDisplayMap = (state = {}, action) => { | ||
let newState = {}; | ||
let stateDisplayMap = action.payload; | ||
switch (action.type) { | ||
case actionNames.SET_STATE_DISPLAY_MAP: | ||
newState = stateDisplayMap; | ||
return newState; | ||
default: | ||
return state; | ||
}; | ||
}; |
31 changes: 31 additions & 0 deletions
31
src/components/PackageDashboard/stateDisplayMapReducer.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,31 @@ | ||
import actionNames from '../../actions/actionNames'; | ||
import { stateDisplayMap } from './stateDisplayMapReducer'; | ||
|
||
describe('stateDisplayMap', () => { | ||
it('should return the given state when not SET_STATE_DISPLAY_MAP', () => { | ||
let action = { | ||
type: 'SOME_OTHER_ACTION', | ||
payload: [{'key': 'value'}] | ||
}; | ||
let expectedState = [ {'stateKey': 'stateValue'}]; | ||
expect(stateDisplayMap(expectedState, action)).toEqual(expectedState); | ||
}); | ||
|
||
it('should return {} in state if state is undefined and not a covered action', () => { | ||
let action = { | ||
type: 'SOME_OTHER_ACTION', | ||
payload: [{'key': 'value'}] | ||
}; | ||
expect(stateDisplayMap(undefined, action)).toEqual({}); | ||
}); | ||
|
||
it('should construct the appropriate state for SET_STATE_DISPLAY_MAP action', () => { | ||
let action = { | ||
type: actionNames.SET_STATE_DISPLAY_MAP, | ||
payload: { 'map': 'a' } | ||
}; | ||
let expectedState = { 'map': 'a' }; | ||
|
||
expect(stateDisplayMap({}, action)).toEqual(expectedState); | ||
}); | ||
}); |
This file was deleted.
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