Advertisement
ilianrusev

Untitled

Feb 18th, 2022
25
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe("Tests …", function () {
  2. describe("test hiringEmployee method", function () {
  3. it("successfully", () => {
  4. expect(companyAdministration.hiringEmployee("gosho", "Programmer", 3)).to.be.equal("gosho was successfully hired for the position Programmer.")
  5. expect(companyAdministration.hiringEmployee("gosho", "Programmer", 10)).to.be.equal("gosho was successfully hired for the position Programmer.")
  6. })
  7. it("not successfully", () => {
  8. expect(companyAdministration.hiringEmployee("gosho", "Programmer", 0)).to.be.equal("gosho is not approved for this position.")
  9. })
  10. it("not successfully", () => {
  11. expect(()=>companyAdministration.hiringEmployee("gosho", "Builder", 2)).to.throw("We are not looking for workers for this position.")
  12. })
  13.  
  14. });
  15.  
  16. describe("test calculateSalary method", function () {
  17. it("invalid hours",()=>{
  18. expect(()=>companyAdministration.calculateSalary("3")).to.throw("Invalid hours")
  19. expect(()=>companyAdministration.calculateSalary([])).to.throw("Invalid hours")
  20. expect(()=>companyAdministration.calculateSalary({})).to.throw("Invalid hours")
  21. expect(()=>companyAdministration.calculateSalary(-5)).to.throw("Invalid hours")
  22. })
  23. it("<160",()=>{
  24. expect(companyAdministration.calculateSalary(0)).to.be.equal(0)
  25. expect(companyAdministration.calculateSalary(160)).to.be.equal(2400)
  26. expect(companyAdministration.calculateSalary(10)).to.be.equal(150)
  27. })
  28. it(">160",()=>{
  29. expect(companyAdministration.calculateSalary(170)).to.be.equal(3550)
  30. })
  31. });
  32.  
  33. describe("test firedEmployee method", function () {
  34. it("successfully",()=>{
  35. expect(companyAdministration.firedEmployee(["Petar","Ivan","Gosho"],1)).to.be.equal("Petar, Gosho")
  36. expect(companyAdministration.firedEmployee(["Petar","Ivan","Gosho"],0)).to.be.equal("Ivan, Gosho")
  37. expect(companyAdministration.firedEmployee(["Petar"],0)).to.be.equal("")
  38. expect(companyAdministration.firedEmployee(["Petar","Ivan","Gosho"],2)).to.be.equal("Petar, Ivan")
  39. })
  40. it("Should throw error if the arguments are not the correct type", function() {
  41. expect(() => companyAdministration.firedEmployee(['e1', 'e2', 'e3'], -2)).to.throw("Invalid input")
  42. expect(() => companyAdministration.firedEmployee(['e1', 'e2', 'e3'], 3)).to.throw("Invalid input")
  43. expect(() => companyAdministration.firedEmployee(['e1', 'e2', 'e3'], -1)).to.throw("Invalid input")
  44. expect(() => companyAdministration.firedEmployee(['e1', 'e2', 'e3'], -2.3)).to.throw("Invalid input")
  45. expect(() => companyAdministration.firedEmployee(['e1', 'e2', 'e3'], -1.3)).to.throw("Invalid input")
  46. expect(() => companyAdministration.firedEmployee(['e1', 'e2', 'e3'], '2')).to.throw("Invalid input")
  47. expect(() => companyAdministration.firedEmployee(['e1', 'e2', 'e3'], 2.3)).to.throw("Invalid input")
  48. expect(() => companyAdministration.firedEmployee('e3', 0)).to.throw("Invalid input")
  49. expect(() => companyAdministration.firedEmployee({}, 0)).to.throw("Invalid input")
  50. expect(() => companyAdministration.firedEmployee(1, 0)).to.throw("Invalid input")
  51. expect(() => companyAdministration.firedEmployee(-1, 0)).to.throw("Invalid input")
  52. });
  53.  
  54. });
  55. });
  56.  
Advertisement
RAW Paste Data Copied
Advertisement