|
1 | 1 | /* global expect*/ |
2 | 2 |
|
3 | | -describe(`web worker CSS Language tests`, function () { |
| 3 | +describe(`web worker CSS Language tests`, async function () { |
4 | 4 | let worker; |
5 | 5 | let messageFromWorker = null; |
6 | 6 |
|
@@ -73,4 +73,73 @@ describe(`web worker CSS Language tests`, function () { |
73 | 73 | const symbols = output.symbols; |
74 | 74 | expect(symbols).to.deep.equal(['.info', '.alert', '#success']); |
75 | 75 | }); |
| 76 | + |
| 77 | + /** |
| 78 | + * - "compatibleVendorPrefixes": Unnecessary vendor prefixes checker. |
| 79 | + * - "vendorPrefix": Warns on missing vendor prefixes. |
| 80 | + * - "boxModel": Warns if CSS box model is potentially misused. |
| 81 | + * - "universalSelector": Warns against the use of the universal selector (*). |
| 82 | + * - "fontFaceProperties": Ensures necessary properties are included in @font-face declarations. |
| 83 | + * - "hexColorLength": Enforces consistency in hex color definitions. |
| 84 | + * - "argumentsInColorFunction": Validates arguments within color functions. |
| 85 | + * - "unknownProperties": Warns on unrecognized or mistyped CSS properties. |
| 86 | + * - "ieHack": Warns about CSS hacks for older versions of Internet Explorer. |
| 87 | + * - "unknownVendorSpecificProperties": Flags vendor-specific properties that might not be universally recognized. |
| 88 | + * - "propertyIgnoredDueToDisplay": Notifies when CSS properties are ignored due to the `display` setting of an element. |
| 89 | + * - "important": Warns against the excessive use of `!important`. |
| 90 | + * - "float": Advises on the use of `float`, recommending modern layout alternatives. |
| 91 | + * - "idSelector": Advises against using ID selectors for styling. |
| 92 | + */ |
| 93 | + |
| 94 | + it("should validate css zeroUnits", async function () { |
| 95 | + const cssValidationData = await (await fetch("test-files/cssValidationData.json")).json(); |
| 96 | + messageFromWorker = null; |
| 97 | + const text = `.box { width: 0px;}`; |
| 98 | + worker.postMessage({ |
| 99 | + command: `validateCSS`, text, cssMode: "CSS", filePath: "file:///c.css", lintSettings: { |
| 100 | + zeroUnits: "warning" |
| 101 | + } |
| 102 | + }); |
| 103 | + let output = await waitForWorkerMessage(`validateCSS`, 1000); |
| 104 | + const symbols = output.diag; |
| 105 | + expect(symbols).to.deep.equal(cssValidationData["zeroUnits"]); |
| 106 | + }); |
| 107 | + |
| 108 | + it("should validate css duplicateProperties", async function () { |
| 109 | + const cssValidationData = await (await fetch("test-files/cssValidationData.json")).json(); |
| 110 | + messageFromWorker = null; |
| 111 | + const text = `.box { color: red; color: blue; }`; |
| 112 | + worker.postMessage({ |
| 113 | + command: `validateCSS`, text, cssMode: "CSS", filePath: "file:///c.css", lintSettings: { |
| 114 | + duplicateProperties: "warning" |
| 115 | + } |
| 116 | + }); |
| 117 | + let output = await waitForWorkerMessage(`validateCSS`, 1000); |
| 118 | + const symbols = output.diag; |
| 119 | + expect(symbols).to.deep.equal(cssValidationData["duplicateProperties"]); |
| 120 | + }); |
| 121 | + |
| 122 | + it("should validate css importStatement", async function () { |
| 123 | + const cssValidationData = await (await fetch("test-files/cssValidationData.json")).json(); |
| 124 | + messageFromWorker = null; |
| 125 | + const text = `@import "a.css"`; |
| 126 | + worker.postMessage({command: `validateCSS`, text, cssMode: "CSS", filePath: "file:///c.css", lintSettings: { |
| 127 | + importStatement: "warning" |
| 128 | + }}); |
| 129 | + let output = await waitForWorkerMessage(`validateCSS`, 1000); |
| 130 | + const symbols = output.diag; |
| 131 | + expect(symbols).to.deep.equal(cssValidationData["importStatement"]); |
| 132 | + }); |
| 133 | + |
| 134 | + it("should validate css emptyRules", async function () { |
| 135 | + const cssValidationData = await (await fetch("test-files/cssValidationData.json")).json(); |
| 136 | + messageFromWorker = null; |
| 137 | + const text = `.box {}`; |
| 138 | + worker.postMessage({command: `validateCSS`, text, cssMode: "CSS", filePath: "file:///c.css", lintSettings: { |
| 139 | + compatibleVendorPrefixes: "warning" |
| 140 | + }}); |
| 141 | + let output = await waitForWorkerMessage(`validateCSS`, 1000); |
| 142 | + const symbols = output.diag; |
| 143 | + expect(symbols).to.deep.equal(cssValidationData["compatibleVendorPrefixes"]); |
| 144 | + }); |
76 | 145 | }); |
0 commit comments