當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ava.TestContext類代碼示例

本文整理匯總了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;未經允許,請勿轉載。