-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2768 from weaveworks/pods-on-details-pages
Fix including pods in details pages
- Loading branch information
Showing
2 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { flattenChildren } from "../flux"; | ||
|
||
describe("flattenChildren", () => { | ||
it("supports empty", () => { | ||
const empty = []; | ||
expect(flattenChildren(empty)).toEqual([]); | ||
}); | ||
|
||
it("handles nested", () => { | ||
const nested = [ | ||
{ | ||
name: "1", | ||
children: [{ name: "2", children: [{ name: "3", children: [] }] }], | ||
}, | ||
]; | ||
const flattened = flattenChildren(nested); | ||
expect(flattened[0]).toMatchObject({ name: "1" }); | ||
expect(flattened[1]).toMatchObject({ name: "2" }); | ||
expect(flattened[2]).toMatchObject({ name: "3" }); | ||
}); | ||
|
||
it("handles multiple", () => { | ||
const multiple = [ | ||
{ name: "1", children: [] }, | ||
{ | ||
name: "2", | ||
children: [ | ||
{ name: "3", children: [] }, | ||
{ name: "4", children: [] }, | ||
], | ||
}, | ||
]; | ||
const flattened = flattenChildren(multiple); | ||
expect(flattened[0]).toMatchObject({ name: "1" }); | ||
expect(flattened[1]).toMatchObject({ name: "2" }); | ||
expect(flattened[2]).toMatchObject({ name: "3" }); | ||
expect(flattened[3]).toMatchObject({ name: "4" }); | ||
}); | ||
|
||
it("breaks if the format changes", () => { | ||
// No children property suggests API has changed | ||
const invalid = [{ name: "1" }]; | ||
expect(() => flattenChildren(invalid)).toThrow(TypeError); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters