本文整理汇总了TypeScript中assert.rejects函数的典型用法代码示例。如果您正苦于以下问题:TypeScript rejects函数的具体用法?TypeScript rejects怎么用?TypeScript rejects使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rejects函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('abort undispatched request', async () => {
const [serverTransports, clientTransports] = createMessageTransports()
const b1 = createBarrier()
const b2 = createBarrier()
const server = createConnection(serverTransports)
server.onRequest('block', async () => {
b2.done()
await b1.wait
})
server.onRequest('undispatched', () => {
throw new Error('handler should not be called')
})
server.listen()
const client = createConnection(clientTransports)
client.listen()
client.sendRequest('block').catch(null)
await b2.wait
const abortController = new AbortController()
const result = client.sendRequest('undispatched', ['foo'], abortController.signal)
abortController.abort()
b1.done()
await assert.rejects(result, (err: AbortError) => err.name === 'AbortError')
})
开发者ID:JoYiRis,项目名称:sourcegraph,代码行数:25,代码来源:connection.test.ts
示例2: it
it('should throw a error if file path is external', async () => {
const workspaceHandler = new WorkspaceHandler(
repoDir,
workspaceDir,
// @ts-ignore
null,
new ConsoleLoggerFactory()
);
const repoUri = 'github.com/microsoft/typescript-node-starter';
await prepareProject(path.join(repoDir, repoUri));
const externalFile = 'node_modules/abbrev/abbrev.js';
const request: LspRequest = {
method: 'textDocument/hover',
params: {
position: {
line: 8,
character: 23,
},
textDocument: {
uri: `git://${repoUri}/blob/master/${externalFile}`,
},
},
};
assert.rejects(
workspaceHandler.handleRequest(request),
new Error('invalid file path in requests.')
);
});
开发者ID:elastic,项目名称:kibana,代码行数:28,代码来源:workspace_handler.ts
示例3: it
it('can not clone a repo by ssh without a key', async () => {
const repo = RepositoryUtils.buildRepository(
'[email protected]:elastic/TypeScript-Node-Starter.git'
);
await assert.rejects(service.clone(repo));
// @ts-ignore
}).timeout(60000);
开发者ID:elastic,项目名称:kibana,代码行数:7,代码来源:repository_service.ts
示例4: async
async () => {
const oauth2client =
new googleapis.auth.OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
oauth2client.credentials = {refresh_token: 'abc'};
await assert.rejects(
oauth2client.revokeCredentials(),
/Error: No access token to revoke./);
assert.deepEqual(oauth2client.credentials, {});
});
开发者ID:sheerun,项目名称:google-api-nodejs-client,代码行数:9,代码来源:test.auth.ts
示例5: it
it("throws errors (asynchronous)", async () => {
const createStream = async function*() {
yield [0x90, ...encode(null)]; // fixarray size=0 + nil
};
await assert.rejects(async () => {
await decodeAsync(createStream());
}, RangeError);
});
开发者ID:msgpack,项目名称:msgpack-javascript,代码行数:9,代码来源:edge-cases.test.ts
示例6: getStatTest
export async function getStatTest() {
assert.strictEqual((await new fileSystem.FileSystem().getStat("dir1")).isDirectory(), true)
assert.strictEqual((await new fileSystem.FileSystem().getStat("f1.txt")).isFile(), true)
assert.strictEqual((await new fileSystem.FileSystem().getStat("dir1", false)).isDirectory(), true)
assert.strictEqual((await new fileSystem.FileSystem().getStat("f1.txt", false)).isFile(), true)
await assert.rejects(async () => { await new fileSystem.FileSystem().getStat("404") })
}
开发者ID:tpack,项目名称:utilskit,代码行数:9,代码来源:fileSystem.test.ts
示例7: copyFileTest
export async function copyFileTest() {
assert.strictEqual(await new fileSystem.FileSystem().copyFile("f1.txt", "foo/copyf1.txt"), true)
assert.strictEqual(fs.readFileSync("foo/copyf1.txt", "utf-8"), "f1.txt")
fs.writeFileSync("foo/copyf1.txt", "f1.txt_1")
assert.strictEqual(await new fileSystem.FileSystem().copyFile("f1.txt", "foo/copyf1.txt", false), false)
assert.strictEqual(fs.readFileSync("foo/copyf1.txt", "utf-8"), "f1.txt_1")
await assert.rejects(new fileSystem.FileSystem().copyFile("404.txt", "goo/copyf1.txt", true))
}
开发者ID:tpack,项目名称:utilskit,代码行数:10,代码来源:fileSystem.test.ts
示例8: writeFileTest
export async function writeFileTest() {
assert.strictEqual(await new fileSystem.FileSystem().writeFile("foo/goo.txt", "A"), true)
assert.strictEqual(fs.readFileSync("foo/goo.txt", "utf-8"), "A")
assert.strictEqual(await new fileSystem.FileSystem().writeFile("foo/goo.txt", "你好"), true)
assert.strictEqual(fs.readFileSync("foo/goo.txt", "utf-8"), "你好")
assert.strictEqual(await new fileSystem.FileSystem().writeFile("foo/goo.txt", "你不好", false), false)
assert.strictEqual(fs.readFileSync("foo/goo.txt", "utf-8"), "你好")
await assert.rejects(new fileSystem.FileSystem().writeFile("dir1", "你好", true))
}
开发者ID:tpack,项目名称:utilskit,代码行数:12,代码来源:fileSystem.test.ts
注:本文中的assert.rejects函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论