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
import { defined } from "../../../Source/Cesium.js";
import pollToPromise from "../../pollToPromise.js";
import { Animation } from "../../../Source/Cesium.js";
import { AnimationViewModel } from "../../../Source/Cesium.js";
import { ClockViewModel } from "../../../Source/Cesium.js";
 
describe("Widgets/Animation/Animation", function () {
  var container;
  var animation;
  afterEach(function () {
    if (defined(animation)) {
      animation = animation.destroy();
    }
    if (defined(container) && defined(container.parentNode)) {
      container.parentNode.removeChild(container);
    }
  });
 
  it("Can create and destroy", function () {
    var clockViewModel = new ClockViewModel();
    var animationViewModel = new AnimationViewModel(clockViewModel);
    animation = new Animation(document.body, animationViewModel);
  });
 
  it("Can create with container not in the DOM", function () {
    container = document.createElement("div");
    var clockViewModel = new ClockViewModel();
    var animationViewModel = new AnimationViewModel(clockViewModel);
    var animation = new Animation(container, animationViewModel);
 
    //Verify applyThemeChanges is called when we add the container to the DOM.
    spyOn(animation, "applyThemeChanges").and.callThrough();
    document.body.appendChild(container);
 
    //This is done via polling because we can't control when the DOM decides to
    //fire the Mutation event.
    return pollToPromise(function () {
      return animation.applyThemeChanges.calls.count() === 1;
    });
  });
 
  it("Can destroy without container ever being in the DOM", function () {
    container = document.createElement("div");
    var clockViewModel = new ClockViewModel();
    var animationViewModel = new AnimationViewModel(clockViewModel);
    animation = new Animation(container, animationViewModel);
  });
});