Skip to content

Commit

Permalink
typo + extra complexity test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart Veneman committed Dec 10, 2023
1 parent 37070ca commit d937b4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/selectors/complexity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const fixture = `
[attr],
[attr=value],
:where(#id, .class),
:where(#a #b #c #d #e #f #g #h #i #j #k #l #m #n #o #p #q #r #s #t #u #v #w #x #y #z),
main > :is(h1, h2),
input[type=text]::-webkit-input-placeholder,
::-webkit-scrollbar,
Expand All @@ -36,6 +37,7 @@ Complexity('calculates complexity', () => {
1,
2,
3,
52,
5,
5,
2,
Expand Down Expand Up @@ -72,10 +74,11 @@ Complexity('calculates complexity uniqueness', () => {
'3': 5,
'4': 1,
'5': 2,
'52': 1,
}

assert.is(actual.totalUnique, 5)
assert.is(actual.uniquenessRatio, 5 / 15)
assert.is(actual.totalUnique, 6)
assert.is(actual.uniquenessRatio, 6 / 16)
assert.equal(actual.unique, expected)
})

Expand Down
2 changes: 1 addition & 1 deletion src/selectors/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function isAccessibility(selector) {

/**
* Get the Complexity for the AST of a Selector Node
* @param {import('css-tree').Selector} ast - AST Node for a Selector
* @param {import('css-tree').Selector} selector - AST Node for a Selector
* @return {[number, boolean]} - The numeric complexity of the Selector and whether it's prefixed or not
*/
export function getComplexity(selector) {
Expand Down

0 comments on commit d937b4b

Please sign in to comment.