Skip to content

Commit

Permalink
fix(ui): update affected tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpaxton committed Mar 12, 2020
1 parent a1a1854 commit 5038ec2
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions ui/src/shared/reducers/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@ import appReducer from 'src/shared/reducers/app'
import {
enablePresentationMode,
disablePresentationMode,
enableDashboardLightMode,
disableDashboardLightMode,
setTheme,
setCurrentPage,
setAutoRefresh,
templateControlBarVisibilityToggled,
} from 'src/shared/actions/app'
import {TimeZone} from 'src/types'
import {AppState as AppPresentationState} from 'src/shared/reducers/app'

describe('Shared.Reducers.appReducer', () => {
const initialState = {
const initialState: AppPresentationState = {
ephemeral: {
inPresentationMode: false,
},
persisted: {
autoRefresh: 0,
showTemplateControlBar: false,
timeZone: 'Local' as TimeZone,
dashboardLightMode: false,
theme: 'dark',
currentPage: 'not set',
},
}

Expand All @@ -36,18 +37,24 @@ describe('Shared.Reducers.appReducer', () => {
expect(reducedState.ephemeral.inPresentationMode).toBe(false)
})

it('should handle ENABLE_DASHBOARD_LIGHT_MODE', () => {
const reducedState = appReducer(initialState, enableDashboardLightMode())
it('should handle SET_THEME with light theme', () => {
const reducedState = appReducer(initialState, setTheme('light'))

expect(reducedState.persisted.dashboardLightMode).toBe(true)
expect(reducedState.persisted.theme).toBe('light')
})

it('should handle DISABLE_DASHBOARD_LIGHT_MODE', () => {
Object.assign(initialState, {persisted: {dashboardLightMode: true}})
it('should handle SET_THEME with dark theme', () => {
Object.assign(initialState, {persisted: {theme: 'light'}})

const reducedState = appReducer(initialState, disableDashboardLightMode())
const reducedState = appReducer(initialState, setTheme('dark'))

expect(reducedState.persisted.dashboardLightMode).toBe(false)
expect(reducedState.persisted.theme).toBe('dark')
})

it('should handle SET_CURRENT_PAGE', () => {
const reducedState = appReducer(initialState, setCurrentPage('dashboard'))

expect(reducedState.persisted.currentPage).toBe('dashboard')
})

it('should handle SET_AUTOREFRESH', () => {
Expand All @@ -57,17 +64,4 @@ describe('Shared.Reducers.appReducer', () => {

expect(reducedState.persisted.autoRefresh).toBe(expectedMs)
})

it('should handle TEMPLATE_CONTROL_BAR_VISIBILITY_TOGGLED', () => {
const reducedState = appReducer(
initialState,
templateControlBarVisibilityToggled()
)

const expectedTestState = !reducedState.persisted.showTemplateControlBar

expect(initialState.persisted.showTemplateControlBar).toBe(
expectedTestState
)
})
})

0 comments on commit 5038ec2

Please sign in to comment.