Created
June 9, 2018 23:51
-
-
Save eloytoro/a2ee53070abf3c94a13ab779d46655a2 to your computer and use it in GitHub Desktop.
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
const builder = require('../'); | |
const { expect } = require('chai'); | |
describe('ice cream', () => { | |
it('builds an ice cream cone', () => { | |
const serving = builder | |
.steps({ | |
scoop: ({ scoops }, flavor) => ({ scoops: scoops.concat(flavor) }), | |
}) | |
.endings({ | |
topping: (cone, topping) => ({ ...cone, topping }) | |
}) | |
.unwrap({ scoops: [] }) | |
const basic = serving | |
.scoop('chocolate') | |
const holygrail = basic | |
.scoop('coconut') | |
.scoop('banana') | |
const perfection = holygrail | |
.topping('cherry'); | |
const ruined = holygrail | |
.topping('sprinkles'); | |
const enthusiast = basic | |
.scoop('chocolate') | |
.scoop('chocolate') | |
.topping('chocolate chip'); | |
const disgrace = basic | |
.scoop('rum & raisins') | |
.topping('peanuts'); | |
expect(perfection).to.eql({ | |
scoops: ['chocolate', 'coconut', 'banana'], | |
topping: 'cherry' | |
}); | |
expect(ruined).to.eql({ | |
scoops: ['chocolate', 'coconut', 'banana'], | |
topping: 'sprinkles' | |
}); | |
expect(enthusiast).to.eql({ | |
scoops: ['chocolate', 'chocolate', 'chocolate'], | |
topping: 'chocolate chip' | |
}); | |
expect(disgrace).to.eql({ | |
scoops: ['chocolate', 'rum & raisins'], | |
topping: 'peanuts' | |
}); | |
}) | |
}) |
Author
eloytoro
commented
Jun 10, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment