Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('Tests fs', function () {
- describe('calcPriceOfFlowers ', function () {
- it('assert with valid params', function () {
- assert.equal(
- flowerShop.calcPriceOfFlowers('rose', 5, 2),
- 'You need $10.00 to buy rose!'
- );
- assert.equal(
- flowerShop.calcPriceOfFlowers('rose', 0, 2),
- 'You need $0.00 to buy rose!'
- );
- assert.equal(
- flowerShop.calcPriceOfFlowers('rose', 5, 0),
- 'You need $0.00 to buy rose!'
- );
- });
- it('assert with invalid params, expect to throw', function () {
- assert.Throw(
- () => flowerShop.calcPriceOfFlowers(null, 5, 0),
- 'Invalid input!'
- );
- assert.Throw(
- () => flowerShop.calcPriceOfFlowers('rose', '5', 0),
- 'Invalid input!'
- );
- assert.Throw(
- () => flowerShop.calcPriceOfFlowers('rose', 7, '1'),
- 'Invalid input!'
- );
- assert.Throw(
- () => flowerShop.calcPriceOfFlowers('rose', 7.6, 2),
- 'Invalid input!'
- );
- assert.Throw(
- () => flowerShop.calcPriceOfFlowers('rose', 7, 2.9),
- 'Invalid input!'
- );
- });
- });
- describe('checkFlowersAvailable', function () {
- it('assert with valid param', function () {
- assert.equal(
- flowerShop.checkFlowersAvailable('Rose', [
- 'Rose',
- 'Lily',
- 'Orchid',
- ]),
- 'The Rose are available!'
- );
- });
- it('assert with valid params no success', function () {
- assert.equal(
- flowerShop.checkFlowersAvailable('Peony', [
- 'Rose',
- 'Lily',
- 'Orchid',
- ]),
- 'The Peony are sold! You need to purchase more!'
- );
- });
- });
- describe('sellFlowers', function () {
- it('assert with valid params', function () {
- assert.equal(
- flowerShop.sellFlowers(['Rose', 'Lily', 'Orchid'], 0),
- 'Lily / Orchid'
- );
- assert.equal(
- flowerShop.sellFlowers(['Rose', 'Lily', 'Orchid'], 1),
- 'Rose / Orchid'
- );
- });
- it('assert with invalid params', function () {
- assert.throw(
- () => flowerShop.sellFlowers('Lily / Orchid', 0),
- 'Invalid input!'
- );
- assert.throw(() => flowerShop.sellFlowers(0), 'Invalid input!');
- assert.throw(
- () => flowerShop.sellFlowers(['Rose', 'Lily', 'Orchid'], '0'),
- 'Invalid input!'
- );
- assert.throw(
- () => flowerShop.sellFlowers(['Rose', 'Lily', 'Orchid'], 1.4),
- 'Invalid input!'
- );
- assert.throw(
- () => flowerShop.sellFlowers(['Rose', 'Lily', 'Orchid'], -1),
- 'Invalid input!'
- );
- assert.throw(
- () => flowerShop.sellFlowers(['Rose', 'Lily', 'Orchid'], 3),
- 'Invalid input!'
- );
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement