Skip to content

Commit 5c03282

Browse files
committed
fix broken test
1 parent cddd219 commit 5c03282

File tree

2 files changed

+56
-46
lines changed

2 files changed

+56
-46
lines changed

src/test/js/spec/EnmapifySpec.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,10 @@ describe("Enmapify Spec", function () {
504504

505505
describe("Test ajax call to manual create point", function() {
506506
var request, result;
507-
jasmine.Ajax.install();
507+
508508

509509
beforeEach(function() {
510+
jasmine.Ajax.install();
510511
result = enmapify(options);
511512
result.viewModel.transients.editCoordinates(true);
512513
options.container["TestLatitude"](0);
@@ -520,6 +521,10 @@ describe("Enmapify Spec", function () {
520521
expect(request.method).toBe('GET');
521522
});
522523

524+
afterEach(function() {
525+
jasmine.Ajax.uninstall();
526+
});
527+
523528
it("should add point to map and dismiss coordinate fields", function() {
524529
request.respondWith({
525530
status: 200,

src/test/js/spec/SpeciesViewModelSpec.js

+50-45
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ describe("SpeciesViewModel Spec", function () {
66
// request = jasmine.Ajax.requests.mostRecent();
77
// expect(request.method).toBe('GET');
88
// });
9-
10-
afterEach(function() {
11-
jasmine.Ajax.uninstall();
12-
});
13-
14-
beforeEach(function() {
15-
jasmine.Ajax.install();
16-
});
17-
189
it("Can participate in the DataModelItem calls like checkWarnings", function () {
1910
var options = {
2011
searchBieUrl: '/species/searchBie'
@@ -40,58 +31,72 @@ describe("SpeciesViewModel Spec", function () {
4031

4132
});
4233

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+
});
5038

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+
});
5642

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+
}
5750

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+
};
6056

61-
// spyOn($, 'ajax').and.callFake(function () {
62-
// var d = $.Deferred();
63-
// d.resolve(responseData);
64-
// return d.promise();
65-
// });
6657

58+
let options = {searchBieUrl: '/test/searchBie', bieUrl: '/test/bie/', getOutputSpeciesIdUrl: 'test/getOutputSpeciesIdUrl'}
59+
let responseData = {outputSpeciesId: "666666"};
6760

61+
// spyOn($, 'ajax').and.callFake(function () {
62+
// var d = $.Deferred();
63+
// d.resolve(responseData);
64+
// return d.promise();
65+
// });
6866

6967

7068

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-
// });
7769

78-
speciesViewModel.loadData(newSpeciesSelectedData);
7970

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+
// });
8177

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+
// });
8683

84+
speciesViewModel.loadData(newSpeciesSelectedData);
85+
request = jasmine.Ajax.requests.filter('test/getOutputSpeciesIdUrl')[0];
86+
request.respondWith({
87+
status: 200,
88+
responseJSON: responseData
89+
});
8790

88-
// expect(request.url).toBe('test/getOutputSpeciesIdUrl');
89-
expect(speciesViewModel.toJS().outputSpeciesId).toEqual(responseData.outputSpeciesId)
9091

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);
9296
// expect($.ajax).toHaveBeenCalled();
93-
// expect(speciesViewModel.toJS().outputSpeciesId).toEqual(responseData.outputSpeciesId);
97+
// expect(speciesViewModel.toJS().outputSpeciesId).toEqual(responseData.outputSpeciesId);
9498

95-
});
99+
});
100+
})
96101

97102
});

0 commit comments

Comments
 (0)