FaDev
FaDev

Reputation: 11

How can I test the validations of a model if I use backbone validation

I have a backbone model

var MyModel= Backbone.Model.extend({
   validation: function () 
      var validate= { 
           name: {
               required: true,
           },
      };

      return validate;

   },
});

I use sinon, mocha and chai for test. When I call model.validate() in the test it tells me that the function does not exist, how can I check that the validation works?

Upvotes: 1

Views: 45

Answers (1)

T J
T J

Reputation: 43156

It seems you should do the following for validation plugin to work:

_.extend(Backbone.Model.prototype, Backbone.Validation.mixin);

Upvotes: 1

Related Questions