Skip to content

Instantly share code, notes, and snippets.

@flackend
Created November 18, 2017 03:47
Show Gist options
  • Select an option

  • Save flackend/af6b41e6f55dfa7ee59a249480f963af to your computer and use it in GitHub Desktop.

Select an option

Save flackend/af6b41e6f55dfa7ee59a249480f963af to your computer and use it in GitHub Desktop.

Revisions

  1. flackend created this gist Nov 18, 2017.
    16 changes: 16 additions & 0 deletions get-index-of.test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    describe("anyOtherFunctionName", function() {
    it("should not use indexOf", function() {
    var body = anyOtherFunctionName.toString();
    expect(/indexOf/.test(body)).toBe(false);
    expect(anyOtherFunctionName("a", "I am a hacker")).toBe(2);
    });
    it("should return a number", function() {
    expect(typeof anyOtherFunctionName("a", "I am a hacker")).toBe("number");
    });
    it("should return the index of the first occurence of a string", function() {
    expect(anyOtherFunctionName("a", "I am a hacker")).toBe(2);
    });
    it("should return -1 when the character does not occur in the string", function() {
    expect(anyOtherFunctionName("x", "I am a hacker")).toBe(-1);
    });
    });