Skip to content

Commit 5527423

Browse files
authored
sync satellite tests (#2806)
1 parent 18bcdee commit 5527423

File tree

2 files changed

+108
-3
lines changed

2 files changed

+108
-3
lines changed

exercises/practice/satellite/.meta/tests.toml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[8df3fa26-811a-4165-9286-ff9ac0850d19]
613
description = "Empty tree"
@@ -19,3 +26,12 @@ description = "Reject inconsistent traversals of same length"
1926

2027
[d86a3d72-76a9-43b5-9d3a-e64cb1216035]
2128
description = "Reject traversals with repeated items"
29+
30+
[af31ae02-7e5b-4452-a990-bccb3fca9148]
31+
description = "A degenerate binary tree"
32+
33+
[ee54463d-a719-4aae-ade4-190d30ce7320]
34+
description = "Another degenerate binary tree"
35+
36+
[87123c08-c155-4486-90a4-e2f75b0f3e8f]
37+
description = "Tree with many more items"

exercises/practice/satellite/satellite.spec.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,93 @@ describe('Satellite', () => {
4949
treeFromTraversals(preorder, inorder);
5050
}).toThrow(new Error('traversals must contain unique items'));
5151
});
52+
53+
xtest('A degenerate binary tree', () => {
54+
const preorder = ['a', 'b', 'c', 'd'];
55+
const inorder = ['d', 'c', 'b', 'a'];
56+
const expected = {
57+
value: 'a',
58+
left: {
59+
value: 'b',
60+
left: {
61+
value: 'c',
62+
left: {
63+
value: 'd',
64+
left: {},
65+
right: {},
66+
},
67+
right: {},
68+
},
69+
right: {},
70+
},
71+
right: {},
72+
};
73+
expect(treeFromTraversals(preorder, inorder)).toEqual(expected);
74+
});
75+
76+
xtest('Another degenerate binary tree', () => {
77+
const preorder = ['a', 'b', 'c', 'd'];
78+
const inorder = ['a', 'b', 'c', 'd'];
79+
const expected = {
80+
value: 'a',
81+
left: {},
82+
right: {
83+
value: 'b',
84+
left: {},
85+
right: {
86+
value: 'c',
87+
left: {},
88+
right: {
89+
value: 'd',
90+
left: {},
91+
right: {},
92+
},
93+
},
94+
},
95+
};
96+
expect(treeFromTraversals(preorder, inorder)).toEqual(expected);
97+
});
98+
99+
xtest('Tree with many more items', () => {
100+
const preorder = ['a', 'b', 'd', 'g', 'h', 'c', 'e', 'f', 'i'];
101+
const inorder = ['g', 'd', 'h', 'b', 'a', 'e', 'c', 'i', 'f'];
102+
const expected = {
103+
value: 'a',
104+
left: {
105+
value: 'b',
106+
left: {
107+
value: 'd',
108+
left: {
109+
value: 'g',
110+
left: {},
111+
right: {},
112+
},
113+
right: {
114+
value: 'h',
115+
left: {},
116+
right: {},
117+
},
118+
},
119+
right: {},
120+
},
121+
right: {
122+
value: 'c',
123+
left: {
124+
value: 'e',
125+
left: {},
126+
right: {},
127+
},
128+
right: {
129+
value: 'f',
130+
left: {
131+
value: 'i',
132+
left: {},
133+
right: {},
134+
},
135+
right: {},
136+
},
137+
},
138+
};
139+
expect(treeFromTraversals(preorder, inorder)).toEqual(expected);
140+
});
52141
});

0 commit comments

Comments
 (0)