Skip to content

Commit

Permalink
User story 5 completed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhodine-orleans-lindsay committed Jan 31, 2020
1 parent 0cf253d commit 2f97b3c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion JavaScriptAirport/spec/FeatureSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Feature Test', function (){
plane.land(airport);
spyOn(airport, 'isStormy').and.returnValue(true);
expect(function(){
plane.takeoff();
plane.takeoff(airport);
}).toThrowError('Takeoff prohibited due to storm conditions');
expect(airport.planes()).toContain(plane);
});
Expand Down
12 changes: 11 additions & 1 deletion JavaScriptAirport/spec/airportSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Airport', function(){
});

it('sets default capacity', function(){
expect(airport.DEFAULT_CAPACITY).toEqual(20)
expect(airport.capacity).toEqual(airport.DEFAULT_CAPACITY);
});

it('raises an error if full', function(){
Expand All @@ -43,7 +43,17 @@ describe('Airport', function(){
}).toThrowError("Airport Empty!");
});
});

it('checks for storm conditions', function(){
expect(airport.isStormy()).toBeFalsy();
});

describe('under stormy conditions',function(){
it('does not clear planes for takeoff when stormy', function(){
spyOn(airport,'isStormy').and.returnValue(true);
expect(function(){
airport.clearForTakeoff(plane);
}).toThrowError('Takeoff prohibited due to storm conditions');
});
});
});
12 changes: 8 additions & 4 deletions JavaScriptAirport/src/airport.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ class Airport{
}
this._runway.push(plane);
};

clearForTakeoff(plane){
if(this.isStormy()){
throw new Error('Takeoff prohibited due to storm conditions');
};
if(this._runway.length == 0){
throw new Error("Airport Empty!");
}
this._runway.pop(plane);
};
throw new Error("Airport Empty!");
};

this._runway.pop(plane);
}
isStormy(){
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ User story 2 and 3 - User story 2 and 3 complete . I implemented the same method
User story 4 - capacity - had already begun this in user story 3 but refactored code and test to include DEFAULT_CAPACITY to get rid of the magic number.
User story 5 -
User story 5 - User story 5 completed. to pass the test, I created a 'isStormy' function that returned false by default and created a guard clause within the 'clearForTakeoff' function that would through the error when isStormy was true. I also refactored my capacity test to have 'capacity' = 'DEFAULT_CAPACITY'.
Expand Down

0 comments on commit 2f97b3c

Please sign in to comment.