lundi 4 mai 2015

AngularJS - Unit tests on Controller that uses moment.js

I'm trying to make unit tests for a controller that uses moment.js to handle three dates of a week. My testing framework is jasmine and my AngularJS version is v1.3.15

Basically I have an init() function that sets them and I want to check if all of them are properly set in the controller.

var myController = this;

myController.init = function () {
    myController.currentDate = moment(new Date()).format('DD-MM-YYYY');
    myController.startOfWeek = moment(currentDate).startOf('week').format('DD-MM-YYYY');
    myController.endOfWeek = moment(currentDate).startOf('week').format('DD-MM-YYYY');
};

At this point I'm not sure if this approach is correct and/or if I should test this stuff here.

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire