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

fix: throw error instead of returning it in check case type functions#1624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionString/CheckFlatCase.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,7 @@
const checkFlatCase = (varname) => {
// firstly, check that input is a string or not.
if (typeof varname !== 'string') {
return new TypeError('Argument is not a string.')
throw new TypeError('Argument is not a string.')
}

const pat = /^[a-z]*$/
Expand Down
2 changes: 1 addition & 1 deletionString/CheckKebabCase.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
const CheckKebabCase = (varName) => {
// firstly, check that input is a string or not.
if (typeof varName !== 'string') {
return new TypeError('Argument is not a string.')
throw new TypeError('Argument is not a string.')
}

const pat = /(\w+)-(\w)([\w-]*)/
Expand Down
2 changes: 1 addition & 1 deletionString/CheckPascalCase.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
const CheckPascalCase = (VarName) => {
// firstly, check that input is a string or not.
if (typeof VarName !== 'string') {
return new TypeError('Argument is not a string.')
throw new TypeError('Argument is not a string.')
}

const pat = /^[A-Z][A-Za-z]*$/
Expand Down
4 changes: 4 additions & 0 deletionsString/test/CheckCamelCase.test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,4 +15,8 @@ describe('checkCamelCase', () => {
const result = checkCamelCase(value)
expect(result).toBe(false)
})

it('should throw when input is not a string', () => {
expect(() => checkCamelCase(100)).toThrowError()
})
})
4 changes: 4 additions & 0 deletionsString/test/CheckFlatCase.test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,4 +15,8 @@ describe('checkFlatCase function', () => {
const actual = checkFlatCase('abcdefghijklmnopqrstuvwxyz')
expect(actual).toBe(true)
})

it('should throw when input is not a string', () => {
expect(() => checkFlatCase(100)).toThrowError()
})
})
4 changes: 4 additions & 0 deletionsString/test/CheckKebabCase.test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,3 +11,7 @@ test('CheckKebabCase(The Algorithms) -> false', () => {
const res = CheckKebabCase(word)
expect(res).toBeFalsy()
})

test('CheckKebabCase throws when input is not a string', () => {
expect(() => CheckKebabCase(100)).toThrowError()
})
4 changes: 4 additions & 0 deletionsString/test/CheckPascalCase.test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,3 +17,7 @@ test('CheckPascalCase(The Algorithms) -> false', () => {
const res = CheckPascalCase(word)
expect(res).toBeFalsy()
})

test('CheckPascalCase throws when input is not a string', () => {
expect(() => CheckPascalCase(100)).toThrowError()
})

[8]ページ先頭

©2009-2025 Movatter.jp