本文整理匯總了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)
}