本文整理汇总了TypeScript中chai.assert.jsonOf方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.jsonOf方法的具体用法?TypeScript assert.jsonOf怎么用?TypeScript assert.jsonOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chai.assert
的用法示例。
在下文中一共展示了assert.jsonOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: assertCLIResult
function assertCLIResult(result:xm.RunCLIResult, test, info:helper.TestInfo, args):void {
assert.isObject(result, 'result');
assert.strictEqual(result.code, 0, 'result.code');
assert.operator(result.stdout.length, '>=', 0, 'result.stdout.length');
var stdout = trimHeader(result.stdout.toString('utf8'));
var stderr = trimHeader(result.stderr.toString('utf8'));
fs.writeFileSync(info.stdoutFile, stdout, 'utf8');
if (result.stderr.length > 0) {
fs.writeFileSync(info.stderrFile, stderr, 'utf8');
}
if (result.error) {
xm.file.writeJSONSync(info.errorFile, result.error);
}
var stdoutExpect = fs.readFileSync(info.stdoutExpect, 'utf8');
assert.operator(stdoutExpect.length, '>=', 0, 'stdoutExpect.length');
helper.longAssert(stdout, stdoutExpect, 'result.stdout');
if (fs.existsSync(info.stderrExpect)) {
var stderrExpect = fs.readFileSync(info.stderrExpect, 'utf8');
helper.longAssert(stderr, stderrExpect, 'result.stderr');
}
if (fs.existsSync(info.errorExpect)) {
var errorExpect = xm.file.readJSONSync(info.errorExpect);
assert.jsonOf(result.error, errorExpect, 'result.error');
}
}
示例2: assertSelection
export function assertSelection(selection:tsd.Selection, values:any, message:string) {
assert.isObject(selection, message + ': selection');
assert.isObject(values, message + ': values');
assert.instanceOf(selection, tsd.Selection, message + ': selection');
if (values.selection) {
helper.assertDefVersionArray(selection.selection, values.selection, message + ': selection');
}
if (values.definitions) {
helper.assertDefArray(selection.definitions, values.definitions, message + ': definitions');
}
if (values.error) {
assert.jsonOf(values.error, selection.error, message + ': error');
}
}
示例3: fixMeta
}).then((first) => {
assert.ok(first, 'first data');
assert.isObject(first, 'first data');
assert.strictEqual(first.sha, expectedSha, 'first.sha vs expectedSha');
assert.jsonSchema(first, metaFields, 'first meta');
fixMeta(first.meta);
assert.jsonOf(expectedJson, first, 'first vs expectedJson');
var firstBuffer = git.GitUtil.decodeBlobJson(first);
assert.instanceOf(firstBuffer, Buffer, 'buffer');
var firstSha = git.GitUtil.blobShaHex(firstBuffer);
assert.strictEqual(firstSha, expectedSha, 'firstSha vs expected');
// get again, should be cached
return repo.api.getBlob(expectedSha).progress((note:any) => {
notes.push(note);
}).then((second) => {
assert.ok(second, 'second data');
assert.isObject(second, 'second data');
assert.strictEqual(second.sha, expectedSha, 'second.sha vs expectedSha');
var secondBuffer = git.GitUtil.decodeBlobJson(first);
assert.instanceOf(secondBuffer, Buffer, 'buffer');
var secondSha = git.GitUtil.blobShaHex(secondBuffer);
assert.strictEqual(secondSha, expectedSha, 'secondSha vs expected');
helper.assertNotes(notes, [
{
message: /^remote: /,
code: 'http 200'
},
{
message: /^local: /,
code: null
}
], 'second');
});
});