15832144755
2022-01-06 7b4c8991dca9cf2a809a95e239d144697d3afb56
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
import createScene from "../../createScene.js";
import { HomeButton } from "../../../Source/Cesium.js";
 
describe(
  "Widgets/HomeButton/HomeButton",
  function () {
    var scene;
    beforeAll(function () {
      scene = createScene();
    });
 
    afterAll(function () {
      scene.destroyForSpecs();
    });
 
    it("constructor sets default values", function () {
      var homeButton = new HomeButton(document.body, scene);
      expect(homeButton.container).toBe(document.body);
      expect(homeButton.viewModel.scene).toBe(scene);
      expect(homeButton.isDestroyed()).toEqual(false);
      homeButton.destroy();
      expect(homeButton.isDestroyed()).toEqual(true);
    });
 
    it("constructor sets expected values", function () {
      var homeButton = new HomeButton(document.body, scene);
      expect(homeButton.container).toBe(document.body);
      expect(homeButton.viewModel.scene).toBe(scene);
      homeButton.destroy();
    });
 
    it("constructor works with string id container", function () {
      var testElement = document.createElement("span");
      testElement.id = "testElement";
      document.body.appendChild(testElement);
      var homeButton = new HomeButton("testElement", scene);
      expect(homeButton.container).toBe(testElement);
      document.body.removeChild(testElement);
      homeButton.destroy();
    });
 
    it("throws if container is undefined", function () {
      expect(function () {
        return new HomeButton(undefined, scene);
      }).toThrowDeveloperError();
    });
 
    it("throws if container string is undefined", function () {
      expect(function () {
        return new HomeButton("testElement", scene);
      }).toThrowDeveloperError();
    });
  },
  "WebGL"
);