@@ -6,15 +6,6 @@ describe("SpeciesViewModel Spec", function () {
6
6
// request = jasmine.Ajax.requests.mostRecent();
7
7
// expect(request.method).toBe('GET');
8
8
// });
9
-
10
- afterEach ( function ( ) {
11
- jasmine . Ajax . uninstall ( ) ;
12
- } ) ;
13
-
14
- beforeEach ( function ( ) {
15
- jasmine . Ajax . install ( ) ;
16
- } ) ;
17
-
18
9
it ( "Can participate in the DataModelItem calls like checkWarnings" , function ( ) {
19
10
var options = {
20
11
searchBieUrl : '/species/searchBie'
@@ -40,58 +31,72 @@ describe("SpeciesViewModel Spec", function () {
40
31
41
32
} ) ;
42
33
43
- it ( "New outputSpeciesId is passed when the species has changed" , function ( ) {
44
- let oldSpeciesSelectedData = {
45
- outputSpeciesId : '5555555' ,
46
- scientificName : 'Current scientific Name' ,
47
- name : 'Current name' ,
48
- guid : 'Current guid'
49
- }
34
+ describe ( "Test outputSpeciesId" , function ( ) {
35
+ beforeEach ( function ( ) {
36
+ jasmine . Ajax . install ( ) ;
37
+ } ) ;
50
38
51
- let newSpeciesSelectedData = {
52
- scientificName : 'New scientific Name' ,
53
- name : 'New name' ,
54
- guid : 'New guid'
55
- } ;
39
+ afterEach ( function ( ) {
40
+ jasmine . Ajax . uninstall ( ) ;
41
+ } ) ;
56
42
43
+ it ( "New outputSpeciesId is passed when the species has changed" , function ( ) {
44
+ let oldSpeciesSelectedData = {
45
+ outputSpeciesId : '5555555' ,
46
+ scientificName : 'Current scientific Name' ,
47
+ name : 'Current name' ,
48
+ guid : 'Current guid'
49
+ }
57
50
58
- let options = { searchBieUrl : '/test/searchBie' , bieUrl : '/test/bie/' , getOutputSpeciesIdUrl : 'test/getOutputSpeciesIdUrl' }
59
- let responseData = { outputSpeciesId : "666666" } ;
51
+ let newSpeciesSelectedData = {
52
+ scientificName : 'New scientific Name' ,
53
+ name : 'New name' ,
54
+ guid : 'New guid'
55
+ } ;
60
56
61
- // spyOn($, 'ajax').and.callFake(function () {
62
- // var d = $.Deferred();
63
- // d.resolve(responseData);
64
- // return d.promise();
65
- // });
66
57
58
+ let options = { searchBieUrl : '/test/searchBie' , bieUrl : '/test/bie/' , getOutputSpeciesIdUrl : 'test/getOutputSpeciesIdUrl' }
59
+ let responseData = { outputSpeciesId : "666666" } ;
67
60
61
+ // spyOn($, 'ajax').and.callFake(function () {
62
+ // var d = $.Deferred();
63
+ // d.resolve(responseData);
64
+ // return d.promise();
65
+ // });
68
66
69
67
70
68
71
- let speciesViewModel = new SpeciesViewModel ( oldSpeciesSelectedData , options , { } ) ;
72
- // spyOn($, 'ajax').and.callFake(function () {
73
- // var d = $.Deferred();
74
- // d.resolve(responseData);
75
- // return d.promise();
76
- // });
77
69
78
- speciesViewModel . loadData ( newSpeciesSelectedData ) ;
79
70
80
- request = jasmine . Ajax . requests . mostRecent ( ) ;
71
+ let speciesViewModel = new SpeciesViewModel ( oldSpeciesSelectedData , options , { } ) ;
72
+ // spyOn($, 'ajax').and.callFake(function () {
73
+ // var d = $.Deferred();
74
+ // d.resolve(responseData);
75
+ // return d.promise();
76
+ // });
81
77
82
- request . respondWith ( {
83
- status : 200 ,
84
- responseJSON : responseData
85
- } ) ;
78
+ // request = jasmine.Ajax.requests.mostRecent();
79
+ // request.respondWith({
80
+ // status: 200,
81
+ // responseJSON: responseData
82
+ // });
86
83
84
+ speciesViewModel . loadData ( newSpeciesSelectedData ) ;
85
+ request = jasmine . Ajax . requests . filter ( 'test/getOutputSpeciesIdUrl' ) [ 0 ] ;
86
+ request . respondWith ( {
87
+ status : 200 ,
88
+ responseJSON : responseData
89
+ } ) ;
87
90
88
- // expect(request.url).toBe('test/getOutputSpeciesIdUrl');
89
- expect ( speciesViewModel . toJS ( ) . outputSpeciesId ) . toEqual ( responseData . outputSpeciesId )
90
91
91
- expect ( speciesViewModel . outputSpeciesId ( ) ) . not . toEqual ( oldSpeciesSelectedData . outputSpeciesId ) ;
92
+ // expect(request.url).toBe('test/getOutputSpeciesIdUrl');
93
+ expect ( speciesViewModel . toJS ( ) . outputSpeciesId ) . toEqual ( responseData . outputSpeciesId )
94
+
95
+ expect ( speciesViewModel . outputSpeciesId ( ) ) . not . toEqual ( oldSpeciesSelectedData . outputSpeciesId ) ;
92
96
// expect($.ajax).toHaveBeenCalled();
93
- // expect(speciesViewModel.toJS().outputSpeciesId).toEqual(responseData.outputSpeciesId);
97
+ // expect(speciesViewModel.toJS().outputSpeciesId).toEqual(responseData.outputSpeciesId);
94
98
95
- } ) ;
99
+ } ) ;
100
+ } )
96
101
97
102
} ) ;
0 commit comments