11import { 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