Last Updated: September 09, 2019
·
739
· satish860

Unit testing Custom Filters

If you are like me who hate reading a lengthy documentation. Here is the code sample of how to test your filter

describe("Write a Filter for the showing the unit testing", function () {
describe("Write a Filter which takes the Key and Id and sends the text", function () {
    var filter;
    beforeEach(function () {
        module("your module name where the filter is defined");
        inject(function ($filter) {
            filter = $filter;
        });
    });
    it("Should define a filter with the Dropdown service as dependcies", function () {
        var NameFilter= filter("Name of the filter");
        expect(NameFilter).toBeDefined();
    });
});
});

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

AngularJS pages are long-lived browser apps with the same script risk as a newer single-page app. Third-party code in the template can read forms and values rendered on the page.

Security insights from Cside