Commit a218e819 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Assure all `thread` objects are assigned a unique `id`

parent 51ef55a1
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
* Default state for new threads * Default state for new threads
*/ */
const DEFAULT_THREAD_STATE = { const DEFAULT_THREAD_STATE = {
id: '__default__',
collapsed: false, collapsed: false,
visible: true, visible: true,
replyCount: 0, replyCount: 0,
...@@ -88,6 +87,7 @@ function setParent(threads, id, parents = []) { ...@@ -88,6 +87,7 @@ function setParent(threads, id, parents = []) {
threads[parentId] = { threads[parentId] = {
...DEFAULT_THREAD_STATE, ...DEFAULT_THREAD_STATE,
children: [], children: [],
id: parentId,
}; };
// Link up this new thread to _its_ parent, which should be the original // Link up this new thread to _its_ parent, which should be the original
// thread's grandparent // thread's grandparent
......
...@@ -184,11 +184,14 @@ describe('sidebar/util/build-thread', function () { ...@@ -184,11 +184,14 @@ describe('sidebar/util/build-thread', function () {
references: ['3'], references: ['3'],
}, },
]; ];
const thread = createThread(fixture); // Get the threads with `id` key included
const thread = createThread(fixture, {}, ['id']);
// It should create a thread with an id of the missing annotation (3)
assert.deepEqual(thread, [ assert.deepEqual(thread, [
{ {
id: '3',
annotation: undefined, annotation: undefined,
children: [{ annotation: fixture[0], children: [] }], children: [{ id: '1', annotation: fixture[0], children: [] }],
}, },
]); ]);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment