本文整理汇总了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);
});
示例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);
});
示例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, {});
}
}
示例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);
});
示例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);
});
示例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);
});
示例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);
});
示例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);
});
示例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);
});
示例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');
});
});