Advertisement
Todorov_Stanimir

02. Auto Service

Nov 9th, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe("class AutoService", () => {
  2.     let autoService;
  3.     beforeEach(function () {
  4.         autoService = new AutoService(2);
  5.     });
  6.  
  7.     describe("check constructor of class", function () {
  8.         it("shoud inirialize properties correctly", function () {
  9.             //test 1
  10.             expect(autoService.garageCapacity).to.equal(2);
  11.             //test 2
  12.             expect(autoService.workInProgress).to.be.a('array')
  13.             expect(autoService.backlogWork).to.be.a('array');
  14.             expect(autoService.workInProgress.length).to.equal(0);
  15.             expect(autoService.backlogWork.length).to.equal(0);
  16.         });
  17.     })
  18.  
  19.     describe("check accessor availableSpace", function () {
  20.         it("shoud return how more cars can be store in the garage", function () {
  21.             let result = autoService.availableSpace;
  22.             //test 3
  23.             expect(result).to.equal(2);
  24.         });
  25.     })
  26.  
  27.     describe("check function signUpForReview(clientName, plateNumber, carInfo)", function () {
  28.         // test 4
  29.         it("shoud register the current client in workInProgress if thre is space", function () {
  30.             autoService.signUpForReview('Peter', 'CA1234CA', { 'engine': 'MFRGG23', 'transmission': 'FF4418ZZ', 'doors': 'broken' });
  31.             //test 5
  32.             expect(autoService.workInProgress.length).to.equal(1);
  33.             expect(autoService.workInProgress).to.deep.equal([{ plateNumber: 'CA1234CA', clientName: 'Peter', carInfo: { 'engine': 'MFRGG23', 'transmission': 'FF4418ZZ', 'doors': 'broken' } }])
  34.         });
  35.         // test
  36.         it("shoud register the current client in backlogWork if thre is not space", function () {
  37.             autoService.signUpForReview('Peter', 'CA1234CA', { 'engine': 'MFRGG23', 'transmission': 'FF4418ZZ', 'doors': 'broken' });
  38.             autoService.signUpForReview('Valio', 'CA1235CA', { 'engine': 'MFRGG24', 'transmission': 'FF4418ZZ', 'doors': 'broken' });
  39.             autoService.signUpForReview('Pesho', 'CA1236CA', { 'engine': 'MFRGG25', 'transmission': 'FF4418ZZ', 'doors': 'broken' });
  40.             //test
  41.             expect(autoService.backlogWork.length).to.equal(1);
  42.             expect(autoService.backlogWork).to.deep.equal([{ plateNumber: 'CA1236CA', clientName: 'Pesho', carInfo: { 'engine': 'MFRGG25', 'transmission': 'FF4418ZZ', 'doors': 'broken' } }])
  43.         });
  44.     })
  45.  
  46.     describe("check function carInfo(plateNumber, clienName)", function () {
  47.         // test 8
  48.         it("shoud return Error if clientName or plateNumber did not exist", function () {
  49.             autoService.signUpForReview('Peter', 'CA1234CA', { 'engine': 'MFRGG23', 'transmission': 'FF4418ZZ', 'doors': 'broken' });
  50.             let result = autoService.carInfo('PB9999PB', 'PHILIP');
  51.             //test
  52.             expect(result).to.equal('There is no car with platenumber PB9999PB and owner PHILIP.');
  53.         });
  54.         // test 6, 9
  55.         it("shoud return carInfo if clientName and CarLable exist in workInProgress", function () {
  56.             autoService.signUpForReview('Peter', 'CA1234CA', { 'engine': 'MFRGG23', 'transmission': 'FF4418ZZ', 'doors': 'broken' });
  57.             let result = autoService.carInfo('CA1234CA', 'Peter');
  58.             expect(result).to.deep.equal({ plateNumber: 'CA1234CA', clientName: 'Peter', carInfo: { 'engine': 'MFRGG23', 'transmission': 'FF4418ZZ', 'doors': 'broken' } });
  59.  
  60.         });
  61.         //test 7
  62.         it("shoud return carInfo if clientName and CarLable exist in backlogWork", function () {
  63.             autoService.signUpForReview('Peter', 'CA1234CA', { 'engine': 'MFRGG23', 'transmission': 'FF4418ZZ', 'doors': 'broken' });
  64.             autoService.signUpForReview('Pesho', 'CA1235CA', { 'engine': 'MFRGG24', 'transmission': 'FF4418ZZ', 'doors': 'broken' });
  65.             autoService.signUpForReview('Valio', 'CA1236CA', { 'engine': 'MFRGG25', 'transmission': 'FF4418ZZ', 'doors': 'broken' });
  66.             let result = autoService.carInfo('CA1236CA', 'Valio');
  67.             expect(result).to.deep.equal({ plateNumber: 'CA1236CA', clientName: 'Valio', carInfo: { 'engine': 'MFRGG25', 'transmission': 'FF4418ZZ', 'doors': 'broken' } });
  68.         });
  69.     })
  70.  
  71.     describe("check function repairCar() (plateNumber, clienName)", function () {
  72.         // test 15
  73.         it("shoud return message if there is not car for reparing", function () {
  74.             let result = autoService.repairCar();
  75.             expect(result).to.equal('No clients, we are just chilling...');
  76.         });
  77.         // test 13, 14
  78.         it("shoud return message if there is not car for reparing", function () {
  79.             autoService.signUpForReview('Peter', 'CA1234CA', { 'engine': 'MFRGG23', 'transmission': 'broken', 'doors': 'broken' });
  80.             let result = autoService.repairCar();
  81.             expect(result).to.equal(`Your transmission and doors were repaired.`);
  82.             expect(autoService.workInProgress.length).to.equal(0)
  83.         });
  84.         //test
  85.         it("shoud return message if there is not car for reparing", function () {
  86.             autoService.signUpForReview('Peter', 'CA1234CA', { 'engine': 'MFRGG23', 'transmission': '1234', 'doors': '5665' });
  87.             let result = autoService.repairCar();
  88.             expect(result).to.equal('Your car was fine, nothing was repaired.');
  89.             expect(autoService.workInProgress.length).to.equal(0)
  90.         });
  91.     })
  92.  
  93. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement