Test context loops
This commit is contained in:
parent
e6617af0f9
commit
8ed6d9fc6b
1 changed files with 26 additions and 2 deletions
|
@ -40,9 +40,7 @@ describe('contexts reducer', () => {
|
||||||
expect(result.inReplyTos.get('C')).toBe('C-tombstone');
|
expect(result.inReplyTos.get('C')).toBe('C-tombstone');
|
||||||
expect(result.replies.get('A').toArray()).toEqual(['C-tombstone']);
|
expect(result.replies.get('A').toArray()).toEqual(['C-tombstone']);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe(CONTEXT_FETCH_SUCCESS, () => {
|
|
||||||
it('inserts a tombstone connecting an orphaned descendant (with null in_reply_to_id)', () => {
|
it('inserts a tombstone connecting an orphaned descendant (with null in_reply_to_id)', () => {
|
||||||
const status = { id: 'A', in_reply_to_id: null };
|
const status = { id: 'A', in_reply_to_id: null };
|
||||||
|
|
||||||
|
@ -63,6 +61,32 @@ describe('contexts reducer', () => {
|
||||||
expect(result.inReplyTos.get('C')).toBe('C-tombstone');
|
expect(result.inReplyTos.get('C')).toBe('C-tombstone');
|
||||||
expect(result.replies.get('A').toArray()).toEqual(['C-tombstone']);
|
expect(result.replies.get('A').toArray()).toEqual(['C-tombstone']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('doesn\'t explode when it encounters a loop', () => {
|
||||||
|
const status = { id: 'A', in_reply_to_id: null };
|
||||||
|
|
||||||
|
const context = {
|
||||||
|
id: 'A',
|
||||||
|
ancestors: [],
|
||||||
|
descendants: [
|
||||||
|
{ id: 'C', in_reply_to_id: 'E' },
|
||||||
|
{ id: 'D', in_reply_to_id: 'C' },
|
||||||
|
{ id: 'E', in_reply_to_id: 'D' },
|
||||||
|
{ id: 'F', in_reply_to_id: 'F' },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const actions = [
|
||||||
|
{ type: STATUS_IMPORT, status },
|
||||||
|
{ type: CONTEXT_FETCH_SUCCESS, ...context },
|
||||||
|
];
|
||||||
|
|
||||||
|
const result = applyActions(undefined, actions, reducer);
|
||||||
|
|
||||||
|
// These checks are superficial. We just don't want a stack overflow!
|
||||||
|
expect(result.inReplyTos.get('C')).toBe('C-tombstone');
|
||||||
|
expect(result.replies.get('A').toArray()).toEqual(['C-tombstone', 'F-tombstone']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe(TIMELINE_DELETE, () => {
|
describe(TIMELINE_DELETE, () => {
|
||||||
|
|
Loading…
Reference in a new issue