File: submitBehaviors.js

package info (click to toggle)
node-knockout 3.4.2-2%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,924 kB
  • sloc: makefile: 7; sh: 2
file content (14 lines) | stat: -rw-r--r-- 748 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
describe('Binding: Submit', function() {
    beforeEach(jasmine.prepareTestNode);

    it('Should invoke the supplied function on submit and prevent default action, using model as \'this\' param and the form node as a param to the handler', function () {
        var firstParamStored;
        var model = { wasCalled: false, doCall: function (firstParam) { this.wasCalled = true; firstParamStored = firstParam; } };
        testNode.innerHTML = "<form data-bind='submit:doCall' />";
        var formNode = testNode.childNodes[0];
        ko.applyBindings(model, testNode);
        ko.utils.triggerEvent(testNode.childNodes[0], "submit");
        expect(model.wasCalled).toEqual(true);
        expect(firstParamStored).toEqual(formNode);
    });
});