Advertisement
bebo231312312321

Untitled

Jun 17th, 2023
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe("Test functionality lottary",()=>{
  2.     describe('Test buyLotteryTicket method ', ()=>{
  3.         it("Test Invalid inputs",()=>{
  4.             expect(()=>lottery.buyLotteryTicket(3,3,false)).to.throw("Unable to buy lottery ticket!")
  5.             expect(()=>lottery.buyLotteryTicket(-1,3,true)).to.throw("Invalid input!")
  6.             expect(()=>lottery.buyLotteryTicket("a",3,true)).to.throw("Invalid input!")
  7.             expect(()=>lottery.buyLotteryTicket("a","a",true)).to.throw("Invalid input!")
  8.             expect(()=>lottery.buyLotteryTicket(-1,"",true)).to.throw("Invalid input!")
  9.             expect(()=>lottery.buyLotteryTicket(-1,-3,true)).to.throw("Invalid input!")
  10.             expect(()=>lottery.buyLotteryTicket('',-3,true)).to.throw("Invalid input!")
  11.             expect(()=>lottery.buyLotteryTicket(3,"3",false)).to.throw("Unable to buy lottery ticket!")
  12.             expect(()=>lottery.buyLotteryTicket('',3,false)).to.throw("Unable to buy lottery ticket!")
  13.             expect(()=>lottery.buyLotteryTicket(-1,3,false)).to.throw("Unable to buy lottery ticket!")
  14.             expect(()=>lottery.buyLotteryTicket([],"a",true)).to.throw("Invalid input!")
  15.             expect(()=>lottery.buyLotteryTicket("a",{},true)).to.throw("Invalid input!")
  16.             expect(()=>lottery.buyLotteryTicket(null,{},true)).to.throw("Invalid input!")
  17.             expect(()=>lottery.buyLotteryTicket(0,0,true)).to.throw("Invalid input!")
  18.             expect(()=>lottery.buyLotteryTicket('',0,true)).to.throw("Invalid input!")
  19.             expect(()=>lottery.buyLotteryTicket(0,'',true)).to.throw("Invalid input!")
  20.             expect(()=>lottery.buyLotteryTicket(1,0,true)).to.throw("Invalid input!")
  21.             expect(()=>lottery.buyLotteryTicket(0,1,true)).to.throw("Invalid input!")
  22.             expect(()=>lottery.buyLotteryTicket(1,1,false)).to.throw("Unable to buy lottery ticket!")
  23.             expect(()=>lottery.buyLotteryTicket(1,1,false)).to.throw("Unable to buy lottery ticket!")
  24.             expect(()=>lottery.buyLotteryTicket(1.1,1,false)).to.throw("Unable to buy lottery ticket!")
  25.             expect(()=>lottery.buyLotteryTicket(1,1.1,false)).to.throw("Unable to buy lottery ticket!")
  26.  
  27.            
  28.  
  29.         })
  30.         it("test valid input",()=>{
  31.             expect(lottery.buyLotteryTicket(1,1,true)).to.equal("You bought 1 tickets for 1$.")
  32.             expect(lottery.buyLotteryTicket(1,10,true)).to.equal("You bought 10 tickets for 10$.")
  33.             expect(lottery.buyLotteryTicket(3,10,true)).to.equal("You bought 10 tickets for 30$.")
  34.             expect(lottery.buyLotteryTicket(2,2,true)).to.equal("You bought 2 tickets for 4$.")
  35.             expect(lottery.buyLotteryTicket(30,1,true)).to.equal("You bought 1 tickets for 30$.")    
  36.             expect(lottery.buyLotteryTicket(30,1,true)).to.equal("You bought 1 tickets for 30$.")    
  37.  
  38.         })
  39.  
  40.     })
  41.     describe("Test checkTicket method",()=>{
  42.         it('Test Invalid inputs',()=>{
  43.             expect(()=> lottery.checkTicket({},["v"])).to.throw("Invalid input!")
  44.             expect(()=> lottery.checkTicket(null,[])).to.throw("Invalid input!")
  45.             expect(()=> lottery.checkTicket([],'')).to.throw("Invalid input!")
  46.             expect(()=> lottery.checkTicket('',["v"])).to.throw("Invalid input!")
  47.             expect(()=> lottery.checkTicket(undefined,"")).to.throw("Invalid input!")
  48.             expect(()=> lottery.checkTicket({},undefined)).to.throw("Invalid input!")
  49.             expect(()=> lottery.checkTicket("","v")).to.throw("Invalid input!")
  50.             expect(()=> lottery.checkTicket(1,["v"])).to.throw("Invalid input!")
  51.             expect(()=> lottery.checkTicket(1.2,2)).to.throw("Invalid input!")
  52.             expect(()=> lottery.checkTicket(0,2)).to.throw("Invalid input!")
  53.             expect(()=> lottery.checkTicket("",0)).to.throw("Invalid input!")
  54.             expect(()=>lottery.checkTicket([1,2,3,4,5],[6,7,8,9,10])).to.throw("Invalid input!")
  55.             expect(()=>lottery.checkTicket([1,2,3,4,5],[0,1,8,9,10])).to.throw("Invalid input!")
  56.             expect(()=>lottery.checkTicket([1,2,3],[6,7,8,9,10])).to.throw("Invalid input!")
  57.             expect(()=>lottery.checkTicket([1,2,3,4,5],[5,4,9,10])).to.throw("Invalid input!")
  58.             expect(()=>lottery.checkTicket([1,2,3,4,5],[1,2,10])).to.throw("Invalid input!")
  59.             //  expect(()=>lottery.checkTicket([1,2,3,4,5],[2,1,8,9,10])).to.throw("Invalid input!")  
  60.             //  expect(()=>lottery.checkTicket([1,2,3,4,5,6],[11,11,31,41,5,6])).to.throw("Invalid input!")  
  61.             //  expect(()=>lottery.checkTicket([1,2,3,4,5,6],[11,21,31,41,15,6])).to.throw("Invalid input!")  
  62.               expect(()=>lottery.checkTicket([1,2,3,4,5,7.6],[11,21,31,41,15,6,7])).to.throw("Invalid input!")  
  63.               expect(()=>lottery.checkTicket([1,2,3,4,5,6,7],[11,21,31,41,15,6])).to.throw("Invalid input!")  
  64.  
  65.             expect(() => lottery.checkTicket("invalid", [1, 2.2, 3, 4, 5, 6])).to.throw("Invalid input!");
  66.             expect(() => lottery.checkTicket([1.3, 2, 3, 4, 5, 6], "invalid")).to.throw("Invalid input!");
  67.          
  68.         })
  69.         it("Test valid inpus",()=>{
  70.             expect(lottery.checkTicket([1,2,3,4,5,6],[1,2,3,4,5,6])).to.equal("You win the JACKPOT!!!")
  71.             expect(lottery.checkTicket([1,2,3,4,5,6],[1,11,13,4,5,7])).to.equal("Congratulations you win, check your reward!")
  72.             expect(lottery.checkTicket([1,2.2,3,4,5,6],[1,21,3,4,5,6])).to.equal("Congratulations you win, check your reward!")
  73.             expect(lottery.checkTicket([1,2.2,3,4,5,6],[1,2.1,3,4,5,7])).to.equal("Congratulations you win, check your reward!")
  74.  
  75.         })
  76.     })
  77.  
  78.     describe("test secondChance method ",()=>{
  79.         it('Test Invalid Inputs',()=>{
  80.             expect(()=> lottery.secondChance("",[])).to.throw("Invalid input!")
  81.             expect(()=> lottery.secondChance(1,"")).to.throw("Invalid input!")
  82.             expect(()=> lottery.secondChance(null,[])).to.throw("Invalid input!")
  83.             expect(()=> lottery.secondChance({},[])).to.throw("Invalid input!")
  84.             expect(()=> lottery.secondChance("",{})).to.throw("Invalid input!")
  85.             expect(()=> lottery.secondChance("",1)).to.throw("Invalid input!")
  86.             expect(()=> lottery.secondChance("","")).to.throw("Invalid input!")
  87.             expect(()=> lottery.secondChance(2,2)).to.throw("Invalid input!")
  88.          
  89.           expect(()=> lottery.secondChance("-1",-1)).to.throw("Invalid input!")
  90.            
  91.             expect(() => lottery.secondChance("invalid", [1, 2, 3, 4, 5, 6,7,7.6])).to.throw("Invalid input!");
  92.             expect(() => lottery.secondChance("invalid", [1, 2, 3, 4, 5, 6,7,7.6])).to.throw("Invalid input!");
  93.             expect(() => lottery.secondChance("invalid", [1, 2, 3, 4, 5, 6,])).to.throw("Invalid input!");
  94.  
  95.             expect(() => lottery.secondChance("invalid", [1, 2, 3, 4, 5, 6,7,7.6])).to.throw("Invalid input!");
  96.             expect(() => lottery.secondChance(123.7, "invalid")).to.throw("Invalid input!");
  97.  
  98.         })
  99.         it("test valid inputs",()=>{
  100. expect(lottery.secondChance(244,[390, 244, 123])).to.equal("You win our second chance prize!")
  101. expect(lottery.secondChance(100,[456, 789])).to.equal("Sorry, your ticket didn't win!")
  102. expect(lottery.secondChance(100,[100, 789, 100])).to.equal("You win our second chance prize!")
  103. expect(lottery.secondChance(120,[119, 244, 121])).to.equal("Sorry, your ticket didn't win!")
  104.  
  105.  
  106.         })
  107.     })
  108. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement