These are chat archives for canjs/canjs

11th
Nov 2016
Viktor Busko
@Lighttree
Nov 11 2016 10:12
Hi guys, we are currently use 2.2.x version of Can.js and I was thinking about migration to newer version. Does it makes sense to migrate to 2.3.27 or its better to 3.0.0. There are couple of limitation I have, for example we can't use npm in some security reasons. And 2.3.27 looks like 'safer' option, but maybe not 'future proof'
anyone has a starter template?
Frank Lemanschik
@frank-dspeed
Nov 11 2016 13:16
@Lighttree Yes 3.0 works better then 2.3
it totally makes sense to upgrade now
Tan Wei Seng
plz install it and get familary with it
it can generate projects for you and helps u using it
Tan Wei Seng
@xming13
Nov 11 2016 13:17
ok
will look into it. thanks!
Sunil George
@georgesunil81
Nov 11 2016 15:32
Hope everyone is doing great here. Am back from a vacation and looking for some help with automated unit testing on my CanJS application!
I am using StealJS and have my CanJS application in form of can.Control that generates each view, something like below -
define([
    "can",
    "app/models/User",
    "app/pages/mobileUserVerification/MobileUserVerificationView.stache"
], function(can, user, MobileUserVerificationView) {

    return can.Control.extend({

        init: function(el, options) {

            var scope = this.scope = new(can.Map.extend({}))();

        //scope variables added or updated here

        //calling internal functions here.
        internalFunction();    

        //finally generating the view as below
            el.html(can.view(MobileUserVerificationView, scope)); 

        },

    internalFunction: function() {

    },

        '#button click': function(el, ev) {

        },

        functionCalledFromStache: function() {

    },
    });
});
My objective is to test the internalFunction by calling it directly from my tests without calling the control/init and generating the view. What unit test framework would you recommend? Will funcunit help achieve my objective?
I'd appreciate if anyone can lead me to any examples of unit testing can.Controls.
Sunil George
@georgesunil81
Nov 11 2016 15:37
Also, there is a function (functionCalledFromStache) that is called from my stache template. Appreciate some guidance on how to unit test such functions too.
Frank Lemanschik
@frank-dspeed
Nov 11 2016 17:22
best is always to import the functions out of a file and then simply unit test that alone
there are always 2 ways of unit test methods for each function or for the whole app
depends on how big your app is
i follow the each function method i test every function if it returns what it should
Sunil George
@georgesunil81
Nov 11 2016 18:21
@frank-dspeed . Thanks for our inputs. Yes, from a perspective of unit testing, I should be able to isolate the method and test it out independently. That is the challenge I am facing currently. can.Control is what is being used in my large application and I am trying to find out a way to get a handle to the individual methods inside of it and test them out.
Frank Lemanschik
@frank-dspeed
Nov 11 2016 18:22
combine sets of functions into classes that you require
and write tests for the class
Sunil George
@georgesunil81
Nov 11 2016 18:24
Yeah, I could do that. But, I do not want to make any changes to the application. I just need to get a handle to the individual functions inside of can.Control. I am looking at funcunit to see if that is possible.