Add a test for micromark helpers filterByPredicate and filterByTypes to ensure they return the same token lists for "all tokens".

This commit is contained in:
David Anson 2023-08-30 22:34:21 -07:00
parent af91dbfed9
commit e282874fe3

View file

@ -45,3 +45,12 @@ test("filterByTypes", async(t) => {
t.true(token.type.endsWith("Text")); t.true(token.type.endsWith("Text"));
} }
}); });
test("filterByPredicate/filterByTypes", async(t) => {
t.plan(1);
const tokens = await testTokens;
const byPredicate = filterByPredicate(tokens, () => true);
const allTypes = new Set(byPredicate.map(((token) => token.type)));
const byTypes = filterByTypes(tokens, [ ...allTypes.values() ]);
t.deepEqual(byPredicate, byTypes);
});