Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exercises/practice/two-bucket/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"contributors": [
"ankorGH",
"ganderzz",
"jagdish-15",
"rchavarria",
"ryanplusplus",
"slaymance",
Expand Down
6 changes: 6 additions & 0 deletions exercises/practice/two-bucket/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ description = "Measure one step using bucket one of size 1 and bucket two of siz
[eb329c63-5540-4735-b30b-97f7f4df0f84]
description = "Measure using bucket one of size 2 and bucket two of size 3 - start with bucket one and end with bucket two"

[58d70152-bf2b-46bb-ad54-be58ebe94c03]
description = "Measure using bucket one much bigger than bucket two"

[9dbe6499-caa5-4a58-b5ce-c988d71b8981]
description = "Measure using bucket one much smaller than bucket two"

[449be72d-b10a-4f4b-a959-ca741e333b72]
description = "Not possible to reach the goal"

Expand Down
47 changes: 25 additions & 22 deletions exercises/practice/two-bucket/two-bucket.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,35 @@ describe('TwoBucket', () => {
});
});

describe('Reachability', () => {
const buckOne = 6;
const buckTwo = 15;
xtest('Measure using bucket one much bigger than bucket two', () => {
const twoBucket = new TwoBucket(5, 1, 2, 'one');
const result = twoBucket.solve();
expect(result.moves).toEqual(6);
expect(result.goalBucket).toEqual('one');
expect(result.otherBucket).toEqual(1);
});

xtest('Not possible to reach the goal, start with bucket one', () => {
expect(() => new TwoBucket(buckOne, buckTwo, 5, 'one')).toThrow();
});
xtest('Measure using bucket one much smaller than bucket two', () => {
const twoBucket = new TwoBucket(3, 15, 9, 'one');
const result = twoBucket.solve();
expect(result.moves).toEqual(6);
expect(result.goalBucket).toEqual('two');
expect(result.otherBucket).toEqual(0);
});

xtest('Not possible to reach the goal, start with bucket two', () => {
expect(() => new TwoBucket(buckOne, buckTwo, 5, 'two')).toThrow();
});
xtest('Not possible to reach the goal', () => {
expect(() => new TwoBucket(6, 15, 5, 'one')).toThrow();
});

xtest('With the same buckets but a different goal, then it is possible', () => {
const starterBuck = 'one';
const goal = 9;
const twoBucket = new TwoBucket(buckOne, buckTwo, goal, starterBuck);
const result = twoBucket.solve();
expect(result.moves).toEqual(10);
expect(result.goalBucket).toEqual('two');
expect(result.otherBucket).toEqual(0);
});
xtest('With the same buckets but a different goal, then it is possible', () => {
const twoBucket = new TwoBucket(6, 15, 9, 'one');
const result = twoBucket.solve();
expect(result.moves).toEqual(10);
expect(result.goalBucket).toEqual('two');
expect(result.otherBucket).toEqual(0);
});

describe('Goal larger than both buckets', () => {
xtest('Is impossible', () => {
expect(() => new TwoBucket(5, 7, 8, 'one')).toThrow();
});
xtest('Goal larger than both buckets is impossible', () => {
expect(() => new TwoBucket(5, 7, 8, 'one')).toThrow();
});
});