Skip to content

Commit

Permalink
Added unit test #216
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Nov 27, 2023
1 parent 1b47ca0 commit a950f75
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/test/js/spec/TriggerPrePopulateBindingSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
describe("triggerPrePopulate binding handler Spec", function () {

var mockElement;
beforeEach(function () {
jasmine.clock().install();

mockElement = document.createElement('input');
document.body.appendChild(mockElement);

});

afterEach(function () {
jasmine.clock().uninstall();
document.body.removeChild(mockElement);
});

it("should add the score class and a tooltip to the element", function () {
var metadata = {
name:'item',
dataType:'number',
behaviour: [
{
type:"pre_populate",
config: {
source: {
"context-path":"test"
},
target: "item2"

}
}
]
};
var context = {
test: {
val1:"1",
item3: "3"
}
};
var config = {};
var dataItem = ko.observable().extend({metadata:{metadata:metadata, context:context, config:config}});


var model = {
item:dataItem,
item2: {
load:function(data) {
this.item3(data.item3);
},
item3:ko.observable()
}
}
$(mockElement).attr('data-bind', 'triggerPrePopulate:item');
ko.applyBindings(model, mockElement);

jasmine.clock().tick(10);

expect(model.item2.item3()).toEqual("3");

});
});

0 comments on commit a950f75

Please sign in to comment.