Skip to content

Commit

Permalink
Update films.spec.js
Browse files Browse the repository at this point in the history
  • Loading branch information
vicenlu authored Sep 26, 2023
1 parent 07f2bbb commit 8d8a815
Showing 1 changed file with 1 addition and 74 deletions.
75 changes: 1 addition & 74 deletions tests/films.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,81 +291,8 @@ describe('Function "orderByYear"', () => {
});

// Exercise 6
describe('Function "moviesAverageByCategory"', () => {
it('should be declared', () => {
expect(typeof moviesAverageByCategory).toBe('function');
});

it('should return a number', () => {
expect(typeof moviesAverageByCategory(movies, 'Drama')).toBe('number');
});

it('should be different from NaN', () => {
expect(moviesAverageByCategory(movies, 'Drama')).not.toBeNaN();
});

it(' should return the average score of 2 movies with score 7 each, without decimals!', () => {
expect(moviesAverageByCategory([
{
score: 7,
genre: ['Drama'],
},
{
score: 7,
genre: ['Drama'],
}
],
'Drama')).toBe(7);
});

it('should be rounded to 2 decimals places', () => {
expect(moviesAverageByCategory([
{
score: 7.75,
genre: ['Drama'],
},
{
score: 6,
genre: ['Drama'],
}
],
'Drama')).toBe(6.88);
});

it('should not take into consideration films of other category', () => {
expect(moviesAverageByCategory([
{
score: 5,
genre: ['Drama'],
},
{
score: 10,
genre: ['Action'],
},
{
score: 10,
genre: ['Action'],
}
],
'Action')).toBe(10);
});

// YOUR CODE HERE. Test moviesAverageByCategory()

it('should return average even if one of the movies does not have score', () => {
expect(moviesAverageByCategory([
{
score: 5,
genre: ['Action'],
},
{
score: '',
genre: ['Action'],
}
],
'Action')).toBe(5);
});

});

// Exercise 7
describe('Function "hoursToMinutes"', () => {
Expand Down

0 comments on commit 8d8a815

Please sign in to comment.