commit-lab / lodasher

8 stars 2 forks source link

Missing Test: after.test.js - Throw error if n is less than 0 #2

Closed ManishManwani36 closed 6 months ago

ManishManwani36 commented 6 months ago

Hi @obber, me again. Found another addition for a test to check if n is less than 0.

it("should not allow an n less than 0", function () {
        const fn = jest.fn();
        expect(function () {
            lodasher.after(-1, fn);
        }).toThrow();
        expect(function () {
            lodasher.after(-1000, fn);
        }).toThrow();
});

Also added an example to the definition in index.js:

const contactList = [];
const addToContactListAfter3Times = after(3, function(name) {
  contactList.push(name);
}

addToContactListAfter3Times('joe');
addToContactListAfter3Times('mary');
addToContactListAfter3Times('jill');
addToContactListAfter3Times('dean');
addToContactListAfter3Times('zoe');

console.log(contactList); // ['dean', 'zoe']
obber commented 6 months ago

Perfect, can you add the change and submit a PR? :)

Thanks!