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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import createScene from "../../createScene.js";
import { Geocoder } from "../../../Source/Cesium.js";
 
describe(
  "Widgets/Geocoder/Geocoder",
  function () {
    var scene;
 
    beforeEach(function () {
      scene = createScene();
    });
 
    afterEach(function () {
      scene.destroyForSpecs();
    });
 
    it("constructor sets expected properties", function () {
      var flightDuration = 1234;
      var destinationFound = jasmine.createSpy();
 
      var geocoder = new Geocoder({
        container: document.body,
        scene: scene,
        flightDuration: flightDuration,
        destinationFound: destinationFound,
      });
 
      var viewModel = geocoder.viewModel;
      expect(viewModel.scene).toBe(scene);
      expect(viewModel.flightDuration).toBe(flightDuration);
      expect(viewModel.destinationFound).toBe(destinationFound);
      geocoder.destroy();
    });
 
    it("can create and destroy", function () {
      var container = document.createElement("div");
      container.id = "testContainer";
      document.body.appendChild(container);
 
      var widget = new Geocoder({
        container: "testContainer",
        scene: scene,
      });
      expect(widget.container).toBe(container);
      expect(widget.isDestroyed()).toEqual(false);
      expect(container.children.length).not.toEqual(0);
      widget.destroy();
      expect(container.children.length).toEqual(0);
      expect(widget.isDestroyed()).toEqual(true);
 
      document.body.removeChild(container);
    });
 
    it("constructor throws with no scene", function () {
      expect(function () {
        return new Geocoder({
          container: document.body,
        });
      }).toThrowDeveloperError();
    });
 
    it("constructor throws with no element", function () {
      expect(function () {
        return new Geocoder({
          scene: scene,
        });
      }).toThrowDeveloperError();
    });
 
    it("constructor throws with string element that does not exist", function () {
      expect(function () {
        return new Geocoder({
          container: "does not exist",
          scene: scene,
        });
      }).toThrowDeveloperError();
    });
  },
  "WebGL"
);