So I have a big nested list of strings. The big nested list will eventually get bigger. But I don't want the unit tests to change when the big nested list gets bigger.
I'm returning custom errors and jazz. But that's irrelevant to this question. So I'm going to abstract this to a list of fruit.
What I want is to be able to add items to the bigger list without disrupting the unit test. In other words, I want to see if the complete/haystack/superset includes the partial/needle/subset. (so no deepEquals). I've tried a lot of different ways to do this, and I keep coming up short.
mocha spec file
import "chai/register-assert";
import { assert } from "chai";
describe.only("Nested Lists and Objects", () => {
let allFoodList = {
smoothieStuff: ["apples", "bananas", "strawberries", "yogurt", "ice"],
saladStuff: ["apples", "carrots", "spinach", "strawberries"],
saladFruit: ["apples", "strawberries"],
};
let fruitList = {
smoothieStuff: ["apples", "bananas", "strawberries"],
saladStuff: ["apples", "strawberries"],
saladFruit: ["apples", "strawberries"],
};
// None of these work
it("deepNestedInclude", () => {
assert.deepNestedInclude(allFoodList, fruitList);
});
it("deepInclude", () => {
assert.deepInclude(allFoodList, fruitList);
});
it("include", () => {
assert.include(allFoodList, fruitList);
});
it.skip("notInclude", () => {
assert.notInclude(allFoodList, fruitList);
});
it("deepInclude", () => {
assert.deepInclude(allFoodList, fruitList);
});
it.skip("notDeepInclude", () => {
assert.notDeepInclude(allFoodList, fruitList);
});
it("nestedInclude", () => {
assert.nestedInclude(allFoodList, fruitList);
});
it("deepNestedInclude", () => {
assert.deepNestedInclude(allFoodList, fruitList);
});
it("ownInclude", () => {
assert.ownInclude(allFoodList, fruitList);
});
it.skip("notOwnInclude", () => {
assert.notOwnInclude(allFoodList, fruitList);
});
it("deepOwnInclude", () => {
assert.deepOwnInclude(allFoodList, fruitList);
});
it.skip("notDeepOwnInclude", () => {
assert.notDeepOwnInclude(allFoodList, fruitList);
});
it("sameMembers", () => {
assert.sameMembers(allFoodList, fruitList);
});
it("sameDeepMembers", () => {
assert.sameDeepMembers(allFoodList, fruitList);
});
it("includeMembers", () => {
assert.include(allFoodList, fruitList);
});
it("includeDeepMembers", () => {
assert.include(allFoodList, fruitList);
});
});
summary
0 passing (22ms)
4 pending
12 failing
I skipped the 'Not' tests because they would also pass for something that doesn't contain the required items. I also didn't put in anything that said "ordered" because I'm pretty sure that's an extra constraint.