@stylable/core-test-kit
Advanced tools
Comparing version 3.10.1 to 3.11.0
@@ -0,1 +1,2 @@ | ||
import { Position } from 'postcss'; | ||
import { StylableMeta, StylableResults } from '@stylable/core'; | ||
@@ -11,10 +12,4 @@ import { Config } from './generate-test-util'; | ||
export declare function findTestLocations(css: string): { | ||
start: { | ||
line: number; | ||
column: number; | ||
} | undefined; | ||
end: { | ||
line: number; | ||
column: number; | ||
} | undefined; | ||
start: Position | undefined; | ||
end: Position | undefined; | ||
word: string | null; | ||
@@ -21,0 +16,0 @@ css: string; |
@@ -15,4 +15,4 @@ "use strict"; | ||
let inWord = false; | ||
let start; | ||
let end; | ||
let start = undefined; | ||
let end = undefined; | ||
let word = null; | ||
@@ -27,6 +27,6 @@ for (let i = 0; i < css.length; i++) { | ||
if (!start) { | ||
start = { line, column }; | ||
start = { line, column, offset: i }; | ||
} | ||
else { | ||
end = { line, column }; | ||
end = { line, column, offset: i }; | ||
} | ||
@@ -85,6 +85,6 @@ } | ||
} | ||
diagnostics.reports.forEach((report, i) => { | ||
for (const [i, report] of diagnostics.reports.entries()) { | ||
const expectedWarning = expectedWarnings[i]; | ||
if (!expectedWarning) { | ||
return; | ||
continue; | ||
} | ||
@@ -102,3 +102,3 @@ const path = expectedWarning.file; | ||
} | ||
}); | ||
} | ||
chai_1.expect(expectedWarnings.length, `expected diagnostics: ${JSON.stringify(expectedWarnings.map((d) => d.message), null, 2)}, but received ${JSON.stringify(warningMessages, null, 2)}`).to.equal(diagnostics.reports.length); | ||
@@ -105,0 +105,0 @@ return result; |
import { Diagnostics, FileProcessor, postProcessor, processNamespace, replaceValueHook, Stylable, StylableMeta, StylableResolver, StylableResults, StylableTransformer } from '@stylable/core'; | ||
import postcss from 'postcss'; | ||
import * as postcss from 'postcss'; | ||
export interface File { | ||
@@ -4,0 +4,0 @@ content: string; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
@@ -9,3 +25,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
const path_1 = require("path"); | ||
const postcss_1 = __importDefault(require("postcss")); | ||
const postcss = __importStar(require("postcss")); | ||
function generateInfra(config, diagnostics = new core_1.Diagnostics()) { | ||
@@ -35,3 +51,3 @@ const { fs, requireModule } = core_1.createMinimalFS(config); | ||
function processSource(source, options = {}, resolveNamespace) { | ||
return core_1.process(postcss_1.default.parse(source, options), undefined, resolveNamespace); | ||
return core_1.process(postcss.parse(source, options), undefined, resolveNamespace); | ||
} | ||
@@ -38,0 +54,0 @@ exports.processSource = processSource; |
@@ -1,4 +0,4 @@ | ||
import postcss from 'postcss'; | ||
import * as 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 |
@@ -1,2 +0,3 @@ | ||
export declare function matchCSSMatchers(chai: any, util: any): void; | ||
/// <reference types="chai" /> | ||
export declare function matchCSSMatchers(chai: Chai.ChaiStatic, util: Chai.ChaiUtils): void; | ||
//# sourceMappingURL=match-css.d.ts.map |
@@ -1,3 +0,4 @@ | ||
export declare function mediaQuery(chai: any, util: any): void; | ||
export declare function styleRules(chai: any, util: any): void; | ||
/// <reference types="chai" /> | ||
export declare function mediaQuery(chai: Chai.ChaiStatic, util: Chai.ChaiUtils): void; | ||
export declare function styleRules(chai: Chai.ChaiStatic, util: Chai.ChaiUtils): void; | ||
//# sourceMappingURL=results.d.ts.map |
{ | ||
"name": "@stylable/core-test-kit", | ||
"version": "3.10.1", | ||
"version": "3.11.0", | ||
"description": "Stylable core test-kit", | ||
@@ -13,6 +13,6 @@ "main": "./cjs/index.js", | ||
"dependencies": { | ||
"@stylable/core": "^3.10.1", | ||
"@stylable/core": "^3.11.0", | ||
"chai": "^4.2.0", | ||
"flat": "^5.0.2", | ||
"postcss": "^7.0.32" | ||
"postcss": "^8.0.8" | ||
}, | ||
@@ -19,0 +19,0 @@ "files": [ |
import { expect } from 'chai'; | ||
import deindent from 'deindent'; | ||
import { Position } from 'postcss'; | ||
import { Diagnostics, process, safeParse, StylableMeta, StylableResults } from '@stylable/core'; | ||
@@ -18,5 +19,5 @@ import { Config, generateFromMock } from './generate-test-util'; | ||
let inWord = false; | ||
let start; | ||
let end; | ||
let word = null; | ||
let start: Position | undefined = undefined; | ||
let end: Position | undefined = undefined; | ||
let word: string | null = null; | ||
for (let i = 0; i < css.length; i++) { | ||
@@ -29,5 +30,5 @@ const ch = css.charAt(i); | ||
if (!start) { | ||
start = { line, column }; | ||
start = { line, column, offset: i }; | ||
} else { | ||
end = { line, column }; | ||
end = { line, column, offset: i }; | ||
} | ||
@@ -82,3 +83,11 @@ } else if (ch === '$') { | ||
const locations: any = {}; | ||
const locations: Record< | ||
string, | ||
{ | ||
start?: Position; | ||
end?: Position; | ||
word: string | null; | ||
css: string; | ||
} | ||
> = {}; | ||
for (const path in config.files) { | ||
@@ -100,6 +109,6 @@ const source = findTestLocations(deindent(config.files[path].content).trim()); | ||
diagnostics.reports.forEach((report, i) => { | ||
for (const [i, report] of diagnostics.reports.entries()) { | ||
const expectedWarning = expectedWarnings[i]; | ||
if (!expectedWarning) { | ||
return; | ||
continue; | ||
} | ||
@@ -124,3 +133,3 @@ const path = expectedWarning.file; | ||
} | ||
}); | ||
} | ||
@@ -127,0 +136,0 @@ expect( |
@@ -17,3 +17,3 @@ import { | ||
import { isAbsolute } from 'path'; | ||
import postcss from 'postcss'; | ||
import * as postcss from 'postcss'; | ||
@@ -20,0 +20,0 @@ export interface File { |
@@ -1,2 +0,2 @@ | ||
import postcss from 'postcss'; | ||
import * as postcss from 'postcss'; | ||
@@ -10,3 +10,3 @@ export function matchRuleAndDeclaration( | ||
) { | ||
const rule = parent.nodes![selectorIndex] as postcss.Rule; | ||
const rule = parent.nodes[selectorIndex] as postcss.Rule; | ||
if (rule.selector !== selector) { | ||
@@ -20,3 +20,3 @@ throw new Error( | ||
// expect(rule.selector, `${msg ? msg + ' ' : ''}selector ${selectorIndex}`).to.equal(selector); | ||
const actualDecl = rule.nodes!.map((x) => x.toString()).join(';'); | ||
const actualDecl = rule.nodes.map((x) => x.toString()).join(';'); | ||
if (actualDecl !== decl) { | ||
@@ -23,0 +23,0 @@ throw new Error( |
import { expect } from 'chai'; | ||
export function matchCSSMatchers(chai: any, util: any) { | ||
export function matchCSSMatchers(chai: Chai.ChaiStatic, util: Chai.ChaiUtils) { | ||
const { flag } = util; | ||
chai.Assertion.addMethod('matchCSS', function (this: any, css: string | string[]) { | ||
chai.Assertion.addMethod('matchCSS', function (css: string | string[]) { | ||
let element = flag(this, 'object'); | ||
@@ -7,0 +7,0 @@ if (!Array.isArray(css)) { |
import { StylableResults } from '@stylable/core'; | ||
import { expect } from 'chai'; | ||
import postcss from 'postcss'; | ||
import * as postcss from 'postcss'; | ||
export function mediaQuery(chai: any, util: any) { | ||
export function mediaQuery(chai: Chai.ChaiStatic, util: Chai.ChaiUtils) { | ||
const { flag } = util; | ||
chai.Assertion.addMethod('mediaQuery', function (this: any, index: number) { | ||
chai.Assertion.addMethod('mediaQuery', function (index: number) { | ||
const actual = flag(this, 'object') as StylableResults; | ||
@@ -40,7 +40,6 @@ | ||
export function styleRules(chai: any, util: any) { | ||
export function styleRules(chai: Chai.ChaiStatic, util: Chai.ChaiUtils) { | ||
const { flag } = util; | ||
chai.Assertion.addMethod('styleRules', function ( | ||
this: any, | ||
styleRules: string[] | { [key: number]: string } | ||
@@ -47,0 +46,0 @@ ) { |
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
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
52743
831
Updated@stylable/core@^3.11.0
Updatedpostcss@^8.0.8