Skip to content

Question: are standalone tests correct? #24

@bartveneman

Description

@bartveneman

Noticed this while implementing #23 in test/standalone.js:

describe('Pass a SelectorList into calculate', () => {
        const selectorLists = csstree.findAll(ast, (node) => node.type === 'SelectorList');

        deepEqual(Specificity.calculate(selectorLists[0])[0].toObject(), { a: 1, b: 0, c: 1 });
        deepEqual(Specificity.calculate(selectorLists[0])[1].toObject(), { a: 0, b: 2, c: 0 });
        deepEqual(Specificity.calculate(selectorLists[1])[0].toObject(), { a: 0, b: 0, c: 1 });
    });

Where I think that it should be this instead:

describe('Pass a SelectorList into calculate', () => {
        const selectorLists = csstree.findAll(ast, (node) => node.type === 'SelectorList');

        deepEqual(calculate(selectorLists[0])[0].toObject(), { a: 1, b: 0, c: 1 });
        deepEqual(calculate(selectorLists[0])[1].toObject(), { a: 0, b: 2, c: 0 });
        deepEqual(calculate(selectorLists[1])[0].toObject(), { a: 0, b: 0, c: 1 });
    });

Removing the Specificity. part still makes the tests pass. Happy to create a PR if this is the correct way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions