diff --git a/lib/nodes/Operator.js b/lib/nodes/Operator.js index 46e9dd4..2fac9af 100644 --- a/lib/nodes/Operator.js +++ b/lib/nodes/Operator.js @@ -12,7 +12,7 @@ const { registerWalker } = require('../walker'); const Node = require('./Node'); -const operators = ['+', '-', '/', '*', '%']; +const operators = ['+', '-', '/', '*', '%', '=', '<=', '>=', '<', '>']; const operRegex = new RegExp(`([/|*}])`); class Operator extends Node { diff --git a/test/fixtures/word.js b/test/fixtures/word.js index 22e40e8..e25f2d4 100644 --- a/test/fixtures/word.js +++ b/test/fixtures/word.js @@ -13,6 +13,9 @@ module.exports = { snapshot: [ 'bold italic 12px \t /3 \'Open Sans\', Arial, "Helvetica Neue", sans-serif', '(min-width: 700px) and (orientation: \\$landscape)', + '(width < 700px)', + '(width <= 700px)', + '(width >= 500px) and (width <= 1200px)', ' \\"word\\" \\s ', '--color', '-webkit-transition', diff --git a/test/snapshots/word.test.js.md b/test/snapshots/word.test.js.md index 9f2bb92..ab07545 100644 --- a/test/snapshots/word.test.js.md +++ b/test/snapshots/word.test.js.md @@ -1354,3 +1354,681 @@ Generated by [AVA](https://avajs.dev). [Symbol(isClean)]: false, }, ] + +## (width < 700px) + +> Snapshot 1 + + '(' + +> Snapshot 2 + + '(width < 700px)' + +> Snapshot 3 + + [ + Punctuation { + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + offset: 0, + }, + input: Input { + css: '(width < 700px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 1, + line: 1, + offset: 0, + }, + }, + type: 'punctuation', + value: '(', + [Symbol(isClean)]: false, + }, + Word { + isColor: false, + isHex: false, + isUrl: false, + isVariable: false, + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + offset: 0, + }, + input: Input { + css: '(width < 700px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 1, + line: 1, + offset: 0, + }, + }, + type: 'word', + value: 'width', + [Symbol(isClean)]: false, + }, + Operator { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 7, + line: 1, + offset: 6, + }, + input: Input { + css: '(width < 700px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 7, + line: 1, + offset: 6, + }, + }, + type: 'operator', + value: '<', + [Symbol(isClean)]: false, + }, + Numeric { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 9, + line: 1, + offset: 8, + }, + input: Input { + css: '(width < 700px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 9, + line: 1, + offset: 8, + }, + }, + type: 'numeric', + unit: 'px', + value: '700', + [Symbol(isClean)]: false, + }, + Punctuation { + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + offset: 0, + }, + input: Input { + css: '(width < 700px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 1, + line: 1, + offset: 0, + }, + }, + type: 'punctuation', + value: ')', + [Symbol(isClean)]: false, + }, + ] + +## (width <= 700px) + +> Snapshot 1 + + '(' + +> Snapshot 2 + + '(width <= 700px)' + +> Snapshot 3 + + [ + Punctuation { + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + offset: 0, + }, + input: Input { + css: '(width <= 700px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 1, + line: 1, + offset: 0, + }, + }, + type: 'punctuation', + value: '(', + [Symbol(isClean)]: false, + }, + Word { + isColor: false, + isHex: false, + isUrl: false, + isVariable: false, + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + offset: 0, + }, + input: Input { + css: '(width <= 700px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 1, + line: 1, + offset: 0, + }, + }, + type: 'word', + value: 'width', + [Symbol(isClean)]: false, + }, + Operator { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 7, + line: 1, + offset: 6, + }, + input: Input { + css: '(width <= 700px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 7, + line: 1, + offset: 6, + }, + }, + type: 'operator', + value: '<=', + [Symbol(isClean)]: false, + }, + Numeric { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 10, + line: 1, + offset: 9, + }, + input: Input { + css: '(width <= 700px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 10, + line: 1, + offset: 9, + }, + }, + type: 'numeric', + unit: 'px', + value: '700', + [Symbol(isClean)]: false, + }, + Punctuation { + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + offset: 0, + }, + input: Input { + css: '(width <= 700px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 1, + line: 1, + offset: 0, + }, + }, + type: 'punctuation', + value: ')', + [Symbol(isClean)]: false, + }, + ] + +## (width >= 500px) and (width <= 1200px) + +> Snapshot 1 + + '(' + +> Snapshot 2 + + '(width >= 500px) and (width <= 1200px)' + +> Snapshot 3 + + [ + Punctuation { + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + offset: 0, + }, + input: Input { + css: '(width >= 500px) and (width <= 1200px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 1, + line: 1, + offset: 0, + }, + }, + type: 'punctuation', + value: '(', + [Symbol(isClean)]: false, + }, + Word { + isColor: false, + isHex: false, + isUrl: false, + isVariable: false, + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + offset: 0, + }, + input: Input { + css: '(width >= 500px) and (width <= 1200px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 1, + line: 1, + offset: 0, + }, + }, + type: 'word', + value: 'width', + [Symbol(isClean)]: false, + }, + Operator { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 7, + line: 1, + offset: 6, + }, + input: Input { + css: '(width >= 500px) and (width <= 1200px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 7, + line: 1, + offset: 6, + }, + }, + type: 'operator', + value: '>=', + [Symbol(isClean)]: false, + }, + Numeric { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 10, + line: 1, + offset: 9, + }, + input: Input { + css: '(width >= 500px) and (width <= 1200px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 10, + line: 1, + offset: 9, + }, + }, + type: 'numeric', + unit: 'px', + value: '500', + [Symbol(isClean)]: false, + }, + Punctuation { + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + offset: 0, + }, + input: Input { + css: '(width >= 500px) and (width <= 1200px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 1, + line: 1, + offset: 0, + }, + }, + type: 'punctuation', + value: ')', + [Symbol(isClean)]: false, + }, + Word { + isColor: false, + isHex: false, + isUrl: false, + isVariable: false, + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 18, + line: 1, + offset: 17, + }, + input: Input { + css: '(width >= 500px) and (width <= 1200px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 18, + line: 1, + offset: 17, + }, + }, + type: 'word', + value: 'and', + [Symbol(isClean)]: false, + }, + Punctuation { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 22, + line: 1, + offset: 21, + }, + input: Input { + css: '(width >= 500px) and (width <= 1200px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 22, + line: 1, + offset: 21, + }, + }, + type: 'punctuation', + value: '(', + [Symbol(isClean)]: false, + }, + Word { + isColor: false, + isHex: false, + isUrl: false, + isVariable: false, + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 1, + line: 1, + offset: 0, + }, + input: Input { + css: '(width >= 500px) and (width <= 1200px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 1, + line: 1, + offset: 0, + }, + }, + type: 'word', + value: 'width', + [Symbol(isClean)]: false, + }, + Operator { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 7, + line: 1, + offset: 6, + }, + input: Input { + css: '(width >= 500px) and (width <= 1200px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 7, + line: 1, + offset: 6, + }, + }, + type: 'operator', + value: '<=', + [Symbol(isClean)]: false, + }, + Numeric { + raws: { + after: '', + before: ' ', + }, + source: { + end: { + column: 10, + line: 1, + offset: 9, + }, + input: Input { + css: '(width >= 500px) and (width <= 1200px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 10, + line: 1, + offset: 9, + }, + }, + type: 'numeric', + unit: 'px', + value: '1200', + [Symbol(isClean)]: false, + }, + Punctuation { + raws: { + after: '', + before: '', + }, + source: { + end: { + column: 22, + line: 1, + offset: 21, + }, + input: Input { + css: '(width >= 500px) and (width <= 1200px)', + hasBOM: false, + id: '', + [Symbol(fromOffset cache)]: [ + 0, + ], + }, + start: { + column: 22, + line: 1, + offset: 21, + }, + }, + type: 'punctuation', + value: ')', + [Symbol(isClean)]: false, + }, + ] diff --git a/test/snapshots/word.test.js.snap b/test/snapshots/word.test.js.snap index 2e2e2e4..a9cbabf 100644 Binary files a/test/snapshots/word.test.js.snap and b/test/snapshots/word.test.js.snap differ