Advertisement
viligen

flowerShop

Jun 14th, 2022
788
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe('Tests fs', function () {
  2.     describe('calcPriceOfFlowers ', function () {
  3.         it('assert with valid params', function () {
  4.             assert.equal(
  5.                 flowerShop.calcPriceOfFlowers('rose', 5, 2),
  6.                 'You need $10.00 to buy rose!'
  7.             );
  8.             assert.equal(
  9.                 flowerShop.calcPriceOfFlowers('rose', 0, 2),
  10.                 'You need $0.00 to buy rose!'
  11.             );
  12.             assert.equal(
  13.                 flowerShop.calcPriceOfFlowers('rose', 5, 0),
  14.                 'You need $0.00 to buy rose!'
  15.             );
  16.         });
  17.  
  18.         it('assert with invalid params, expect to throw', function () {
  19.             assert.Throw(
  20.                 () => flowerShop.calcPriceOfFlowers(null, 5, 0),
  21.                 'Invalid input!'
  22.             );
  23.             assert.Throw(
  24.                 () => flowerShop.calcPriceOfFlowers('rose', '5', 0),
  25.                 'Invalid input!'
  26.             );
  27.             assert.Throw(
  28.                 () => flowerShop.calcPriceOfFlowers('rose', 7, '1'),
  29.                 'Invalid input!'
  30.             );
  31.             assert.Throw(
  32.                 () => flowerShop.calcPriceOfFlowers('rose', 7.6, 2),
  33.                 'Invalid input!'
  34.             );
  35.             assert.Throw(
  36.                 () => flowerShop.calcPriceOfFlowers('rose', 7, 2.9),
  37.                 'Invalid input!'
  38.             );
  39.         });
  40.     });
  41.  
  42.     describe('checkFlowersAvailable', function () {
  43.         it('assert  with valid param', function () {
  44.             assert.equal(
  45.                 flowerShop.checkFlowersAvailable('Rose', [
  46.                     'Rose',
  47.                     'Lily',
  48.                     'Orchid',
  49.                 ]),
  50.                 'The Rose are available!'
  51.             );
  52.         });
  53.         it('assert  with valid params no success', function () {
  54.             assert.equal(
  55.                 flowerShop.checkFlowersAvailable('Peony', [
  56.                     'Rose',
  57.                     'Lily',
  58.                     'Orchid',
  59.                 ]),
  60.                 'The Peony are sold! You need to purchase more!'
  61.             );
  62.         });
  63.     });
  64.     describe('sellFlowers', function () {
  65.         it('assert with valid params', function () {
  66.             assert.equal(
  67.                 flowerShop.sellFlowers(['Rose', 'Lily', 'Orchid'], 0),
  68.                 'Lily / Orchid'
  69.             );
  70.  
  71.             assert.equal(
  72.                 flowerShop.sellFlowers(['Rose', 'Lily', 'Orchid'], 1),
  73.                 'Rose / Orchid'
  74.             );
  75.         });
  76.         it('assert with invalid params', function () {
  77.             assert.throw(
  78.                 () => flowerShop.sellFlowers('Lily / Orchid', 0),
  79.                 'Invalid input!'
  80.             );
  81.             assert.throw(() => flowerShop.sellFlowers(0), 'Invalid input!');
  82.             assert.throw(
  83.                 () => flowerShop.sellFlowers(['Rose', 'Lily', 'Orchid'], '0'),
  84.                 'Invalid input!'
  85.             );
  86.             assert.throw(
  87.                 () => flowerShop.sellFlowers(['Rose', 'Lily', 'Orchid'], 1.4),
  88.                 'Invalid input!'
  89.             );
  90.             assert.throw(
  91.                 () => flowerShop.sellFlowers(['Rose', 'Lily', 'Orchid'], -1),
  92.                 'Invalid input!'
  93.             );
  94.             assert.throw(
  95.                 () => flowerShop.sellFlowers(['Rose', 'Lily', 'Orchid'], 3),
  96.                 'Invalid input!'
  97.             );
  98.         });
  99.     });
  100. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement