Skip to content

Commit

Permalink
Merge pull request #33894 from dimagi/riese/fix_query_spec
Browse files Browse the repository at this point in the history
fix silentlly failing query_spec.js
  • Loading branch information
MartinRiese committed Dec 18, 2023
2 parents 3e11c9e + 1c39777 commit df41a25
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,30 @@ hqDefine("cloudcare/js/formplayer/spec/query_spec", function () {
describe('Query', function () {

describe('itemset', function () {
let QueryListView = hqImport("cloudcare/js/formplayer/menus/views/query"),
Utils = hqImport("cloudcare/js/formplayer/utils/utils");

let QueryViewModel = Backbone.Model.extend(),
QueryViewCollection = Backbone.Collection.extend(),
keyModel = new QueryViewModel({
let keyQueryView;

before(function () {
const QueryListView = hqImport("cloudcare/js/formplayer/menus/views/query");
const Utils = hqImport("cloudcare/js/formplayer/utils/utils");

const QueryViewModel = Backbone.Model.extend();
const QueryViewCollection = Backbone.Collection.extend();
const keyModel = new QueryViewModel({
"itemsetChoicesKey": ["CA", "MA", "FL"],
"itemsetChoices": ["California", "Massachusetts", "Florida"],
});

let keyViewCollection = new QueryViewCollection([keyModel]);
const keyViewCollection = new QueryViewCollection([keyModel]);

sinon.stub(Utils, 'getStickyQueryInputs').callsFake(function () { return 'fake_value'; });
let keyQueryListView = QueryListView({ collection: keyViewCollection}),
sinon.stub(Utils, 'getStickyQueryInputs').callsFake(function () { return 'fake_value'; });

const keyQueryListView = QueryListView({ collection: keyViewCollection});
keyQueryView = new keyQueryListView.childView({ parentView: keyQueryListView, model: keyModel});
});

it('should create dictionary with either keys', function () {
let expectedKeyItemsetChoicesDict = { "CA": "California", "MA": "Massachusetts", "FL": "Florida"};
const expectedKeyItemsetChoicesDict = { "CA": "California", "MA": "Massachusetts", "FL": "Florida"};
assert.deepEqual(expectedKeyItemsetChoicesDict, keyQueryView.model.get("itemsetChoicesDict"));
});
});
Expand Down

0 comments on commit df41a25

Please sign in to comment.