Skip to content

Commit

Permalink
test now pases as guard clause added to 'clearForLanding' function
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhodine-orleans-lindsay committed Jan 31, 2020
1 parent e324a6d commit 10e2839
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions JavaScriptAirport/spec/airportSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,12 @@ describe('Airport', function(){
airport.clearForTakeoff(plane);
}).toThrowError('Takeoff prohibited due to storm conditions');
});

it('does not clear planes for landing when stormy', function(){
spyOn(airport,'isStormy').and.returnValue(true);
expect(function(){
airport.clearForLanding(plane);
}).toThrowError('Landing prohibited due to storm conditions');
});
});
});
5 changes: 4 additions & 1 deletion JavaScriptAirport/src/airport.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ class Airport{
};

clearForLanding(plane) {
if(this.isStormy()){
throw new Error('Landing prohibited due to storm conditions');
};
if(this._runway.length == this.capacity){
throw new Error("Airport Full!");
}
};
this._runway.push(plane);
};

Expand Down

0 comments on commit 10e2839

Please sign in to comment.