All files / src menuItems.js

100% Statements 10/10
100% Branches 0/0
100% Functions 6/6
100% Lines 10/10

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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63  6x 6x               44x 44x                 2x                                                         6x   44x     2x 6x     44x        
function nameToParentItem(name) {
    const key = name.toLowerCase().replace(' ', '_');
    return {
        name,
        image: `images/aac_icons/${key}.png`,
        audio: `/audio/${key}.mp3`
    };
}
 
function nameToChildItem(name, index) {
    const key = name.toLowerCase().replace(' ', '_');
    return {
        name,
        image: `images/aac_icons/${key}.png`,
        audio: `/audio/${key}.mp3`,
        id: index,
        sideImage: `images/food_side_view/${key}_side.png`
    };
}
 
export const menu = [
    {
        name: "Burger",
        children: [
            "Bottom Bun", "Top Bun", "Patty", "Lettuce",
            "Onion", "Tomato", "Cheese", "Ketchup", "Mustard"
        ],
    },
    {
        name: "Sides",
        children: [
            "Fries", "Onion Rings", "Mozzarella Sticks"
        ],
    },
    {
        name: "Drinks",
        children: [
            "Soda",
            "Blue",
            "Green",
            "Yellow",
            "Red",
            "Orange",
            "Purple",
            "Small",
            "Medium",
            "Large"
        ],
    }
].map(category => ({
    parent: nameToParentItem(category.name),
    children: category.children.map((childName, childIndex) => nameToChildItem(childName, childIndex))
}));
 
export const menuMap = Object.fromEntries(
    menu.map(({ parent, children }) => [
        parent.name,
        Object.fromEntries([
            ...children.map(child => [child.name, child])
        ])
    ])
);