Remove deprecated helpers and fix release script (#2128)
* Remove deprecated helpers * Use more idiomatic assertions * Fix release script
This commit is contained in:
Vendored
-91
@@ -1,96 +1,5 @@
|
||||
var global = globalThis;
|
||||
|
||||
/**
|
||||
* @deprecated Use "expectTemplate(template)...toCompileTo(output)" instead
|
||||
*/
|
||||
global.shouldCompileTo = function (string, hashOrArray, expected, message) {
|
||||
shouldCompileToWithPartials(string, hashOrArray, false, expected, message);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated Use "expectTemplate(template)...toCompileTo(output)" instead
|
||||
*/
|
||||
global.shouldCompileToWithPartials = function shouldCompileToWithPartials(
|
||||
string,
|
||||
hashOrArray,
|
||||
partials,
|
||||
expected,
|
||||
message // eslint-disable-line no-unused-vars
|
||||
) {
|
||||
var result = compileWithPartials(string, hashOrArray, partials);
|
||||
expect(result).toBe(expected);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated Use "expectTemplate(template)...toCompileTo(output)" instead
|
||||
*/
|
||||
global.compileWithPartials = function (string, hashOrArray, partials) {
|
||||
var template, ary, options;
|
||||
if (hashOrArray && hashOrArray.hash) {
|
||||
ary = [hashOrArray.hash, hashOrArray];
|
||||
delete hashOrArray.hash;
|
||||
} else if (Object.prototype.toString.call(hashOrArray) === '[object Array]') {
|
||||
ary = [];
|
||||
ary.push(hashOrArray[0]); // input
|
||||
ary.push({ helpers: hashOrArray[1], partials: hashOrArray[2] });
|
||||
options =
|
||||
typeof hashOrArray[3] === 'object'
|
||||
? hashOrArray[3]
|
||||
: { compat: hashOrArray[3] };
|
||||
if (hashOrArray[4] != null) {
|
||||
options.data = !!hashOrArray[4];
|
||||
ary[1].data = hashOrArray[4];
|
||||
}
|
||||
} else {
|
||||
ary = [hashOrArray];
|
||||
}
|
||||
|
||||
template = CompilerContext[partials ? 'compileWithPartial' : 'compile'](
|
||||
string,
|
||||
options
|
||||
);
|
||||
return template.apply(this, ary);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated Use vitest's expect API instead
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
global.equals = global.equal = function equals(a, b, msg) {
|
||||
expect(a).toBe(b);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated Use vitest's expect API instead
|
||||
*/
|
||||
global.shouldThrow = function (callback, type, msg) {
|
||||
var failed;
|
||||
try {
|
||||
callback();
|
||||
failed = true;
|
||||
} catch (caught) {
|
||||
if (type && !(caught instanceof type)) {
|
||||
throw new Error('Type failure: ' + caught);
|
||||
}
|
||||
if (
|
||||
msg &&
|
||||
!(msg.test ? msg.test(caught.message) : msg === caught.message)
|
||||
) {
|
||||
throw new Error(
|
||||
'Throw mismatch: Expected ' +
|
||||
caught.message +
|
||||
' to match ' +
|
||||
msg +
|
||||
'\n\n' +
|
||||
caught.stack
|
||||
);
|
||||
}
|
||||
}
|
||||
if (failed) {
|
||||
throw new Error('It failed to throw');
|
||||
}
|
||||
};
|
||||
|
||||
global.expectTemplate = function (templateAsString) {
|
||||
return new HandlebarsTestBench(templateAsString);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user