Skip to content

Commit

Permalink
failing test for guard clause if airport is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhodine-orleans-lindsay committed Jan 31, 2020
1 parent fe1b919 commit e2a3d7c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions JavaScriptAirport/spec/airportSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,11 @@ describe('Airport', function(){
airport.clearForLanding(plane);
}).toThrowError("Airport Full!");
});

it('raises an error if empty', function(){
expect(function(){
airport.clearForTakeoff(plane);
}).toThrowError("Airport Empty!");
});
});
});
3 changes: 3 additions & 0 deletions JavaScriptAirport/src/airport.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class Airport{
};

clearForLanding(plane) {
if(this._runway.length == this.capacity){
throw new Error("Airport Full!");
}
this._runway.push(plane);
};
clearForTakeoff(plane){
Expand Down

0 comments on commit e2a3d7c

Please sign in to comment.