本文整理汇总了TypeScript中ava.TestContext类的典型用法代码示例。如果您正苦于以下问题:TypeScript TestContext类的具体用法?TypeScript TestContext怎么用?TypeScript TestContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestContext类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: inspectPushRecordCreationRequest
async function inspectPushRecordCreationRequest(t: TestContext, requestStub: SinonStub) {
// For player#create device record is already serialized. Checking serialized structure.
const anyValues = [
"device_type",
"language",
"timezone",
"device_os",
"sdk",
"delivery_platform",
"browser_name",
"browser_version",
"operating_system",
"operating_system_version",
"device_platform",
"device_model",
"identifier",
"notification_types"
];
t.is(requestStub.callCount, 1);
t.not(requestStub.getCall(0), null);
const data: any = requestStub.getCall(0).args[1];
anyValues.forEach((valueKey) => {
t.not(data[valueKey], undefined, `player create: ${valueKey} is undefined! => data: ${JSON.stringify(data)}`);
});
}
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:25,代码来源:onSession.ts
示例2: isDeprecated
return function isDeprecated(t: TestContext) {
// replace original implementation
console.warn = originalWarn
// test for correct log message, if in development
if (process.env.NODE_ENV === "development") {
t.true(spyWarn.called)
t.regex(spyWarn.getCall(0).args[0], /Deprecation warning:/)
}
}
开发者ID:lelandyolo,项目名称:mobx-state-tree,代码行数:9,代码来源:deprecated.ts
示例3: async
fn: async (t: TestContext) => {
const ted = await Tyr.byName.user.findOne({ query: { name: 'ted' } });
if (!ted) {
throw new Error(`No ted found`);
}
const query = `
query getUserById($id: [ID]) {
user(_id: $id) {
status {
name
}
}
}
`;
const result = await Tyr.graphql({
query,
variables: {
id: [ted.$id]
}
});
const expected = {
data: {
user: {
status: {
name: 'Active'
}
}
}
};
t.deepEqual<ExecutionResult>(result, expected);
}
开发者ID:tyranid-org,项目名称:tyranid,代码行数:35,代码来源:enum-collection.ts
示例4: asyncFn
export async function expectAsyncToThrow<R>(
t: TestContext,
asyncFn: () => Promise<R>,
expectedMessageRegex: RegExp,
description = ''
) {
let threw = false;
let message = '';
try {
await asyncFn();
} catch (err) {
threw = true;
message = err.message;
}
t.true(threw, description);
t.regex(message, expectedMessageRegex, description);
}
开发者ID:CrossLead,项目名称:tyranid-gracl,代码行数:17,代码来源:expectAsyncToThrow.ts
示例5: async
fn: async (t: TestContext) => {
const query = `
query userNameQuery {
users {
name
teamIds {
name,
organizationId {
name
}
}
}
}
`;
const result = await Tyr.graphql({ query });
const expected = {
data: {
users: [
{
name: 'ben',
teamIds: [
{
name: 'burritoMakers',
organizationId: {
name: 'Chipotle'
}
},
{
name: 'chipotleMarketing',
organizationId: {
name: 'Chipotle'
}
}
]
},
{
name: 'ted',
teamIds: [
{
name: 'cavaEngineers',
organizationId: {
name: 'Cava'
}
}
]
},
{
name: 'noTeams',
teamIds: []
}
]
}
};
t.deepEqual<ExecutionResult>(result, expected);
}
开发者ID:tyranid-org,项目名称:tyranid,代码行数:58,代码来源:array-populated.ts
示例6: async
fn: async (t: TestContext) => {
const burritoMakers = await Tyr.byName.team.findOne({
query: { name: 'burritoMakers' }
});
if (!burritoMakers) {
throw new Error(`No burrito`);
}
const query = `
query userNameQuery {
users {
name
teamIds(_id: "${burritoMakers.$id}") {
name,
organizationId {
name
}
}
}
}
`;
const result = await Tyr.graphql({ query });
const expected = {
data: {
users: [
{
name: 'ben',
teamIds: [
{
name: 'burritoMakers',
organizationId: {
name: 'Chipotle'
}
}
]
},
{
name: 'ted',
teamIds: []
},
{
name: 'noTeams',
teamIds: []
}
]
}
};
t.deepEqual<ExecutionResult>(result, expected);
}
开发者ID:tyranid-org,项目名称:tyranid,代码行数:52,代码来源:sub-document-parameters.ts
示例7: inspectOnSessionRequest
async function inspectOnSessionRequest(t: TestContext, requestStub: SinonStub) {
// Device record is serialized inside of `updateUserSession`. Checking original DeviceRecord properties.
const anyValues = [
"deliveryPlatform",
"language",
"timezone",
"browserVersion",
"sdkVersion",
"browserName",
"subscriptionState",
"operatingSystem",
"operatingSystemVersion",
"devicePlatform",
"deviceModel",
];
t.is(requestStub.callCount, 1);
t.not(requestStub.getCall(0), null);
const data: any = requestStub.getCall(0).args[1];
anyValues.forEach((valueKey) => {
t.not(data[valueKey], undefined, `on_session: ${valueKey} is undefined! => data: ${JSON.stringify(data)}`);
});
}
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:22,代码来源:onSession.ts
示例8: forBestFormats
async function forBestFormats(t: TestContext, presetName: string): Promise<void> {
let preset = prepPreset(DefaultPresets.find(p => p.name === presetName));
const format = await getBestFormats('https://www.youtube.com/watch?v=oVXg7Grp1W8', preset);
let skipVideo = false;
let skipAudio = false;
if (preset.videoSort) {
t.truthy(format.video);
t.true(format.video.resolution <= preset.maxResolution);
} else {
skipVideo = true;
}
if (preset.audioSort) {
t.truthy(format.audio);
t.true(format.audio.audioBitrate <= preset.maxAudioBitrate);
} else {
skipAudio = true;
}
if (skipAudio && skipVideo) t.fail();
}
开发者ID:JimmyBoh,项目名称:pully,代码行数:22,代码来源:analyzer.spec.ts
示例9: async
fn: async (t: TestContext) => {
const ted = await Tyr.byName.user.findOne({ query: { name: 'ted' } });
if (!ted) {
throw new Error(`No ted`);
}
const query = `
query getUserById($id: [ID]) {
user(_id: $id) {
name
teamIds {
name,
organizationId {
name
}
}
}
}
`;
const result = await Tyr.graphql({
query,
variables: {
id: [ted.$id]
}
});
const expected = {
data: {
user: {
name: 'ted',
teamIds: [
{
name: 'cavaEngineers',
organizationId: {
name: 'Cava'
}
}
]
}
}
};
t.deepEqual<ExecutionResult>(result, expected);
}
开发者ID:tyranid-org,项目名称:tyranid,代码行数:45,代码来源:variables.ts
示例10: async
fn: async (t: TestContext) => {
const orgId = 'organizationId';
const gql = Tyr.graphql;
const result = await gql`
query userNameQuery {
users {
name
${orgId} {
name
}
}
}
`;
const expected = {
data: {
users: [
{
name: 'ben',
organizationId: {
name: 'Chipotle'
}
},
{
name: 'ted',
organizationId: {
name: 'Cava'
}
},
{
name: 'noTeams',
organizationId: {
name: 'Chipotle'
}
}
]
}
};
t.deepEqual<ExecutionResult>(result, expected);
}
开发者ID:tyranid-org,项目名称:tyranid,代码行数:42,代码来源:template-tag.ts
注:本文中的ava.TestContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论