Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created July 31, 2019 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasongorman/32d5a0162aadffd6e7fbe527219e00f6 to your computer and use it in GitHub Desktop.
Save jasongorman/32d5a0162aadffd6e7fbe527219e00f6 to your computer and use it in GitHub Desktop.
describe('Average rating', function(){
it('calculates the average of ratings in all reviews for a CD', function(){
const cd = new CD(0,0, new Description('Obzen', 'Meshuggah'));
const jason = new Customer('Jason');
jason.addToCollection(cd);
const review1 = new Review(jason, rating=5);
const jane = new Customer('Jane');
jane.addToCollection(cd);
const review2 = new Review(jane, rating=4);
cd.leaveReview(review1);
cd.leaveReview(review2);
assert.equal(cd.averageRating(), 4.5);
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment