Skip to content

Commit

Permalink
add test with complex deps tree
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Oct 28, 2020
1 parent 058a8d3 commit 7d2e4d5
Showing 1 changed file with 115 additions and 0 deletions.
115 changes: 115 additions & 0 deletions src/core/server/saved_objects/export/sort_objects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,119 @@ describe('sortObjects()', () => {
]
`);
});
test('should not fail on complex circular dependencies', () => {
const docs = [
{
id: '1',
type: 'foo',
attributes: {},
references: [
{
name: 'ref12',
type: 'foo',
id: '2',
},
{
name: 'ref13',
type: 'baz',
id: '3',
},
],
},
{
id: '2',
type: 'foo',
attributes: {},
references: [
{
name: 'ref13',
type: 'foo',
id: '3',
},
],
},
{
id: '3',
type: 'baz',
attributes: {},
references: [
{
name: 'ref13',
type: 'xyz',
id: '4',
},
],
},
{
id: '4',
type: 'xyz',
attributes: {},
references: [
{
name: 'ref14',
type: 'foo',
id: '1',
},
],
},
];

expect(sortObjects(docs)).toMatchInlineSnapshot(`
Array [
Object {
"attributes": Object {},
"id": "2",
"references": Array [
Object {
"id": "3",
"name": "ref13",
"type": "foo",
},
],
"type": "foo",
},
Object {
"attributes": Object {},
"id": "4",
"references": Array [
Object {
"id": "1",
"name": "ref14",
"type": "foo",
},
],
"type": "xyz",
},
Object {
"attributes": Object {},
"id": "3",
"references": Array [
Object {
"id": "4",
"name": "ref13",
"type": "xyz",
},
],
"type": "baz",
},
Object {
"attributes": Object {},
"id": "1",
"references": Array [
Object {
"id": "2",
"name": "ref12",
"type": "foo",
},
Object {
"id": "3",
"name": "ref13",
"type": "baz",
},
],
"type": "foo",
},
]
`);
});
});

0 comments on commit 7d2e4d5

Please sign in to comment.