Skip to content

Commit

Permalink
Rewrite testing
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-collier committed Jul 23, 2019
1 parent 39f0cbc commit a568e2d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
16 changes: 9 additions & 7 deletions __tests__/actionCreators/resources.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ describe('newResource', () => {
await store.dispatch(newResource(resourceTemplateId))
const actions = store.getActions()
expect(actions[0]).toEqual({ type: 'CLEAR_RESOURCE_TEMPLATES' })
expect(actions[1]).toEqual({ type: 'SET_RESOURCE', payload: { [resourceTemplateId]: {} } })
expect(actions[2]).toEqual({ type: 'RETRIEVE_RESOURCE_TEMPLATE_STARTED', payload: resourceTemplateId })
expect(actions[3]).toEqual({ type: 'SET_RESOURCE_TEMPLATE', payload: resourceTemplateResponse.response.body })
expect(actions[1]).toEqual({ type: 'CLEAR_RESOURCE_URI_MESSAGE' })
expect(actions[2]).toEqual({ type: 'SET_RESOURCE', payload: { [resourceTemplateId]: {} } })
expect(actions[3]).toEqual({ type: 'RETRIEVE_RESOURCE_TEMPLATE_STARTED', payload: resourceTemplateId })
expect(actions[4]).toEqual({ type: 'SET_RESOURCE_TEMPLATE', payload: resourceTemplateResponse.response.body })
})
})

Expand All @@ -114,10 +115,11 @@ describe('existingResource', () => {

await store.dispatch(existingResource(resource, 'http://localhost:8080/repository/stanford/888ea64d-f471-41bf-9d33-c9426ab83b5c'))
const actions = store.getActions()
expect(actions[0]).toEqual({ type: 'SET_RESOURCE', payload: { [resourceTemplateId]: {} } })
expect(actions[1]).toEqual({ type: 'SET_BASE_URL', payload: 'http://localhost:8080/repository/stanford/888ea64d-f471-41bf-9d33-c9426ab83b5c' })
expect(actions[2]).toEqual({ type: 'RETRIEVE_RESOURCE_TEMPLATE_STARTED', payload: undefined })
expect(actions[3]).toEqual({ type: 'SET_RESOURCE_TEMPLATE', payload: resourceTemplateResponse.response.body })
expect(actions[0]).toEqual({ type: 'CLEAR_RESOURCE_URI_MESSAGE' })
expect(actions[1]).toEqual({ type: 'SET_RESOURCE', payload: { [resourceTemplateId]: {} } })
expect(actions[2]).toEqual({ type: 'SET_BASE_URL', payload: 'http://localhost:8080/repository/stanford/888ea64d-f471-41bf-9d33-c9426ab83b5c' })
expect(actions[3]).toEqual({ type: 'RETRIEVE_RESOURCE_TEMPLATE_STARTED', payload: undefined })
expect(actions[4]).toEqual({ type: 'SET_RESOURCE_TEMPLATE', payload: resourceTemplateResponse.response.body })
})
})

Expand Down
8 changes: 4 additions & 4 deletions __tests__/reducers/inputs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {
removeMyItem, setItemsOrSelections, setBaseURL,
validate, showGroupChooser, closeGroupChooser, showRdfPreview,
showResourceURIMessage, clearingResourceURIMessage,
showResourceURIMessage, clearResourceURIMessage,
} from 'reducers/inputs'

import {
Expand Down Expand Up @@ -365,15 +365,15 @@ describe('showResourceURIMessage', () => {
})
})

describe('clearingResourceURIMessage', () => {
describe('clearResourceURIMessage', () => {
it('turns off the Resource URI message display', () => {
initialState.editor.resourceURIMessage = {
show: true,
uri: 'this message will disapear',
}

const result = clearingResourceURIMessage(initialState, {
type: 'CLEARING_RESOURCE_URI_MESSAGE',
const result = clearResourceURIMessage(initialState, {
type: 'CLEAR_RESOURCE_URI_MESSAGE',
})

expect(result.editor.resourceURIMessage.show).toBe(false)
Expand Down

0 comments on commit a568e2d

Please sign in to comment.