Advertisement
bebo231312312321

Untitled

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