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 assertSmaller(inputCSS: string, result: CascadeTestResult, assertions?: DeltaAssertions): Promise {
let testedMarkup = result.testedTemplates[0].testedMarkups[0];
let inputHtml = testedMarkup.originalBody;
let optimizedHtml = Promise.resolve({css: testedMarkup.optimizedBody});
const optimizedCss = Promise.resolve({css: result.optimization.output.content.toString()});
let templatePromise = cssSize.numeric(inputHtml, {}, () => optimizedHtml);
let cssPromise = cssSize.numeric(inputCSS, {}, () => optimizedCss);
return Promise.all([cssPromise, templatePromise]).then(([cssDelta, templateDelta]) => {
assertDelta("uncompressed", cssDelta, templateDelta, assertions);
assertDelta("gzip", cssDelta, templateDelta, assertions);
assertDelta("brotli", cssDelta, templateDelta, assertions);
});
}
export function assertSmaller(inputCSS: string, result: CascadeTestResult, assertions?: DeltaAssertions): Promise {
let testedMarkup = result.testedTemplates[0].testedMarkups[0];
let inputHtml = testedMarkup.originalBody;
let optimizedHtml = Promise.resolve({css: testedMarkup.optimizedBody});
const optimizedCss = Promise.resolve({css: result.optimization.output.content.toString()});
let templatePromise = cssSize.numeric(inputHtml, {}, () => optimizedHtml);
let cssPromise = cssSize.numeric(inputCSS, {}, () => optimizedCss);
return Promise.all([cssPromise, templatePromise]).then(([cssDelta, templateDelta]) => {
assertDelta("uncompressed", cssDelta, templateDelta, assertions);
assertDelta("gzip", cssDelta, templateDelta, assertions);
assertDelta("brotli", cssDelta, templateDelta, assertions);
});
}