本文整理汇总了TypeScript中assert.ifError函数的典型用法代码示例。如果您正苦于以下问题:TypeScript ifError函数的具体用法?TypeScript ifError怎么用?TypeScript ifError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ifError函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: done
request.get({url:domain+'/files/'+this.file.fileId, json:true}, (err, rs, updated:IFile) => {
assert.ifError(err)
assert.equal(rs.statusCode, 200, "Status("+rs.statusCode+"): " + updated)
assert.equal(updated.name, "asdf", "didn't update. maybe it updated the fileId") // data.txt
assert.equal(updated.ext, "txt", "changed extension!")
assert.equal(updated.url, this.file.url)
this.book.files = [updated]
// your responsibility to update the book's version
request.put({url:domain+"/books/"+this.bookId, json:this.book}, (err, rs, body) => {
assert.ifError(err)
assert.equal(rs.statusCode, 200, "Status("+rs.statusCode+"): " + body)
request.get({url:domain+'/books/'+this.bookId+'/files', json:true}, (err, rs, files:IFile[]) => {
assert.ifError(err)
assert.equal(rs.statusCode, 200, "Status("+rs.statusCode+"): " + files)
assert.equal(files.length, 1)
var updated = files[0]
assert.equal(updated.name, "asdf", "didn't update. maybe it updated the fileId") // data.txt
assert.equal(updated.ext, "txt", "changed extension!")
assert.equal(updated.url, this.file.url)
done()
})
})
})
示例2: done
request.get({url: domain + '/genres/'+this.book.genre+'/books', json:true}, (err, rs, books:IBook[]) => {
assert.ifError(err)
assert.equal(rs.statusCode, 200)
assert.equal(books[0].genre, this.book.genre)
assert.ok(books.filter((book:IBook) => book.bookId == this.book.bookId).length)
done()
})
示例3: function
bq.createJob({}, function(err, job, resp) {
assert.ifError(err);
assert.strictEqual(job, fakeJob);
assert.strictEqual(job.metadata, RESPONSE);
assert.strictEqual(resp, RESPONSE);
done();
});
示例4: walkTest
export async function walkTest() {
const dirs: string[] = []
const files: string[] = []
await new fileSystem.FileSystem().walk(".", {
other() {
},
error(e) {
assert.ifError(e)
},
dir(p) {
dirs.push(path.relative(root, p).replace(/\\/g, "/"))
},
file(p) {
files.push(path.relative(root, p).replace(/\\/g, "/"))
},
walkDir() {
}
})
assert.deepStrictEqual(dirs.sort(), ["", "dir1", "dir1/sub1", "dir1/sub2", "dir2"])
assert.deepStrictEqual(files.sort(), ["dir1/sub1/f3.txt", "dir1/sub1/f4.txt", "dir1/sub2/f5.txt", "f1.txt", "f2.txt"])
await new fileSystem.FileSystem().walk("404", {})
}
示例5: done
api.wait(brk, err2 => {
assert.ifError(err2);
const frame = brk.stackFrames[0];
const args = frame.arguments;
const locals = frame.locals;
// TODO: Determine how to remove these casts to any.
ctxMembers = brk.variableTable.slice(brk.variableTable.length - 1)[0]!
.members;
assert.deepStrictEqual(
ctxMembers!.length,
1,
'There should be one member in the context variable value'
);
assert.deepStrictEqual(ctxMembers![0], {name: 'a', value: '10'});
assert.strictEqual(args.length, 0, 'There should be zero arguments');
if (utils.satisfies(process.version, '>=11')) {
assert.strictEqual(locals.length, 3, 'There should be three locals');
assert.deepStrictEqual(locals[0].name, 'this');
assert.deepStrictEqual(locals[1], {name: 'b', value: '1'});
assert.deepStrictEqual(locals[2].name, 'context');
} else {
assert.strictEqual(locals.length, 2, 'There should be two locals');
assert.deepStrictEqual(locals[0], {name: 'b', value: '1'});
assert.deepStrictEqual(locals[1].name, 'context');
}
api.clear(brk, err3 => {
assert.ifError(err3);
done();
});
});
示例6: assert
api.set(bp, err => {
assert.ifError(err);
api.wait(bp, err => {
assert.ifError(err);
const exp = bp.evaluatedExpressions[0];
assert(exp);
const varIndex = exp!.varTableIndex;
assert(varIndex);
const members = bp.variableTable[varIndex!]!.members;
assert(members);
for (const entry of members!) {
if (entry.name === 'title') {
assert(entry.value === undefined);
}
}
api.clear(bp, err => {
assert.ifError(err);
done();
});
});
process.nextTick(() => {
code.foo();
});
});
示例7: function
fs.readFile(this.file.url.replace(localFileMatch[0], ""), function(err, body) {
assert.ifError(err)
var asdf = body.toString()
assert.ok(asdf.match('data'))
done()
})
示例8: function
table.createLoadJob(file, function(err, job) {
assert.ifError(err);
job.on('error', done).on('complete', function() {
done();
});
});