当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript assert.jsonSchema方法代码示例

本文整理汇总了TypeScript中chai.assert.jsonSchema方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.jsonSchema方法的具体用法?TypeScript assert.jsonSchema怎么用?TypeScript assert.jsonSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chai.assert的用法示例。


在下文中一共展示了assert.jsonSchema方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it("should fetch invoices", async () => {
    if (!schema) {
      throw new Error("Invoice schema not generated");
    }

    const { state: { token } } = store;

    const resp = await Billing.Invoices.getCollection({
      token,
      query: {},
      settings: {
        url: process.env.API_URL || "",
        project: process.env.PROJECT_ID || "",
      },
    });

    if (!resp.ok) {
      throw new Error(resp.error.title);
    }

    if (!resp.value.data) {
      throw new Error("data field is empty");
    }

    assert.isTrue(resp.ok);
    assert.jsonSchema(resp.value, schema);
  });
开发者ID:cycleplatform,项目名称:api-client-nodejs,代码行数:27,代码来源:fetchInvoices.test.ts

示例2: it

    it("should fetch a token", async () => {
      const totpToken = totp({
        secret: process.env.TOTP_SECRET,
        encoding: "base32",
        // tslint:disable-next-line:no-bitwise
        time: (Date.now() / 1000) | 0, // specified in seconds
      });

      const resp = await Auth.passwordGrant(
        {
          email: process.env.EMAIL || "",
          password: process.env.PASSWORD || "",
          client_id: process.env.CLIENT_ID,
          client_secret: process.env.CLIENT_SECRET,
          totp_passcode: totpToken,
        },
        {
          url: process.env.AUTH_URL,
          noVersion: true,
          useHttp: store.state.settings.useHttp,
        },
      );

      if (!resp.ok) {
        throw new Error(resp.error.title);
      }

      assert.isTrue(resp.ok);
      assert.jsonSchema(resp.value, schema);

      // use this token for subsequent requests
      store.updateToken(resp.value);
    });
开发者ID:cycleplatform,项目名称:api-client-nodejs,代码行数:33,代码来源:passwordGrant.test.ts

示例3: assertConfig

	export function assertConfig(config:tsd.Config, values:any, message:string) {
		assert.ok(config, message + ': config');
		assert.ok(values, message + ': values');
		assert.instanceOf(config, tsd.Config, message + ': config');

		helper.propStrictEqual(config, values, 'path', message);
		helper.propStrictEqual(config, values, 'version', message);
		helper.propStrictEqual(config, values, 'repo', message);
		helper.propStrictEqual(config, values, 'ref', message);

		if (values.repoOwner) {
			helper.propStrictEqual(config, values, 'repoOwner', message);
		}
		if (values.repoProject) {
			helper.propStrictEqual(config, values, 'repoProject', message);
		}

		var json = config.toJSON();
		assert.jsonSchema(json, helper.getConfigSchema(), message + ': schema');
		helper.propStrictEqual(json, values, 'path', message + ': json');
		helper.propStrictEqual(json, values, 'version', message + ': json');
		helper.propStrictEqual(json, values, 'repo', message + ': json');
		helper.propStrictEqual(json, values, 'ref', message + ': json');
		if (values.installed) {
			assert.like(json.installed, values.installed);
		}
		else {
			assert.like(json.installed, {});
		}
	}
开发者ID:AbraaoAlves,项目名称:tsd,代码行数:30,代码来源:DefConfig.ts

示例4: it

  it("should update account name and revert it back", async () => {
    const { token } = store.state;
    const originalResp = await Account.getSingle({
      token,
      settings: { url: process.env.API_URL },
    });

    if (!originalResp.ok) {
      throw new Error(originalResp.error.title);
    }

    if (!originalResp.value.data) {
      throw new Error("data field is null");
    }

    const value = {
      name: {
        first: "Mike",
        last: "Wizowsky",
      },
    };

    const resp = await Account.update({
      token,
      value,

      query: {},
      settings: { url: process.env.API_URL },
    });

    if (!resp.ok) {
      throw new Error(resp.error.title);
    }

    assert.isTrue(resp.ok);
    assert.jsonSchema(resp.value.data, schema);
    assert.deepPropertyVal(resp.value.data, "name", {
      first: "Mike",
      last: "Wizowsky",
    });

    const revertUpdate = { name: originalResp.value.data.name };
    const revertResp = await Account.update({
      token,
      query: {},
      value: revertUpdate,
      settings: { url: process.env.API_URL },
    });

    if (!revertResp.ok) {
      throw new Error(revertResp.error.title);
    }

    assert.deepPropertyVal(revertResp.value.data, "name", revertUpdate.name);
  });
开发者ID:cycleplatform,项目名称:api-client-nodejs,代码行数:55,代码来源:updateAccount.test.ts

示例5: it

  it("should fetch project capabilities", async () => {
    if (!schema) {
      throw new Error("Capabilities schema not generated");
    }

    const resp = await Projects.getCapabilities({
      settings: store.state.settings,
    });

    if (!resp.ok) {
      throw new Error(resp.error.title);
    }

    assert.isTrue(resp.ok);
    assert.jsonSchema(resp.value, schema);
  });
开发者ID:cycleplatform,项目名称:api-client-nodejs,代码行数:16,代码来源:fetchProjectCapabilities.test.ts

示例6: it

  it("should fetch user account", async () => {
    if (!schema) {
      throw new Error("Account schema not generated");
    }
    const { token } = store.state;

    const resp = await Account.getSingle({
      token,
      query: {},
      settings: { url: process.env.API_URL },
    });

    if (!resp.ok) {
      throw new Error(resp.error.title);
    }

    assert.isTrue(resp.ok);
    assert.jsonSchema(resp.value.data, schema);
  });
开发者ID:cycleplatform,项目名称:api-client-nodejs,代码行数:19,代码来源:fetchAccount.test.ts

示例7: it

  it("should fetch notifications", async () => {
    if (!schema) {
      throw new Error("Notification schema not generated");
    }

    const { state: { token } } = store;

    const resp = await Notifications.getCollection({
      token,
      settings: store.state.settings,
    });

    if (!resp.ok) {
      throw new Error(resp.error.title);
    }

    assert.isTrue(resp.ok);
    assert.jsonSchema(resp.value, schema);
  });
开发者ID:cycleplatform,项目名称:api-client-nodejs,代码行数:19,代码来源:fetchNotifications.test.ts

示例8: it

  it("should fetch provider datacenters", async () => {
    if (!schema) {
      throw new Error("DC schema not generated");
    }

    const { active: { provider } } = store.state;

    const resp = await Infrastructure.Providers.DataCenters.getCollection({
      provider,
      query: {},
      settings: store.state.settings,
    });

    if (!resp.ok) {
      throw new Error(resp.error.title);
    }

    assert.isTrue(resp.ok);
    assert.jsonSchema(resp.value, schema);
  });
开发者ID:cycleplatform,项目名称:api-client-nodejs,代码行数:20,代码来源:fetchProviderDcs.test.ts

示例9: it

  it("should delete the environment we created", async () => {
    const { token } = store.state;
    const resp = await Environments.remove({
      token,
      id: store.state.active.environment,
      query: {},
      settings: store.state.settings,
    });

    if (!resp.ok) {
      throw new Error(resp.error.title);
    }

    if (!resp.value.data) {
      throw new Error("data field is empty");
    }

    assert.isTrue(resp.ok);
    assert.jsonSchema(resp.value.data, schema);
  });
开发者ID:cycleplatform,项目名称:api-client-nodejs,代码行数:20,代码来源:deleteEnvironment.test.ts

示例10:

			}).then((first) => {
				assert.ok(first, 'first data');
				assert.isObject(first, 'first data');
				assert.strictEqual(first.sha, expectedSha, 'first.sha vs expectedSha');

				assert.jsonSchema(first, metaFields, 'first meta');
				fixMeta(first.meta);
				assert.jsonOf(expectedJson, first, 'first vs expectedJson');

				var firstBuffer = git.GitUtil.decodeBlobJson(first);
				assert.instanceOf(firstBuffer, Buffer, 'buffer');

				var firstSha = git.GitUtil.blobShaHex(firstBuffer);
				assert.strictEqual(firstSha, expectedSha, 'firstSha vs expected');

				// get again, should be cached
				return repo.api.getBlob(expectedSha).progress((note:any) => {
					notes.push(note);
				}).then((second) => {
					assert.ok(second, 'second data');
					assert.isObject(second, 'second data');
					assert.strictEqual(second.sha, expectedSha, 'second.sha vs expectedSha');

					var secondBuffer = git.GitUtil.decodeBlobJson(first);
					assert.instanceOf(secondBuffer, Buffer, 'buffer');
					var secondSha = git.GitUtil.blobShaHex(secondBuffer);
					assert.strictEqual(secondSha, expectedSha, 'secondSha vs expected');

					helper.assertNotes(notes, [
						{
							message: /^remote: /,
							code: 'http 200'
						},
						{
							message: /^local: /,
							code: null
						}
					], 'second');
				});
			});
开发者ID:AbraaoAlves,项目名称:tsd,代码行数:40,代码来源:GithubAPI.ts


注:本文中的chai.assert.jsonSchema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。