Skip to content

Commit

Permalink
fix(ui/tasks): updated reducer test to more accurately reflect the cu…
Browse files Browse the repository at this point in the history
…rrent reducer functionality and updated the parameter name for consistency
  • Loading branch information
asalem1 committed Oct 23, 2019
1 parent af3b16c commit 579dbda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ui/src/tasks/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,11 @@ export const selectTaskByID = (id: string) => async (
}
}

export const setAllTaskOptionsByID = (id: string) => async (
export const setAllTaskOptionsByID = (taskID: string) => async (
dispatch
): Promise<void> => {
try {
const task = await client.tasks.get(id)
const task = await client.tasks.get(taskID)
dispatch(setAllTaskOptions(task))
} catch (e) {
console.error(e)
Expand Down
16 changes: 9 additions & 7 deletions ui/src/tasks/reducers/tasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import {setTaskOption} from 'src/tasks/actions'
import {TaskSchedule} from 'src/utils/taskOptionsToFluxScript'

// skipping this test since the cron and interval values should not be reset when toggling between schedule tasks
describe.skip('tasksReducer', () => {
describe('tasksReducer', () => {
describe('setTaskOption', () => {
it('clears the cron property from the task options when interval is selected', () => {
it('should not clear the cron property from the task options when interval is selected', () => {
const initialState = defaultState
initialState.taskOptions = {...defaultTaskOptions, cron: '0 2 * * *'}
const cron = '0 2 * * *'
initialState.taskOptions = {...defaultTaskOptions, cron }

const actual = tasksReducer(
initialState,
Expand All @@ -22,16 +23,17 @@ describe.skip('tasksReducer', () => {
taskOptions: {
...defaultTaskOptions,
taskScheduleType: TaskSchedule.interval,
cron: '',
cron,
},
}

expect(actual).toEqual(expected)
})

it('clears the interval property from the task options when cron is selected', () => {
it('should not clear the interval property from the task options when cron is selected', () => {
const initialState = defaultState
initialState.taskOptions = {...defaultTaskOptions, interval: '24h'} // todo(docmerlin): allow for time units larger than 1d, right now h is the longest unit our s
const interval = '24h'
initialState.taskOptions = {...defaultTaskOptions, interval } // todo(docmerlin): allow for time units larger than 1d, right now h is the longest unit our s

const actual = tasksReducer(
initialState,
Expand All @@ -43,7 +45,7 @@ describe.skip('tasksReducer', () => {
taskOptions: {
...defaultTaskOptions,
taskScheduleType: TaskSchedule.cron,
interval: '',
interval,
},
}

Expand Down

0 comments on commit 579dbda

Please sign in to comment.