Skip to content

Instantly share code, notes, and snippets.

@flackend
Created November 18, 2017 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flackend/af6b41e6f55dfa7ee59a249480f963af to your computer and use it in GitHub Desktop.
Save flackend/af6b41e6f55dfa7ee59a249480f963af to your computer and use it in GitHub Desktop.
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);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment