本文整理匯總了TypeScript中ava.TestContext.true方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TestContext.true方法的具體用法?TypeScript TestContext.true怎麽用?TypeScript TestContext.true使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ava.TestContext
的用法示例。
在下文中一共展示了TestContext.true方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: isDeprecated
return function isDeprecated(t: TestContext) {
// replace original implementation
console.warn = originalWarn
// test for correct log message, if in development
if (process.env.NODE_ENV === "development") {
t.true(spyWarn.called)
t.regex(spyWarn.getCall(0).args[0], /Deprecation warning:/)
}
}
示例2: forBestFormats
async function forBestFormats(t: TestContext, presetName: string): Promise<void> {
let preset = prepPreset(DefaultPresets.find(p => p.name === presetName));
const format = await getBestFormats('https://www.youtube.com/watch?v=oVXg7Grp1W8', preset);
let skipVideo = false;
let skipAudio = false;
if (preset.videoSort) {
t.truthy(format.video);
t.true(format.video.resolution <= preset.maxResolution);
} else {
skipVideo = true;
}
if (preset.audioSort) {
t.truthy(format.audio);
t.true(format.audio.audioBitrate <= preset.maxAudioBitrate);
} else {
skipAudio = true;
}
if (skipAudio && skipVideo) t.fail();
}
示例3: asyncFn
export async function expectAsyncToThrow<R>(
t: TestContext,
asyncFn: () => Promise<R>,
expectedMessageRegex: RegExp,
description = ''
) {
let threw = false;
let message = '';
try {
await asyncFn();
} catch (err) {
threw = true;
message = err.message;
}
t.true(threw, description);
t.regex(message, expectedMessageRegex, description);
}