本文整理汇总了TypeScript中alsatian.AsyncTest函数的典型用法代码示例。如果您正苦于以下问题:TypeScript AsyncTest函数的具体用法?TypeScript AsyncTest怎么用?TypeScript AsyncTest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AsyncTest函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Expect
@AsyncTest()
@TestCase('')
async getWorksShouldFailWith422WhenPassingAnInvalidArgument(publicKey: string) {
const response = await this.client.getWorksByPublicKey(publicKey)
Expect(response.status).toBe(422)
}
示例2: lookup
@AsyncTest(".lookup(): Should return data for osm addresses")
@Timeout(5000)
public async lookup() {
const results = await lookup({
osm_ids: "R136712" //To determine the osm_id, use a NominatimResponse's 'osm_id' and prefix it with the first letter of its `osm_type`.
})
Expect(results.length >= 1).toBe(true);
const result = results[0];
Expect(typeof(result.place_id)).toBe("string");
Expect(typeof(result.licence)).toBe("string");
Expect(typeof(result.lat)).toBe("string");
Expect(typeof(result.lon)).toBe("string");
Expect(result.display_name).toEqual("Minneapolis, Hennepin County, Minnesota, United States of America");
Expect(result.address).not.toBeNull();
Expect(result.address).toBeDefined();
const address = result.address;
Expect(address.city).toEqual("Minneapolis");
Expect(address.county).toEqual("Hennepin County");
Expect(address.state).toEqual("Minnesota");
Expect(address.country).toEqual("United States of America");
}
示例3: getAddressWithCoords
@AsyncTest(".getAddressWithCoords(): Should return address data with coordinates")
@Timeout(5000)
public async getAddressWithCoords() {
const results = await geocode({
city: "Minneapolis",
state: "MN",
country: "US",
addressdetails: true
});
Expect(results.length >= 1).toBe(true);
const result = results[0];
Expect(typeof(result.place_id)).toBe("string");
Expect(typeof(result.licence)).toBe("string");
Expect(typeof(result.osm_id)).toBe("string");
Expect(typeof(result.lat)).toBe("string");
Expect(typeof(result.lon)).toBe("string");
Expect(result.display_name).toEqual("Minneapolis, Hennepin County, Minnesota, United States of America");
Expect(result.address).not.toBeNull();
Expect(result.address).toBeDefined();
const address = result.address;
Expect(address.city).toEqual("Minneapolis");
Expect(address.county).toEqual("Hennepin County");
Expect(address.state).toEqual("Minnesota");
Expect(address.country).toEqual("United States of America");
}
示例4: asyncNoErrorThrown
@AsyncTest()
public async asyncNoErrorThrown() {
const errorFunction = async () => {
return new Promise(resolve => {
setTimeout(resolve, 400);
});
};
await Expect(errorFunction).not.toThrowAsync();
}
示例5: asyncErrorNotThrown
@AsyncTest()
public async asyncErrorNotThrown() {
const errorFunction = async () => {
return new Promise((resolve, reject) => {
setTimeout(resolve, 400);
});
};
await Expect(errorFunction).toThrowAsync();
}
示例6: getWorksByPublicKeyShouldSucceed
@AsyncTest()
@TestCase(TheRaven.publicKey)
@TestCase(TheMurdersInTheRueMorgue.publicKey)
@TestCase(AStudyInScarlet.publicKey)
async getWorksByPublicKeyShouldSucceed(publicKey: string) {
const response = await this.client.getWorksByPublicKey(publicKey)
Expect(response.status).toBe(200)
Expect(response.ok).toBeTruthy()
}
示例7: asyncErrorUnexpectedly
@AsyncTest()
public async asyncErrorUnexpectedly() {
const errorFunction = async () => {
return new Promise((resolve, reject) => {
setTimeout(() => reject(new Error("error")), 400);
});
};
await Expect(errorFunction).not.toThrowAsync();
}
示例8: asnycExactErrorNotThrown
@AsyncTest()
public async asnycExactErrorNotThrown() {
const errorFunction = async () => {
return new Promise((resolve, reject) => {
setTimeout(() => reject(new Error("error")), 400);
});
};
await Expect(errorFunction).toThrowErrorAsync(TypeError, "specific error");
}
示例9: postWorkShouldSucceedWithEmptyResponse
@AsyncTest()
async postWorkShouldSucceedWithEmptyResponse() {
const claim = createClaim(Key1.privateKey, ClaimType.Work, {
name: 'Name',
})
const postResponse = await this.client.postWork(claim)
const postResponseBody = await postResponse.text()
Expect(postResponseBody).toBe('')
}
示例10: createClaim
@AsyncTest()
async postWorkShouldSucceedWith202() {
const claim = createClaim(Key1.privateKey, ClaimType.Work, {
name: 'Name',
})
const postResponse = await this.client.postWork(claim)
Expect(postResponse.ok).toBeTruthy()
Expect(postResponse.status).toBe(202)
}