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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import { knockout } from "../../../Source/Cesium.js";
import { ProviderViewModel } from "../../../Source/Cesium.js";
import { createCommand } from "../../../Source/Cesium.js";
 
describe("Widgets/BaseLayerPicker/ProviderViewModel", function () {
  var spyCreationFunction;
  beforeEach(function () {
    spyCreationFunction = jasmine.createSpy("creationFunction");
  });
 
  describe("with observables", function () {
    it("constructor sets expected parameters", function () {
      var options = {
        name: knockout.observable("name"),
        tooltip: knockout.observable("tooltip"),
        iconUrl: knockout.observable("iconUrl"),
        category: "mycategory",
        creationFunction: createCommand(spyCreationFunction),
      };
 
      var viewModel = new ProviderViewModel(options);
      expect(viewModel.name).toBe(options.name());
      expect(viewModel.tooltip).toBe(options.tooltip());
      expect(viewModel.iconUrl).toBe(options.iconUrl());
      expect(viewModel.category).toBe(options.category);
 
      expect(viewModel.creationCommand).toBeDefined();
      viewModel.creationCommand();
      expect(spyCreationFunction).toHaveBeenCalled();
    });
 
    it("constructor throws with no name", function () {
      var options = {
        tooltip: knockout.observable("tooltip"),
        iconUrl: knockout.observable("iconUrl"),
        creationFunction: createCommand(spyCreationFunction),
      };
 
      expect(function () {
        return new ProviderViewModel(options);
      }).toThrowDeveloperError();
    });
 
    it("constructor throws with no tooltip", function () {
      var options = {
        name: knockout.observable("name"),
        iconUrl: knockout.observable("iconUrl"),
        creationFunction: createCommand(spyCreationFunction),
      };
 
      expect(function () {
        return new ProviderViewModel(options);
      }).toThrowDeveloperError();
    });
 
    it("constructor throws with no iconUrl", function () {
      var options = {
        name: knockout.observable("name"),
        tooltip: knockout.observable("tooltip"),
        creationFunction: createCommand(spyCreationFunction),
      };
 
      expect(function () {
        return new ProviderViewModel(options);
      }).toThrowDeveloperError();
    });
 
    it("constructor throws with no creationFunction", function () {
      var options = {
        name: knockout.observable("name"),
        tooltip: knockout.observable("tooltip"),
        iconUrl: knockout.observable("iconUrl"),
      };
 
      expect(function () {
        return new ProviderViewModel(options);
      }).toThrowDeveloperError();
    });
  });
 
  describe("with values", function () {
    it("constructor sets expected parameters", function () {
      var options = {
        name: "name",
        tooltip: "tooltip",
        iconUrl: "iconUrl",
        creationFunction: spyCreationFunction,
      };
 
      var viewModel = new ProviderViewModel(options);
      expect(viewModel.name).toEqual(options.name);
      expect(viewModel.tooltip).toEqual(options.tooltip);
      expect(viewModel.iconUrl).toEqual(options.iconUrl);
 
      expect(viewModel.creationCommand).toBeDefined();
      viewModel.creationCommand();
      expect(spyCreationFunction).toHaveBeenCalled();
    });
 
    it("constructor throws with no name", function () {
      var options = {
        tooltip: "tooltip",
        iconUrl: "iconUrl",
        creationFunction: spyCreationFunction,
      };
 
      expect(function () {
        return new ProviderViewModel(options);
      }).toThrowDeveloperError();
    });
 
    it("constructor throws with no tooltip", function () {
      var options = {
        name: "name",
        iconUrl: "iconUrl",
        creationFunction: spyCreationFunction,
      };
 
      expect(function () {
        return new ProviderViewModel(options);
      }).toThrowDeveloperError();
    });
 
    it("constructor throws with no iconUrl", function () {
      var options = {
        name: "name",
        tooltip: "tooltip",
        creationFunction: spyCreationFunction,
      };
 
      expect(function () {
        return new ProviderViewModel(options);
      }).toThrowDeveloperError();
    });
 
    it("constructor throws with no creationFunction", function () {
      var options = {
        name: "name",
        tooltip: "tooltip",
        iconUrl: "iconUrl",
      };
 
      expect(function () {
        return new ProviderViewModel(options);
      }).toThrowDeveloperError();
    });
  });
});