@stylable/core-test-kit
Advanced tools
Comparing version 2.0.6 to 2.0.7
@@ -1,3 +0,3 @@ | ||
import { Diagnostics, FileProcessor, Pojo, postProcessor, processNamespace, replaceValueHook, Stylable, StylableMeta, StylableResolver, StylableResults, StylableTransformer } from '@stylable/core'; | ||
import * as postcss from 'postcss'; | ||
import { Diagnostics, FileProcessor, postProcessor, processNamespace, replaceValueHook, Stylable, StylableMeta, StylableResolver, StylableResults, StylableTransformer } from '@stylable/core'; | ||
import postcss from 'postcss'; | ||
export interface File { | ||
@@ -9,3 +9,3 @@ content: string; | ||
export interface InfraConfig { | ||
files: Pojo<File>; | ||
files: Record<string, File>; | ||
trimWS?: boolean; | ||
@@ -15,3 +15,3 @@ } | ||
entry?: string; | ||
files: Pojo<File>; | ||
files: Record<string, File>; | ||
usedFiles?: string[]; | ||
@@ -18,0 +18,0 @@ trimWS?: boolean; |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@stylable/core"); | ||
var postcss = __importStar(require("postcss")); | ||
var postcss_1 = __importDefault(require("postcss")); | ||
function generateInfra(config, diagnostics) { | ||
@@ -16,3 +12,3 @@ if (diagnostics === void 0) { diagnostics = new core_1.Diagnostics(); } | ||
var fileProcessor = core_1.cachedProcessFile(function (from, content) { | ||
var meta = core_1.process(postcss.parse(content, { from: from }), diagnostics); | ||
var meta = core_1.process(postcss_1.default.parse(content, { from: from }), diagnostics); | ||
meta.namespace = config.files[from].namespace || meta.namespace; | ||
@@ -41,3 +37,3 @@ return meta; | ||
if (options === void 0) { options = {}; } | ||
return core_1.process(postcss.parse(source, options), undefined, resolveNamespace); | ||
return core_1.process(postcss_1.default.parse(source, options), undefined, resolveNamespace); | ||
} | ||
@@ -44,0 +40,0 @@ exports.processSource = processSource; |
@@ -1,4 +0,4 @@ | ||
import * as postcss from 'postcss'; | ||
import postcss from 'postcss'; | ||
export declare function matchRuleAndDeclaration(parent: postcss.Container, selectorIndex: number, selector: string, decl: string, msg?: string): void; | ||
export declare function matchAllRulesAndDeclarations(parent: postcss.Container, all: string[][], msg?: string, offset?: number): void; | ||
//# sourceMappingURL=match-rules.d.ts.map |
@@ -6,7 +6,8 @@ "use strict"; | ||
if (rule.selector !== selector) { | ||
throw new Error((msg ? msg + ' ' : '') + "selector " + selectorIndex); | ||
throw new Error((msg ? msg + ' ' : '') + "selector " + selectorIndex + "\nactual: " + rule.selector + "\nexpected: " + selector); | ||
} | ||
// expect(rule.selector, `${msg ? msg + ' ' : ''}selector ${selectorIndex}`).to.equal(selector); | ||
if (rule.nodes.map(function (x) { return x.toString(); }).join(';') !== decl) { | ||
throw new Error((msg ? msg + ' ' : '') + "selector " + selectorIndex + " first declaration"); | ||
var actualDecl = rule.nodes.map(function (x) { return x.toString(); }).join(';'); | ||
if (actualDecl !== decl) { | ||
throw new Error((msg ? msg + ' ' : '') + "selector " + selectorIndex + " declaration\nactual: " + actualDecl + "\nexpected: " + decl); | ||
} | ||
@@ -13,0 +14,0 @@ } |
{ | ||
"name": "@stylable/core-test-kit", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "Stylable core test-kit", | ||
@@ -14,6 +14,6 @@ "main": "./cjs/index.js", | ||
"dependencies": { | ||
"@stylable/core": "^2.0.6", | ||
"@stylable/core": "^2.0.7", | ||
"chai": "^4.2.0", | ||
"flat": "^4.1.0", | ||
"postcss": "^7.0.14" | ||
"postcss": "^7.0.16" | ||
}, | ||
@@ -35,3 +35,3 @@ "files": [ | ||
"license": "BSD-3-Clause", | ||
"gitHead": "6a142469d537cbd5cfea431097c6c518e425184d" | ||
"gitHead": "73c0150fd5ea27ad86426821b0c30a16f78ae162" | ||
} |
@@ -7,3 +7,2 @@ import { | ||
isAbsolute, | ||
Pojo, | ||
postProcessor, | ||
@@ -19,3 +18,3 @@ process, | ||
} from '@stylable/core'; | ||
import * as postcss from 'postcss'; | ||
import postcss from 'postcss'; | ||
@@ -29,3 +28,3 @@ export interface File { | ||
export interface InfraConfig { | ||
files: Pojo<File>; | ||
files: Record<string, File>; | ||
trimWS?: boolean; | ||
@@ -36,3 +35,3 @@ } | ||
entry?: string; | ||
files: Pojo<File>; | ||
files: Record<string, File>; | ||
usedFiles?: string[]; | ||
@@ -39,0 +38,0 @@ trimWS?: boolean; |
@@ -1,2 +0,2 @@ | ||
import * as postcss from 'postcss'; | ||
import postcss from 'postcss'; | ||
@@ -12,7 +12,16 @@ export function matchRuleAndDeclaration( | ||
if (rule.selector !== selector) { | ||
throw new Error(`${msg ? msg + ' ' : ''}selector ${selectorIndex}`); | ||
throw new Error( | ||
`${msg ? msg + ' ' : ''}selector ${selectorIndex}\nactual: ${ | ||
rule.selector | ||
}\nexpected: ${selector}` | ||
); | ||
} | ||
// expect(rule.selector, `${msg ? msg + ' ' : ''}selector ${selectorIndex}`).to.equal(selector); | ||
if (rule.nodes!.map(x => x.toString()).join(';') !== decl) { | ||
throw new Error(`${msg ? msg + ' ' : ''}selector ${selectorIndex} first declaration`); | ||
const actualDecl = rule.nodes!.map(x => x.toString()).join(';'); | ||
if (actualDecl !== decl) { | ||
throw new Error( | ||
`${ | ||
msg ? msg + ' ' : '' | ||
}selector ${selectorIndex} declaration\nactual: ${actualDecl}\nexpected: ${decl}` | ||
); | ||
} | ||
@@ -19,0 +28,0 @@ } |
@@ -7,5 +7,5 @@ const flatten = require('flat'); | ||
const { flag } = util; | ||
chai.Assertion.addMethod('flatMatch', function(this: any, obj: {}, maxDepth = 5) { | ||
chai.Assertion.addMethod('flatMatch', function(this: any, obj: {}, maxDepth: number = 5) { | ||
expect(flatten(flag(this, 'object'), { maxDepth })).to.contain(flatten(obj)); | ||
}); | ||
} |
import { StylableResults } from '@stylable/core'; | ||
import { expect } from 'chai'; | ||
import * as postcss from 'postcss'; | ||
import postcss from 'postcss'; | ||
@@ -12,3 +12,7 @@ export function mediaQuery(chai: any, util: any) { | ||
if (!actual.meta || !actual.exports) { | ||
throw new Error(`expected Stylable result {meta, exports}, but got: {${Object.keys(actual).join(', ')}}`); | ||
throw new Error( | ||
`expected Stylable result {meta, exports}, but got: {${Object.keys(actual).join( | ||
', ' | ||
)}}` | ||
); | ||
} | ||
@@ -40,6 +44,13 @@ | ||
chai.Assertion.addMethod('styleRules', function(this: any, styleRules: string[] | { [key: number]: string }) { | ||
chai.Assertion.addMethod('styleRules', function( | ||
this: any, | ||
styleRules: string[] | { [key: number]: string } | ||
) { | ||
const actual = flag(this, 'object') as StylableResults; | ||
if (!actual.meta || !actual.exports) { | ||
throw new Error(`expected Stylable result {meta, exports}, but got: {${Object.keys(actual).join(', ')}}`); | ||
throw new Error( | ||
`expected Stylable result {meta, exports}, but got: {${Object.keys(actual).join( | ||
', ' | ||
)}}` | ||
); | ||
} | ||
@@ -67,7 +78,8 @@ | ||
expect(nodes, `rules exist`).to.not.equal(undefined); | ||
expect(nodes && nodes[expectedIndex].toString()).to.equal(styleRules[expectedIndex]); | ||
expect(nodes && nodes[expectedIndex].toString()).to.equal( | ||
styleRules[expectedIndex] | ||
); | ||
} | ||
} | ||
}); | ||
} |
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
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
49616
778
Updated@stylable/core@^2.0.7
Updatedpostcss@^7.0.16