Skip to content

Commit aa2b33d

Browse files
authored
Update tests two-buckets (#2765)
1 parent c6ff2ba commit aa2b33d

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

exercises/practice/two-bucket/.meta/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"contributors": [
66
"ankorGH",
77
"ganderzz",
8+
"jagdish-15",
89
"rchavarria",
910
"ryanplusplus",
1011
"slaymance",

exercises/practice/two-bucket/.meta/tests.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ description = "Measure one step using bucket one of size 1 and bucket two of siz
2727
[eb329c63-5540-4735-b30b-97f7f4df0f84]
2828
description = "Measure using bucket one of size 2 and bucket two of size 3 - start with bucket one and end with bucket two"
2929

30+
[58d70152-bf2b-46bb-ad54-be58ebe94c03]
31+
description = "Measure using bucket one much bigger than bucket two"
32+
33+
[9dbe6499-caa5-4a58-b5ce-c988d71b8981]
34+
description = "Measure using bucket one much smaller than bucket two"
35+
3036
[449be72d-b10a-4f4b-a959-ca741e333b72]
3137
description = "Not possible to reach the goal"
3238

exercises/practice/two-bucket/two-bucket.spec.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,35 @@ describe('TwoBucket', () => {
7474
});
7575
});
7676

77-
describe('Reachability', () => {
78-
const buckOne = 6;
79-
const buckTwo = 15;
77+
xtest('Measure using bucket one much bigger than bucket two', () => {
78+
const twoBucket = new TwoBucket(5, 1, 2, 'one');
79+
const result = twoBucket.solve();
80+
expect(result.moves).toEqual(6);
81+
expect(result.goalBucket).toEqual('one');
82+
expect(result.otherBucket).toEqual(1);
83+
});
8084

81-
xtest('Not possible to reach the goal, start with bucket one', () => {
82-
expect(() => new TwoBucket(buckOne, buckTwo, 5, 'one')).toThrow();
83-
});
85+
xtest('Measure using bucket one much smaller than bucket two', () => {
86+
const twoBucket = new TwoBucket(3, 15, 9, 'one');
87+
const result = twoBucket.solve();
88+
expect(result.moves).toEqual(6);
89+
expect(result.goalBucket).toEqual('two');
90+
expect(result.otherBucket).toEqual(0);
91+
});
8492

85-
xtest('Not possible to reach the goal, start with bucket two', () => {
86-
expect(() => new TwoBucket(buckOne, buckTwo, 5, 'two')).toThrow();
87-
});
93+
xtest('Not possible to reach the goal', () => {
94+
expect(() => new TwoBucket(6, 15, 5, 'one')).toThrow();
95+
});
8896

89-
xtest('With the same buckets but a different goal, then it is possible', () => {
90-
const starterBuck = 'one';
91-
const goal = 9;
92-
const twoBucket = new TwoBucket(buckOne, buckTwo, goal, starterBuck);
93-
const result = twoBucket.solve();
94-
expect(result.moves).toEqual(10);
95-
expect(result.goalBucket).toEqual('two');
96-
expect(result.otherBucket).toEqual(0);
97-
});
97+
xtest('With the same buckets but a different goal, then it is possible', () => {
98+
const twoBucket = new TwoBucket(6, 15, 9, 'one');
99+
const result = twoBucket.solve();
100+
expect(result.moves).toEqual(10);
101+
expect(result.goalBucket).toEqual('two');
102+
expect(result.otherBucket).toEqual(0);
98103
});
99104

100-
describe('Goal larger than both buckets', () => {
101-
xtest('Is impossible', () => {
102-
expect(() => new TwoBucket(5, 7, 8, 'one')).toThrow();
103-
});
105+
xtest('Goal larger than both buckets is impossible', () => {
106+
expect(() => new TwoBucket(5, 7, 8, 'one')).toThrow();
104107
});
105108
});

0 commit comments

Comments
 (0)