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


TypeScript alsatian.AsyncTest函數代碼示例

本文整理匯總了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)
  }
開發者ID:GuilhermeCaruso,項目名稱:node,代碼行數:7,代碼來源:GetWorksByPublicKey.ts

示例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");
    }
開發者ID:nozzlegear,項目名稱:nominatim-browser,代碼行數:26,代碼來源:lookup.ts

示例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");
    }
開發者ID:nozzlegear,項目名稱:nominatim-browser,代碼行數:30,代碼來源:geocode.ts

示例4: asyncNoErrorThrown

  @AsyncTest()
  public async asyncNoErrorThrown() {
    const errorFunction = async () => {
      return new Promise(resolve => {
        setTimeout(resolve, 400);
      });
    };

    await Expect(errorFunction).not.toThrowAsync();
  }
開發者ID:alsatian-test,項目名稱:alsatian,代碼行數:10,代碼來源:to-throw.spec.ts

示例5: asyncErrorNotThrown

  @AsyncTest()
  public async asyncErrorNotThrown() {
    const errorFunction = async () => {
      return new Promise((resolve, reject) => {
        setTimeout(resolve, 400);
      });
    };

    await Expect(errorFunction).toThrowAsync();
  }
開發者ID:alsatian-test,項目名稱:alsatian,代碼行數:10,代碼來源:to-throw.spec.ts

示例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()
  }
開發者ID:GuilhermeCaruso,項目名稱:node,代碼行數:10,代碼來源:GetWorksByPublicKey.ts

示例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();
  }
開發者ID:alsatian-test,項目名稱:alsatian,代碼行數:10,代碼來源:to-throw.spec.ts

示例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");
  }
開發者ID:alsatian-test,項目名稱:alsatian,代碼行數:10,代碼來源:to-throw.spec.ts

示例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('')
  }
開發者ID:GuilhermeCaruso,項目名稱:node,代碼行數:11,代碼來源:PostWork.ts

示例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)
  }
開發者ID:GuilhermeCaruso,項目名稱:node,代碼行數:11,代碼來源:PostWork.ts


注:本文中的alsatian.AsyncTest函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。