diff --git a/spec/test.js b/spec/test.js index de4c18b..eba5b48 100644 --- a/spec/test.js +++ b/spec/test.js @@ -18,70 +18,70 @@ describe('Car', function(){ }); describe('#state', function(){ - xit('should initially be off', function(){ + it('should initially be off', function(){ expect(myCar.state).to.equal("off"); }); }); describe('#previousOwners', function(){ - xit('should exist and initially be empty', function(){ + it('should exist and initially be empty', function(){ expect(myCar.previousOwners).to.exist.to.be.empty; }); }); describe('#currentOwner', function(){ - xit('should initially be manufacturer', function(){ + it('should initially be manufacturer', function(){ expect(myCar.currentOwner).to.equal("Manufacturer"); }); }); describe('#passengers', function(){ - xit('should exist and initially be empty', function(){ + it('should exist and initially be empty', function(){ expect(myCar.passengers).to.exist.to.be.empty; }); }); describe('#sale', function(){ - xit('should move currentOwner to previousOwners array', function(){ + it('should move currentOwner to previousOwners array', function(){ myCar.sale("Charlie"); expect(myCar.previousOwners[0]).to.equal("Manufacturer"); }); - xit('should update currentOwner with the new owner', function(){ + it('should update currentOwner with the new owner', function(){ myCar.sale("Charlie"); expect(myCar.currentOwner).to.equal("Charlie"); }); }); describe('#paint', function(){ - xit('should update the color of myCar', function(){ + it('should update the color of myCar', function(){ myCar.paint("Blue"); expect(myCar.color).to.equal("Blue"); }); }); describe('#start', function(){ - xit('should update the state to on', function(){ + it('should update the state to on', function(){ myCar.start(); expect(myCar.state).to.equal("on"); }); }); describe('#off', function(){ - xit('should update the state to off', function(){ + it('should update the state to off', function(){ myCar.off(); expect(myCar.state).to.equal("off"); }); }); describe('#pickUp', function(){ - xit('should add the passenger to the passengers array', function(){ + it('should add the passenger to the passengers array', function(){ myCar.start(); myCar.pickUp("john"); expect(myCar.passengers[0]).to.equal("john"); }); - xit('should only modify passengers array if car is on', function(){ + it('should only modify passengers array if car is on', function(){ // myCar.off(); myCar.pickUp("john"); expect(myCar.passengers[0]).to.be.empty; @@ -89,14 +89,14 @@ describe('Car', function(){ }); describe('#dropOff', function(){ - xit('should remove passenger from the passengers array', function(){ + it('should remove passenger from the passengers array', function(){ myCar.start(); myCar.pickUp("john"); myCar.dropOff("john"); expect(myCar.passengers).to.be.empty; }); - xit('should leave passenger in the passengers array if car is off', function(){ + it('should leave passenger in the passengers array if car is off', function(){ myCar.start(); myCar.pickUp("john"); myCar.off(); diff --git a/src/car.js b/src/car.js index 5a72227..ab6a3cd 100644 --- a/src/car.js +++ b/src/car.js @@ -1,11 +1,46 @@ -function Car(make, model, year, color){ - +function Car(make, model, year, color, state, previousOwners, currentOwner, passengers){ + this.year = year; + this.state = 'off'; + this.previousOwners = []; + this.currentOwner = "Manufacturer"; + this.passengers = []; + this.newOwner = "Charlie"; + this.color = "Blue"; } Car.prototype.sale = function(newOwner){ + this.previousOwners.push(this.currentOwner); +// i should move currentOwner to previousOwner[] + this.currentOwner = newOwner; +// this function should update currentOwner with the new Owner }; +Car.prototype.start = function(state){ + this.state = "on"; +} + +Car.prototype.off = function(state){ + this.state = "off"; +} + +Car.prototype.pickUp = function(passengers){ + // this.passengers.push("john"); + if (this.state === "on"){ + this.passengers.push(passengers); + } +} + +Car.prototype.dropOff = function(passengers){ + this.passengers.shift(passengers); + if(this.state === "off"){ + this.passengers.push(passengers); + } +} + + + + Car.prototype.paint = function(newColor){ };