Last Updated: September 09, 2019
·
551
· 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();
    });
});
});