summaryrefslogtreecommitdiffstats
path: root/devtools/client/shared/components/test/node/components/object-inspector/utils/node-supports-numerical-bucketing.test.js
blob: 51199146e0e71c5b93a3b5de732540f80fec3a6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */

const {
  createNode,
  makeNodesForEntries,
  nodeSupportsNumericalBucketing,
} = require("resource://devtools/client/shared/components/object-inspector/utils/node.js");

const createRootNode = stub =>
  createNode({
    name: "root",
    contents: { value: stub },
  });

const gripArrayStubs = require("resource://devtools/client/shared/components/test/node/stubs/reps/grip-array.js");
const gripMapStubs = require("resource://devtools/client/shared/components/test/node/stubs/reps/grip-map.js");

describe("nodeSupportsNumericalBucketing", () => {
  it("returns true for Arrays", () => {
    expect(
      nodeSupportsNumericalBucketing(
        createRootNode(gripArrayStubs.get("testBasic"))
      )
    ).toBe(true);
  });

  it("returns true for NodeMap", () => {
    expect(
      nodeSupportsNumericalBucketing(
        createRootNode(gripArrayStubs.get("testNamedNodeMap"))
      )
    ).toBe(true);
  });

  it("returns true for NodeList", () => {
    expect(
      nodeSupportsNumericalBucketing(
        createRootNode(gripArrayStubs.get("testNodeList"))
      )
    ).toBe(true);
  });

  it("returns true for DocumentFragment", () => {
    expect(
      nodeSupportsNumericalBucketing(
        createRootNode(gripArrayStubs.get("testDocumentFragment"))
      )
    ).toBe(true);
  });

  it("returns true for <entries> node", () => {
    expect(
      nodeSupportsNumericalBucketing(
        makeNodesForEntries(
          createRootNode(gripMapStubs.get("testSymbolKeyedMap"))
        )
      )
    ).toBe(true);
  });

  it("returns true for buckets node", () => {
    expect(
      nodeSupportsNumericalBucketing(
        makeNodesForEntries(
          createRootNode(gripMapStubs.get("testSymbolKeyedMap"))
        )
      )
    ).toBe(true);
  });
});