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


TypeScript assert.deepEqual方法代碼示例

本文整理匯總了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" },
   });
 });
開發者ID:itchio,項目名稱:itch,代碼行數:15,代碼來源:datetime.spec.ts

示例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);
  });
開發者ID:itchio,項目名稱:itch,代碼行數:50,代碼來源:group-id-by.spec.ts

示例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" },
    ]);
  });
開發者ID:itchio,項目名稱:itch,代碼行數:22,代碼來源:get-by-ids.spec.ts

示例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,
    });
  });
開發者ID:itchio,項目名稱:itch,代碼行數:23,代碼來源:camelify.spec.ts


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