-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function startsWith(value, arg1) { | ||
return typeof value === 'string' && typeof arg1 === 'string' && value.startsWith(arg1); | ||
} | ||
|
||
startsWith.negativeForm = 'doesNotStartWith'; | ||
|
||
export default startsWith; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import startsWith from '.'; | ||
|
||
describe('Tests isArray rule', () => { | ||
const word = 'meow'; | ||
const totallyDifferentWord = 'lorem'; | ||
it('Should return true for the same word', () => { | ||
expect(startsWith(word, word)).toBe(true); | ||
}); | ||
|
||
it('Should return true for a prefix', () => { | ||
expect(startsWith(word, word.substring(0, word.length / 2))).toBe(true); | ||
}); | ||
|
||
it('Should return true for empty prefix', () => { | ||
expect(startsWith(word, '')).toBe(true); | ||
}); | ||
|
||
it('Should return false for a wrong prefix', () => { | ||
expect(startsWith(word, word.substring(1, word.length - 1))).toBe(false); | ||
}); | ||
|
||
it('Should return false for a prefix which is a totally different word', () => { | ||
expect(startsWith(word, totallyDifferentWord)).toBe(false); | ||
}); | ||
|
||
it('Should return false for a prefix longer than the word', () => { | ||
expect(startsWith(word, word.repeat(2))).toBe(false); | ||
}); | ||
|
||
it('Should expose negativeForm property', () => { | ||
expect(startsWith.negativeForm).toBe('doesNotStartWith'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters