All files DinnerMenu.js

100% Statements 9/9
100% Branches 4/4
100% Functions 4/4
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                    8x 8x           2x 2x 8x                       2x 1x     4x      
// Title, Director, Genre, Release year, Rating
// `${this.movie}, a ${this.genre} film directed by ${this.director} was released in ${this.releaseYear}. It received a rating of ${this.rating}.`
 
/**
 * Represents a DinnerMenu
 * @constructor
*/
 
class MenuItem{
    constructor({name, isVegetarian}){
        this.name = name;
        this.isVegetarian = isVegetarian;
    }
}
 
export default class DinnerMenu{
    constructor(dishes){
        this.dishes = [];
        for(let dish of dishes){
            this.dishes.push(new MenuItem(dish));
        }
    }
 
 
    /**
     * Method to get menu items
     * @param isVegetarian to return vegetarian menu. Defaults to false
     * isVegetarian false returns all menu
     * returns Array<MenuItem> - a list of queried menu item
    */
    getMenu({isVegetarian = false} = {}){
        if(!isVegetarian){
            return this.dishes;
        }
        else{
            return this.dishes.filter((dish) => dish.isVegetarian);
        }
    }
}