Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function processSource(
source: string,
options: { from?: string } = {},
resolveNamespace?: typeof processNamespace
) {
return process(postcss.parse(source, options), undefined, resolveNamespace);
}
export function expectWarnings(css: string, warnings: Diagnostic[]) {
const source = findTestLocations(css);
const root = safeParse(source.css);
const res = process(root);
res.diagnostics.reports.forEach((report, i) => {
const expectedWarning = warnings[i];
if (expectedWarning.skip) {
return;
}
expect(report.message).to.equal(expectedWarning.message);
expect(report.node.source!.start, 'start').to.eql(source.start);
if (source.word !== null) {
expect(report.options.word).to.equal(source.word);
}
if (expectedWarning.severity) {
expect(
report.type,
(from, content) => {
const meta = process(postcss.parse(content, { from }), diagnostics);
meta.namespace = config.files[from].namespace || meta.namespace;
return meta;
},
fs,
for (const node of ast.nodes) {
if (node.type === 'decl') {
const r = postcss.rule({ selector: node.prop + ':' + node.value });
r.source = node.source;
node.replaceWith(r);
fakes.push(r);
}
}
}
if (ast.raws.after && ast.raws.after.trim()) {
const r = postcss.rule({ selector: ast.raws.after.trim() });
ast.append(r);
fakes.push(r);
}
meta = stylableProcess(ast);
} catch (error) {
return { meta: null, fakes };
}
return {
meta,
fakes
};
}