Last Updated: September 09, 2019
·
754
· 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?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside