Skip to content

Commit 2364c24

Browse files
committed
Test that notes can be moved within a lane
1 parent 9222182 commit 2364c24

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

immutable_app/app/reducers/lanes.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,12 @@ export default function lanes(state = initialState, action) {
6363
const sourceId = action.sourceId;
6464
const targetId = action.targetId;
6565

66-
const lanes = state;
67-
const sourceLane = lanes.filter((lane) => {
66+
const sourceLane = state.find((lane) => {
6867
return lane.notes.indexOf(sourceId) >= 0;
69-
})[0];
70-
const targetLane = lanes.filter((lane) => {
68+
});
69+
const targetLane = state.find((lane) => {
7170
return lane.notes.indexOf(targetId) >= 0;
72-
})[0];
71+
});
7372
const sourceNoteIndex = sourceLane.notes.indexOf(sourceId);
7473
const targetNoteIndex = targetLane.notes.indexOf(targetId);
7574

immutable_app/tests/lane_reducer_test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,37 @@ describe('LaneReducer', () => {
141141
});
142142

143143
it('should allow moving notes within a lane', () => {
144+
const lane = {
145+
id: 'foobar',
146+
name: 'demo lane',
147+
notes: []
148+
};
149+
const sourceNoteId = '123456';
150+
const targetNoteId = '654321';
151+
152+
let lanes = reducer(undefined, {
153+
type: types.CREATE_LANE,
154+
lane: lane
155+
});
156+
lanes = reducer(lanes, {
157+
type: types.ATTACH_TO_LANE,
158+
laneId: lane.id,
159+
noteId: sourceNoteId
160+
});
161+
lanes = reducer(lanes, {
162+
type: types.ATTACH_TO_LANE,
163+
laneId: lane.id,
164+
noteId: targetNoteId
165+
});
166+
lanes = reducer(lanes, {
167+
type: types.MOVE,
168+
sourceId: sourceNoteId,
169+
targetId: targetNoteId,
170+
});
144171

172+
assert.equal(lanes.get(0).notes.length, 2);
173+
assert.equal(lanes.get(0).notes[0], targetNoteId);
174+
assert.equal(lanes.get(0).notes[1], sourceNoteId);
145175
});
146176

147177
it('should allow moving notes from a lane to lane', () => {

0 commit comments

Comments
 (0)