-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #262 from AtlasOfLivingAustralia/feature/issue1638
commit fix on occurrenceId changing every form submit #1638
- Loading branch information
Showing
3 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,70 @@ | ||
describe("SpeciesViewModel Spec", function () { | ||
var request, result; | ||
it("Can participate in the DataModelItem calls like checkWarnings", function () { | ||
|
||
let speciesViewModel = new SpeciesViewModel({}, {searchBieUrl:'/species/searchBie'}, {}); | ||
var options = { | ||
searchBieUrl: '/species/searchBie' | ||
} | ||
let speciesViewModel = new SpeciesViewModel({}, options, {}); | ||
expect(speciesViewModel.checkWarnings()).toBeUndefined(); | ||
}); | ||
|
||
it("Same outputSpeciesId is passed when the species has not changed", function (){ | ||
var data = { | ||
outputSpeciesId: "5555555", | ||
scientificName: "Test Scientific Name", | ||
name:"Test name", | ||
guid:"Test guid" | ||
}; | ||
|
||
let options = {searchBieUrl: '/test/searchBie', bieUrl: '/test/bie/', getOutputSpeciesIdUrl: 'test/getOutputSpeciesIdUrl'} | ||
|
||
let speciesViewModel = new SpeciesViewModel({}, options, {}); | ||
speciesViewModel.loadData(data); | ||
|
||
expect(data.outputSpeciesId).toEqual(speciesViewModel.toJS().outputSpeciesId); | ||
|
||
}); | ||
|
||
describe("Test ajax call to supply new outSpeciesId", function () { | ||
beforeEach(function() { | ||
jasmine.Ajax.install(); | ||
}); | ||
|
||
afterEach(function() { | ||
jasmine.Ajax.uninstall(); | ||
}); | ||
|
||
it("New outputSpeciesId is passed when the species has changed", function (){ | ||
let oldSpeciesSelectedData = { | ||
outputSpeciesId: '5555555', | ||
scientificName: 'Current scientific Name', | ||
name: 'Current name', | ||
guid: 'Current guid' | ||
} | ||
|
||
let newSpeciesSelectedData = { | ||
scientificName: 'New scientific Name', | ||
name: 'New name', | ||
guid: 'New guid' | ||
}; | ||
|
||
let options = {searchBieUrl: '/test/searchBie', bieUrl: '/test/bie/', getOutputSpeciesIdUrl: 'test/getOutputSpeciesIdUrl'} | ||
let responseData = {outputSpeciesId: "666666"}; | ||
|
||
let speciesViewModel = new SpeciesViewModel(oldSpeciesSelectedData, options, {}); | ||
|
||
speciesViewModel.loadData(newSpeciesSelectedData); | ||
request = jasmine.Ajax.requests.filter('test/getOutputSpeciesIdUrl')[0]; | ||
request.respondWith({ | ||
status: 200, | ||
responseJSON: responseData | ||
}); | ||
|
||
expect(request.url).toBe('test/getOutputSpeciesIdUrl'); | ||
expect(speciesViewModel.toJS().outputSpeciesId).toEqual(responseData.outputSpeciesId) | ||
expect(speciesViewModel.outputSpeciesId()).not.toEqual(oldSpeciesSelectedData.outputSpeciesId); | ||
|
||
}); | ||
}) | ||
|
||
}); |