Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const recipeSelection = require('./recipeSelection');
- const assert = require('chai').assert;
- const expect = require('chai').expect;
- describe("Tests recipeSelection functionallity", function () {
- describe("Test isTypeSuitable functionallity", function () {
- it("Validate input", function () {
- expect(() => { recipeSelection.isTypeSuitable("Vegetarian", 2) }).to.throw('Invalid input');
- });
- it("If the dietaryRestriction is 'Vegetarian' and the type is 'Meat'", function () {
- assert.equal(recipeSelection.isTypeSuitable("Meat", "Vegetarian"), "This recipe is not suitable for vegetarians");
- });
- it("If the dietaryRestriction is 'Vegan' and the type is either 'Meat' or 'Dairy'", function () {
- assert.equal(recipeSelection.isTypeSuitable("Meat", "Vegan"), "This recipe is not suitable for vegans");
- assert.equal(recipeSelection.isTypeSuitable("Dairy", "Vegan"), "This recipe is not suitable for vegans");
- });
- it("In any other case if the two params are strings", function () {
- assert.equal(recipeSelection.isTypeSuitable('Meat', 'Person'), "This recipe is suitable for your dietary restriction");
- })
- });
- describe("Test isItAffordable functionallity", function () {
- it("Validate input", function () {
- expect(() => { recipeSelection.isItAffordable('price', 'budget') }).to.throw('Invalid input');
- });
- it("If the remaining budget is less than 0", function () {
- assert.equal(recipeSelection.isItAffordable(10, 5), "You don't have enough budget to afford this recipe");
- });
- it("If the remainin budget is more or equal to 0", function () {
- assert.equal(recipeSelection.isItAffordable(10, 10), "Recipe ingredients bought. You have 0$ left");
- });
- });
- describe("Test getRecipesByCategory functionallity", function () {
- it("Validate input", function () {
- expect(() => { recipeSelection.getRecipesByCategory([{ title: " Spicy Tofu Stir-Fry ", category: " Asian " }, { title: "Spaghetti", category: "Italian" }], 2) }).to.throw('Invalid input');
- expect(() => { recipeSelection.getRecipesByCategory({}, 'Italian') }).to.throw('Invalid input');
- });
- it("Extract the array of titles", function () {
- assert(recipeSelection.getRecipesByCategory([{ title: " Spicy Tofu Stir-Fry ", category: " Asian " }, { title: "Spaghetti", category: "Italian" }, { title: "Pizza", category: "Italian" } ], 'Italian'), ['Spaghetti', 'Pizza']);
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment