Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita5945e3

Browse files
authored
fix: throw error instead of returning it (#1624)
1 parentc067a34 commita5945e3

File tree

7 files changed

+19
-3
lines changed

7 files changed

+19
-3
lines changed

‎String/CheckFlatCase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
constcheckFlatCase=(varname)=>{
1313
// firstly, check that input is a string or not.
1414
if(typeofvarname!=='string'){
15-
returnnewTypeError('Argument is not a string.')
15+
thrownewTypeError('Argument is not a string.')
1616
}
1717

1818
constpat=/^[a-z]*$/

‎String/CheckKebabCase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
constCheckKebabCase=(varName)=>{
1111
// firstly, check that input is a string or not.
1212
if(typeofvarName!=='string'){
13-
returnnewTypeError('Argument is not a string.')
13+
thrownewTypeError('Argument is not a string.')
1414
}
1515

1616
constpat=/(\w+)-(\w)([\w-]*)/

‎String/CheckPascalCase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
constCheckPascalCase=(VarName)=>{
1111
// firstly, check that input is a string or not.
1212
if(typeofVarName!=='string'){
13-
returnnewTypeError('Argument is not a string.')
13+
thrownewTypeError('Argument is not a string.')
1414
}
1515

1616
constpat=/^[A-Z][A-Za-z]*$/

‎String/test/CheckCamelCase.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ describe('checkCamelCase', () => {
1515
constresult=checkCamelCase(value)
1616
expect(result).toBe(false)
1717
})
18+
19+
it('should throw when input is not a string',()=>{
20+
expect(()=>checkCamelCase(100)).toThrowError()
21+
})
1822
})

‎String/test/CheckFlatCase.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ describe('checkFlatCase function', () => {
1515
constactual=checkFlatCase('abcdefghijklmnopqrstuvwxyz')
1616
expect(actual).toBe(true)
1717
})
18+
19+
it('should throw when input is not a string',()=>{
20+
expect(()=>checkFlatCase(100)).toThrowError()
21+
})
1822
})

‎String/test/CheckKebabCase.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ test('CheckKebabCase(The Algorithms) -> false', () => {
1111
constres=CheckKebabCase(word)
1212
expect(res).toBeFalsy()
1313
})
14+
15+
test('CheckKebabCase throws when input is not a string',()=>{
16+
expect(()=>CheckKebabCase(100)).toThrowError()
17+
})

‎String/test/CheckPascalCase.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ test('CheckPascalCase(The Algorithms) -> false', () => {
1717
constres=CheckPascalCase(word)
1818
expect(res).toBeFalsy()
1919
})
20+
21+
test('CheckPascalCase throws when input is not a string',()=>{
22+
expect(()=>CheckPascalCase(100)).toThrowError()
23+
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp