@stylable/core-test-kit
Advanced tools
Comparing version 5.8.0 to 5.9.0
@@ -12,3 +12,3 @@ "use strict"; | ||
const prevNode = node.prev(); | ||
if ((prevNode === null || prevNode === void 0 ? void 0 : prevNode.type) === 'comment') { | ||
if (prevNode?.type === 'comment') { | ||
const foundPrefix = prevNode.text.match(prefixRegex); | ||
@@ -15,0 +15,0 @@ if (foundPrefix) { |
@@ -23,3 +23,3 @@ "use strict"; | ||
const indent = line.match(/^[\s\t]+/); | ||
const indentSize = (indent === null || indent === void 0 ? void 0 : indent[0].length) || 0; | ||
const indentSize = indent?.[0].length || 0; | ||
if (indentSize < min) { | ||
@@ -26,0 +26,0 @@ min = indentSize; |
@@ -11,2 +11,3 @@ export { Diagnostic, expectAnalyzeDiagnostics, expectTransformDiagnostics, findTestLocations, shouldReportNoDiagnostics, diagnosticBankReportToStrings, } from './diagnostics'; | ||
export { MinimalDocument, MinimalElement } from './minimal-dom'; | ||
export { createTempDirectorySync, copyDirectory } from './native-temp-dir'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MinimalElement = exports.MinimalDocument = exports.deindent = exports.testStylableCore = exports.testInlineExpectsErrors = exports.testInlineExpects = exports.collectAst = exports.matchRuleAndDeclaration = exports.matchAllRulesAndDeclarations = exports.matchCSSMatchers = exports.flatMatch = exports.generateStylableEnvironment = exports.processSource = exports.generateStylableRoot = exports.generateStylableResult = exports.generateStylableExports = exports.generateInfra = exports.createTransformer = exports.createProcess = exports.diagnosticBankReportToStrings = exports.shouldReportNoDiagnostics = exports.findTestLocations = exports.expectTransformDiagnostics = exports.expectAnalyzeDiagnostics = void 0; | ||
exports.copyDirectory = exports.createTempDirectorySync = exports.MinimalElement = exports.MinimalDocument = exports.deindent = exports.testStylableCore = exports.testInlineExpectsErrors = exports.testInlineExpects = exports.collectAst = exports.matchRuleAndDeclaration = exports.matchAllRulesAndDeclarations = exports.matchCSSMatchers = exports.flatMatch = exports.generateStylableEnvironment = exports.processSource = exports.generateStylableRoot = exports.generateStylableResult = exports.generateStylableExports = exports.generateInfra = exports.createTransformer = exports.createProcess = exports.diagnosticBankReportToStrings = exports.shouldReportNoDiagnostics = exports.findTestLocations = exports.expectTransformDiagnostics = exports.expectAnalyzeDiagnostics = void 0; | ||
var diagnostics_1 = require("./diagnostics"); | ||
@@ -38,2 +38,5 @@ Object.defineProperty(exports, "expectAnalyzeDiagnostics", { enumerable: true, get: function () { return diagnostics_1.expectAnalyzeDiagnostics; } }); | ||
Object.defineProperty(exports, "MinimalElement", { enumerable: true, get: function () { return minimal_dom_1.MinimalElement; } }); | ||
var native_temp_dir_1 = require("./native-temp-dir"); | ||
Object.defineProperty(exports, "createTempDirectorySync", { enumerable: true, get: function () { return native_temp_dir_1.createTempDirectorySync; } }); | ||
Object.defineProperty(exports, "copyDirectory", { enumerable: true, get: function () { return native_temp_dir_1.copyDirectory; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -49,3 +49,2 @@ "use strict"; | ||
function testInlineExpects(result, expectedTestInput) { | ||
var _a; | ||
// backward compatibility (no diagnostic checks) | ||
@@ -65,3 +64,4 @@ const isDeprecatedInput = isRoot(result); | ||
const rootAst = context.meta.sourceAst; | ||
const expectedTestAmount = expectedTestInput !== null && expectedTestInput !== void 0 ? expectedTestInput : (((_a = rootAst.toString().match(new RegExp(`${testScopesRegex()}`, `gm`))) === null || _a === void 0 ? void 0 : _a.length) || 0); | ||
const expectedTestAmount = expectedTestInput ?? | ||
(rootAst.toString().match(new RegExp(`${testScopesRegex()}`, `gm`))?.length || 0); | ||
const checks = []; | ||
@@ -130,3 +130,3 @@ const errors = []; | ||
function checkTest(context, expectation, targetNode, srcNode) { | ||
const type = (srcNode === null || srcNode === void 0 ? void 0 : srcNode.type) || (targetNode === null || targetNode === void 0 ? void 0 : targetNode.type); | ||
const type = srcNode?.type || targetNode?.type; | ||
switch (type) { | ||
@@ -149,3 +149,2 @@ case `rule`: { | ||
function ruleTest(context, expectation, targetNode, srcNode) { | ||
var _a; | ||
const result = { | ||
@@ -167,4 +166,4 @@ type: `@rule`, | ||
if (ruleIndex) { | ||
if ((targetNode === null || targetNode === void 0 ? void 0 : targetNode.type) !== `rule`) { | ||
result.errors.push(`mixed-in expectation is only supported for CSS Rule, not ${targetNode === null || targetNode === void 0 ? void 0 : targetNode.type}`); | ||
if (targetNode?.type !== `rule`) { | ||
result.errors.push(`mixed-in expectation is only supported for CSS Rule, not ${targetNode?.type}`); | ||
return result; | ||
@@ -182,3 +181,3 @@ } | ||
// test by target node type | ||
const nodeType = testNode === null || testNode === void 0 ? void 0 : testNode.type; | ||
const nodeType = testNode?.type; | ||
if (nodeType === `rule`) { | ||
@@ -188,3 +187,3 @@ const expectedDeclarations = []; | ||
const declarationCheck = declsInput ? `full` : `none`; | ||
if (declsInput && ((_a = declsInput[1]) === null || _a === void 0 ? void 0 : _a.includes(`:`))) { | ||
if (declsInput && declsInput[1]?.includes(`:`)) { | ||
for (const decl of declsInput[1].split(`;`)) { | ||
@@ -291,3 +290,2 @@ if (decl.trim() !== ``) { | ||
function transformTest(context, expectation, targetNode, srcNode) { | ||
var _a, _b, _c, _d; | ||
// check node is removed in transformation | ||
@@ -300,4 +298,4 @@ const matchResult = expectation.match(/-remove(?<label>\([^)]*\))?/); | ||
const isRemoved = !targetNode || | ||
((_a = targetNode.source) === null || _a === void 0 ? void 0 : _a.start) !== ((_b = srcNode.source) === null || _b === void 0 ? void 0 : _b.start) || | ||
((_c = targetNode.source) === null || _c === void 0 ? void 0 : _c.end) !== ((_d = srcNode.source) === null || _d === void 0 ? void 0 : _d.end); | ||
targetNode.source?.start !== srcNode.source?.start || | ||
targetNode.source?.end !== srcNode.source?.end; | ||
return { | ||
@@ -314,3 +312,2 @@ type: `@transform`, | ||
function diagnosticTest(type, { meta }, expectation, _targetNode, srcNode) { | ||
var _a, _b; | ||
const result = { | ||
@@ -329,5 +326,5 @@ type: `@${type}`, | ||
label = label ? label + `: ` : ``; | ||
severity = (severity === null || severity === void 0 ? void 0 : severity.trim()) || ``; | ||
message = (message === null || message === void 0 ? void 0 : message.trim()) || ``; | ||
word = (word === null || word === void 0 ? void 0 : word.trim()) || ``; | ||
severity = severity?.trim() || ``; | ||
message = message?.trim() || ``; | ||
word = word?.trim() || ``; | ||
if (!message) { | ||
@@ -343,4 +340,4 @@ result.errors.push(exports.testInlineExpectsErrors.diagnosticsMalformed(type, expectation, label)); | ||
location: { | ||
start: (_a = srcNode.source) === null || _a === void 0 ? void 0 : _a.start, | ||
end: (_b = srcNode.source) === null || _b === void 0 ? void 0 : _b.end, | ||
start: srcNode.source?.start, | ||
end: srcNode.source?.end, | ||
word, | ||
@@ -371,5 +368,4 @@ css: ``, | ||
meta.targetAst.walkComments((outputComment) => { | ||
var _a, _b, _c, _d, _e, _f; | ||
if (((_b = (_a = outputComment.source) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.offset) === ((_c = source === null || source === void 0 ? void 0 : source.start) === null || _c === void 0 ? void 0 : _c.offset) && | ||
((_e = (_d = outputComment.source) === null || _d === void 0 ? void 0 : _d.end) === null || _e === void 0 ? void 0 : _e.offset) === ((_f = source === null || source === void 0 ? void 0 : source.end) === null || _f === void 0 ? void 0 : _f.offset)) { | ||
if (outputComment.source?.start?.offset === source?.start?.offset && | ||
outputComment.source?.end?.offset === source?.end?.offset) { | ||
match = outputComment; | ||
@@ -383,6 +379,5 @@ return false; | ||
function isRemovedFromTarget(target, source) { | ||
var _a, _b, _c, _d; | ||
return (!target || | ||
((_a = target.source) === null || _a === void 0 ? void 0 : _a.start) !== ((_b = source.source) === null || _b === void 0 ? void 0 : _b.start) || | ||
((_c = target.source) === null || _c === void 0 ? void 0 : _c.end) !== ((_d = source.source) === null || _d === void 0 ? void 0 : _d.end)); | ||
target.source?.start !== source.source?.start || | ||
target.source?.end !== source.source?.end); | ||
} | ||
@@ -393,3 +388,3 @@ function getNextMixinRule(originRule, count) { | ||
current = current.next(); | ||
if ((current === null || current === void 0 ? void 0 : current.type) !== `comment`) { | ||
if (current?.type !== `comment`) { | ||
count--; | ||
@@ -396,0 +391,0 @@ } |
@@ -86,4 +86,3 @@ "use strict"; | ||
remove() { | ||
var _a; | ||
(_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this); | ||
this.parentElement?.removeChild(this); | ||
} | ||
@@ -90,0 +89,0 @@ querySelector(_selector) { |
@@ -16,5 +16,4 @@ "use strict"; | ||
function testStylableCore(input, options = {}) { | ||
var _a; | ||
// infra | ||
const fs = ((_a = options.stylableConfig) === null || _a === void 0 ? void 0 : _a.filesystem) || | ||
const fs = options.stylableConfig?.filesystem || | ||
(0, memory_1.createMemoryFs)(typeof input === `string` ? { '/entry.st.css': input } : input); | ||
@@ -21,0 +20,0 @@ const stylable = new core_1.Stylable({ |
{ | ||
"name": "@stylable/core-test-kit", | ||
"version": "5.8.0", | ||
"version": "5.9.0", | ||
"description": "Stylable core test-kit", | ||
@@ -10,4 +10,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@file-services/memory": "^7.2.4", | ||
"@stylable/core": "^5.8.0", | ||
"@file-services/memory": "^7.2.5", | ||
"@stylable/core": "^5.9.0", | ||
"chai": "^4.3.7", | ||
@@ -14,0 +14,0 @@ "flat": "^5.0.2", |
@@ -31,1 +31,2 @@ export { | ||
export { MinimalDocument, MinimalElement } from './minimal-dom'; | ||
export { createTempDirectorySync, copyDirectory } from './native-temp-dir'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174134
63
2854
3
Updated@file-services/memory@^7.2.5
Updated@stylable/core@^5.9.0