Skip to content

Commit

Permalink
Implement submitGroupName action creator with push to channel
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Solomon and Travis Vander Hoop committed Nov 26, 2019
1 parent dcc7a82 commit 9a56759
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/redux/groups_test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import deepFreeze from "deep-freeze"
import { spy } from "sinon"

import {
reducer as groupsReducer,
selectors,
actionCreators,
} from "../../web/static/js/redux/groups"

describe("groups reducer", () => {
Expand Down Expand Up @@ -155,3 +157,20 @@ describe("selectors", () => {
})
})
})

describe("action creators", () => {
describe("submitGroupName", () => {
it("pushes an 'update_group_name' event to the server, passing the args", () => {
const mockRetroChannel = { push: spy() }
const dispatchStub = () => {}
const getStateStub = () => {}

const groupArguments = { id: 666, name: "steven's domain" }
const thunk = actionCreators.submitGroupName(groupArguments)

thunk(dispatchStub, getStateStub, mockRetroChannel)

expect(mockRetroChannel.push).to.have.been.calledWith("update_group_name", groupArguments)
})
})
})
8 changes: 8 additions & 0 deletions web/static/js/redux/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ export const selectors = {
})
},
}

export const actionCreators = {
submitGroupName: groupArguments => {
return (dispatch, getState, retroChannel) => {
retroChannel.push("update_group_name", groupArguments)
}
},
}
2 changes: 2 additions & 0 deletions web/static/js/redux/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import {
reducer as groups,
selectors as groupSelectors,
actionCreators as groupActionCreators,
} from "./groups"

import {
Expand Down Expand Up @@ -86,6 +87,7 @@ export const actions = {
...mobileActions,
...voteActions,
...userOptionsActions,
...groupActionCreators,
}

export const selectors = {
Expand Down

0 comments on commit 9a56759

Please sign in to comment.