Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: are standalone tests correct? #24

Open
bartveneman opened this issue Feb 18, 2024 · 0 comments · May be fixed by #25
Open

Question: are standalone tests correct? #24

bartveneman opened this issue Feb 18, 2024 · 0 comments · May be fixed by #25

Comments

@bartveneman
Copy link
Contributor

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.

bartveneman pushed a commit to bartveneman/specificity that referenced this issue May 6, 2024
closes bramus#24

Standalone tests were all using instances of Specificity
instead of the actual standalone functions. Removed all
the `Specificity.` prefixes after which the tests still
run successfully.
@bartveneman bartveneman linked a pull request May 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant