本文整理汇总了TypeScript中test.assert.deepEqual方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.deepEqual方法的具体用法?TypeScript assert.deepEqual怎么用?TypeScript assert.deepEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test.assert
的用法示例。
在下文中一共展示了assert.deepEqual方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("seconds", () => {
assert.deepEqual(formatDurationAsMessage(38), {
id: "duration.seconds",
values: { x: "38" },
});
assert.deepEqual(formatDurationAsMessage(123), {
id: "duration.minutes",
values: { x: "2" },
});
assert.deepEqual(formatDurationAsMessage(3800), { id: "duration.hour" });
assert.deepEqual(formatDurationAsMessage(3600 * 4 + 120), {
id: "duration.hours",
values: { x: "4" },
});
});
示例2: it
it("groupIdBy", () => {
assert.deepEqual(groupIdBy(null, "gameId"), {});
assert.deepEqual(groupIdBy(undefined, "gameId"), {});
assert.deepEqual(groupIdBy([], "gameId"), {});
assert.deepEqual(groupIdBy({}, "gameId"), {});
const items = [
{ id: 1, gameId: 11 },
{ id: 4, gameId: 44 },
{ id: 7, gameId: 77 },
{ id: 77, gameId: 77 },
];
assert.deepEqual(groupIdBy(items, "gameId"), {
11: [1],
44: [4],
77: [7, 77],
} as any);
assert.deepEqual(
groupIdBy<typeof items[0]>(items, o => String(o.gameId * 10)),
{
110: [1],
440: [4],
770: [7, 77],
} as any
);
assert.deepEqual(groupIdBy(items, "id"), {
1: [1],
4: [4],
7: [7],
77: [77],
} as any);
const itemMap = indexBy(items, "id");
assert.deepEqual(groupIdBy(itemMap, "gameId"), {
11: [1],
44: [4],
77: [7, 77],
} as any);
assert.deepEqual(groupIdBy(itemMap, "id"), {
1: [1],
4: [4],
7: [7],
77: [77],
} as any);
});
示例3: it
it("gets records by IDs, being chill about null values", () => {
const records = {
"12": {
word: "twelve",
},
"34": {
word: "thirty-four",
},
"56": {
word: "fifty-six",
},
};
assert.deepEqual(getByIds(null, []), []);
assert.deepEqual(getByIds(records, null), []);
assert.deepEqual(getByIds(records, []), []);
assert.deepEqual(getByIds(records, ["34"]), [{ word: "thirty-four" }]);
assert.deepEqual(getByIds(records, ["56", "1024", "12"]), [
{ word: "fifty-six" },
{ word: "twelve" },
]);
});
示例4: it
it("camelifyObject", () => {
assert.deepEqual(
camelifyObject({
heed: 12,
the_call: {
display_name: "waffles",
},
alreadyDone: ["dont_touch_me"],
}),
{
heed: 12,
theCall: {
displayName: "waffles",
},
alreadyDone: ["dont_touch_me"],
}
);
const date = new Date();
assert.deepEqual(camelifyObject({ created_at: date }), {
createdAt: date,
});
});