Skip to content

Commit 5de0796

Browse files
committed
add more point tests
1 parent 8641d5a commit 5de0796

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

app/points.model.spec.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,47 @@
11
import { PointsModel } from './points.model';
22

3-
describe('points model tests', function() {
4-
it('should contsctruct it', function() {
5-
var pointsModel = new PointsModel();
3+
describe('PointsModel tests', function() {
4+
var mockPoint = {
5+
attributes: {
6+
index: 0
7+
},
8+
geometry: {
9+
x: 1,
10+
y: 2,
11+
spatialReference: {
12+
wkid: 4326
13+
}
14+
}
15+
};
16+
17+
var pointsModel;
18+
beforeEach(function() {
19+
pointsModel = new PointsModel();
20+
});
21+
22+
it('should contstruct it', function() {
623
expect(pointsModel).toBeDefined();
24+
expect(pointsModel.getPointGraphics()).toBeDefined();
25+
});
26+
27+
describe("adding and removing points", function() {
28+
it('should add a point to collection', function() {
29+
pointsModel.addPoint(mockPoint);
30+
pointsModel.addPoint(mockPoint);
31+
expect(pointsModel.getPointGraphics().length).toEqual(2);
32+
});
33+
34+
it('should add points to collection', function() {
35+
pointsModel.addPoints([mockPoint, mockPoint]);
36+
expect(pointsModel.getPointGraphics().length).toEqual(2);
37+
});
38+
39+
it('should clear points', function() {
40+
pointsModel.addPoint(mockPoint);
41+
pointsModel.addPoint(mockPoint);
42+
pointsModel.clear();
43+
expect(pointsModel.getPointGraphics().length).toEqual(0);
44+
});
745
});
46+
847
});

0 commit comments

Comments
 (0)