mercredi 8 février 2017

Karma-Jasmine unit tests for passing Query String parameters to next page

Vote count: 0

I have some unit tests with karma-jasmine for a function that makes use of the window.location.href. Here the query strings from the window.location has to be passed to the next page.

I am splitting the current page url at '?' and appending it to the href in the anchor tag.

    qs: function () {
        var qs = window.location.href.split('?')[1] || '';
        var queryString = '&' + qs;
        var urlLink = this.$el.find('a.button');
        var url = urlLink.attr('href');
        var completeUrl = url + queryString;
        urlLink.attr('href', completeUrl);
    },

and the html is

    <a class="button" href="www.xyz.com">Button</a>

Can anyone help me out with the solution to do the karma-jasmine unit tests for this.

asked 43 secs ago

Let's block ads! (Why?)



Karma-Jasmine unit tests for passing Query String parameters to next page

Aucun commentaire:

Enregistrer un commentaire