Skip to content

Commit

Permalink
User story 1 complete. Iinitially tried to create the function airpor…
Browse files Browse the repository at this point in the history
…t.land(plane) which seemed to be working until the point where I had to push the plane into the array, so I refactored my tests to to follow the walkthrough more closely and have the land function in the Plane class.
  • Loading branch information
Rhodine-orleans-lindsay committed Jan 31, 2020
1 parent 7d801ab commit fbfb1a3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion JavaScriptAirport/spec/FeatureSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Feature Test', function (){
airport = new Airport();
});
it('allows planes to land at the airport', function(){
airport.land(plane);
plane.land(airport);
expect(airport.planes()).toContain(plane)
});
});
13 changes: 5 additions & 8 deletions JavaScriptAirport/spec/airportSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ describe('Airport', function(){
var plane;
beforeEach(function(){
airport = new Airport();
plane = jasmine.createSpyObj('plane', ['clearForLanding']);
});
it('allows plane to land at airport', function() {
expect(airport.land).not.toBeUndefined()
});
it('planes can land at airport', function(){
airport.land(plane);
expect(plane.clearForLanding).toHaveBeenCalledWith(airport);
plane = jasmine.createSpy('plane',['land']);
});
it('has no planes by default', function(){
expect(airport.planes()).toEqual([]);
});
it('can clear planes for landing', function(){
airport.clearForLanding(plane);
expect(airport.planes()).toEqual([plane]);
});
});
6 changes: 6 additions & 0 deletions JavaScriptAirport/spec/planeSpec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
'use strict'
describe('Plane', function(){
var plane;
var airport
beforeEach(function(){
plane = new Plane();
airport = jasmine.createSpyObj('airport',['clearForLanding']);
});
it('can land at an airport', function(){
plane.land(airport);
expect(airport.clearForLanding).toHaveBeenCalledWith(plane);
});
});
12 changes: 7 additions & 5 deletions JavaScriptAirport/src/airport.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
'use strict'
class Airport{

land(){

};
constructor(){
this._runway = []
}

planes(){
return [];
return this._runway;
};

clearForLanding(plane) {
this._runway.push(plane)
};
};
4 changes: 3 additions & 1 deletion JavaScriptAirport/src/plane.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use strict'
class Plane{

land(airport){
airport.clearForLanding(this)
};
}

0 comments on commit fbfb1a3

Please sign in to comment.