From 7192cd7e506759bfef94a40ece402b1b724c87b5 Mon Sep 17 00:00:00 2001 From: Dongho Kim <70563791+mass2527@users.noreply.github.com> Date: Tue, 24 Sep 2024 10:36:32 +0900 Subject: [PATCH] test: Update specs for string methods (#589) * style: Remove unnecessary `async` keyword * test: Update specs for string methods --- src/compat/function/debounce.spec.ts | 2 +- src/compat/string/endsWith.spec.ts | 14 +++++++------- src/compat/string/startsWith.spec.ts | 14 +++++++------- src/function/after.spec.ts | 8 ++++---- src/function/before.spec.ts | 8 ++++---- src/function/debounce.spec.ts | 2 +- src/function/throttle.spec.ts | 4 ++-- src/string/_internal/getWords.spec.ts | 20 ++++++++++---------- src/string/camelCase.spec.ts | 22 +++++++++------------- src/string/capitalize.spec.ts | 14 +++++++------- src/string/kebabCase.spec.ts | 24 ++++++++++++------------ src/string/lowerCase.spec.ts | 20 ++++++++++---------- src/string/pascalCase.spec.ts | 2 +- src/string/snakeCase.spec.ts | 20 ++++++++++---------- src/string/trim.spec.ts | 22 +++++++++++----------- src/string/trimEnd.spec.ts | 22 +++++++++++----------- src/string/trimStart.spec.ts | 22 +++++++++++----------- src/string/upperCase.spec.ts | 20 ++++++++++---------- 18 files changed, 128 insertions(+), 132 deletions(-) diff --git a/src/compat/function/debounce.spec.ts b/src/compat/function/debounce.spec.ts index 0e6d992ed..5a7b43345 100644 --- a/src/compat/function/debounce.spec.ts +++ b/src/compat/function/debounce.spec.ts @@ -76,7 +76,7 @@ describe('debounce', () => { expect(func).toHaveBeenCalledTimes(2); }); - it('should have no effect if we call cancel when the function is not executed', async () => { + it('should have no effect if we call cancel when the function is not executed', () => { const func = vi.fn(); const debounceMs = 50; const debouncedFunc = debounce(func, debounceMs); diff --git a/src/compat/string/endsWith.spec.ts b/src/compat/string/endsWith.spec.ts index c2382d2f6..f9840c7fc 100644 --- a/src/compat/string/endsWith.spec.ts +++ b/src/compat/string/endsWith.spec.ts @@ -2,31 +2,31 @@ import { describe, it, expect } from 'vitest'; import { endsWith } from './endsWith'; describe('endsWith', () => { - it('should return true if the string ends with the target string', async () => { + it('should return true if the string ends with the target string', () => { expect(endsWith('fooBar', 'Bar')).toEqual(true); }); - it('should return false if the string does not end with the target string', async () => { + it('should return false if the string does not end with the target string', () => { expect(endsWith('fooBar', 'abc')).toEqual(false); }); - it('should return false if the string does not end with the target string, but does contain it', async () => { + it('should return false if the string does not end with the target string, but does contain it', () => { expect(endsWith('fooBar', 'foo')).toEqual(false); }); - it('should return true if the target string is an empty string', async () => { + it('should return true if the target string is an empty string', () => { expect(endsWith('fooBar', '')).toEqual(true); }); - it('should return true if the string and target string are empty strings', async () => { + it('should return true if the string and target string are empty strings', () => { expect(endsWith('', '')).toEqual(true); }); - it('should return false if the string past the provided position does not end with the target string', async () => { + it('should return false if the string past the provided position does not end with the target string', () => { expect(endsWith('fooBar', 'foo', 5)).toEqual(false); }); - it('should return true if the string before the provided position ends with the target string', async () => { + it('should return true if the string before the provided position ends with the target string', () => { expect(endsWith('fooBar123', 'foo', 3)).toEqual(true); }); diff --git a/src/compat/string/startsWith.spec.ts b/src/compat/string/startsWith.spec.ts index 5a1db9182..4c5e5ed39 100644 --- a/src/compat/string/startsWith.spec.ts +++ b/src/compat/string/startsWith.spec.ts @@ -2,31 +2,31 @@ import { describe, it, expect } from 'vitest'; import { startsWith } from './startsWith'; describe('startsWith', () => { - it('should return true if the string starts with the target string', async () => { + it('should return true if the string starts with the target string', () => { expect(startsWith('fooBar', 'foo')).toEqual(true); }); - it('should return false if the string does not start with the target string', async () => { + it('should return false if the string does not start with the target string', () => { expect(startsWith('fooBar', 'abc')).toEqual(false); }); - it('should return false if the string does not start with the target string, but does contain it', async () => { + it('should return false if the string does not start with the target string, but does contain it', () => { expect(startsWith('fooBar', 'Bar')).toEqual(false); }); - it('should return true if the target string is an empty string', async () => { + it('should return true if the target string is an empty string', () => { expect(startsWith('fooBar', '')).toEqual(true); }); - it('should return true if the string and target string are empty strings', async () => { + it('should return true if the string and target string are empty strings', () => { expect(startsWith('', '')).toEqual(true); }); - it('should return false if the string past the provided position does not start with the target string', async () => { + it('should return false if the string past the provided position does not start with the target string', () => { expect(startsWith('fooBar', 'Bar', 5)).toEqual(false); }); - it('should return true if the string past the provided position does start with the target string', async () => { + it('should return true if the string past the provided position does start with the target string', () => { expect(startsWith('fooBar', 'Bar', 3)).toEqual(true); }); diff --git a/src/function/after.spec.ts b/src/function/after.spec.ts index 889acac5c..349247c48 100644 --- a/src/function/after.spec.ts +++ b/src/function/after.spec.ts @@ -2,14 +2,14 @@ import { describe, expect, it, vi } from 'vitest'; import { after } from './after'; describe('after', () => { - it('should throw error if n is less than zero.', async () => { + it('should throw error if n is less than zero.', () => { const mockFn = vi.fn(); const n = -1; expect(() => after(n, mockFn)).toThrowErrorMatchingInlineSnapshot('[Error: n must be a non-negative integer.]'); expect(() => after(NaN, mockFn)).toThrowErrorMatchingInlineSnapshot('[Error: n must be a non-negative integer.]'); }); - it('should create a function that invokes `func` only after being called `n` calls.`', async () => { + it('should create a function that invokes `func` only after being called `n` calls.`', () => { const mockFn = vi.fn(); const n = 3; @@ -26,7 +26,7 @@ describe('after', () => { expect(mockFn).toHaveBeenCalledTimes(2); }); - it('should not invoke func immediately when n is zero.', async () => { + it('should not invoke func immediately when n is zero.', () => { const mockFn = vi.fn(); const afterFn = after(0, mockFn); expect(mockFn).toHaveBeenCalledTimes(0); @@ -35,7 +35,7 @@ describe('after', () => { expect(mockFn).toHaveBeenCalledTimes(1); }); - it('should handle arguments correctly.', async () => { + it('should handle arguments correctly.', () => { const mockFn = vi.fn(); mockFn.mockReturnValue(3); diff --git a/src/function/before.spec.ts b/src/function/before.spec.ts index 9ade61b39..db1a0e163 100644 --- a/src/function/before.spec.ts +++ b/src/function/before.spec.ts @@ -2,12 +2,12 @@ import { describe, expect, it, vi } from 'vitest'; import { before } from './before'; describe('before', () => { - it('should throw error if n is less than zero.', async () => { + it('should throw error if n is less than zero.', () => { const mockFn = vi.fn(); expect(() => before(-1, mockFn)).toThrowErrorMatchingInlineSnapshot('[Error: n must be a non-negative integer.]'); }); - it('should create a function that invokes `func` only until the `n-1`-th calls.', async () => { + it('should create a function that invokes `func` only until the `n-1`-th calls.', () => { const mockFn = vi.fn(); mockFn.mockReturnValue(1); const n = 3; @@ -21,7 +21,7 @@ describe('before', () => { expect(beforeFn()).toBeUndefined(); }); - it('should not invoke func immediately when n is a positive integer', async () => { + it('should not invoke func immediately when n is a positive integer', () => { const mockFn = vi.fn(); mockFn.mockReturnValue(1); const n = 3; @@ -32,7 +32,7 @@ describe('before', () => { expect(mockFn).toHaveBeenCalledTimes(1); }); - it('should handle arguments correctly', async () => { + it('should handle arguments correctly', () => { const mockFn = vi.fn(); mockFn.mockReturnValue(3); const n = 3; diff --git a/src/function/debounce.spec.ts b/src/function/debounce.spec.ts index ab4d1f7c0..f57da7e15 100644 --- a/src/function/debounce.spec.ts +++ b/src/function/debounce.spec.ts @@ -74,7 +74,7 @@ describe('debounce', () => { expect(func).toHaveBeenCalledTimes(2); }); - it('should have no effect if we call cancel when the function is not executed', async () => { + it('should have no effect if we call cancel when the function is not executed', () => { const func = vi.fn(); const debounceMs = 50; const debouncedFunc = debounce(func, debounceMs); diff --git a/src/function/throttle.spec.ts b/src/function/throttle.spec.ts index 229438244..cb1f74da9 100644 --- a/src/function/throttle.spec.ts +++ b/src/function/throttle.spec.ts @@ -3,7 +3,7 @@ import { throttle } from './throttle'; import { delay } from '../promise'; describe('throttle', () => { - it('should throttle function calls', async () => { + it('should throttle function calls', () => { const func = vi.fn(); const throttledFunc = throttle(func, 100); @@ -34,7 +34,7 @@ describe('throttle', () => { expect(func).toHaveBeenCalledTimes(2); }); - it('should call the function with correct arguments', async () => { + it('should call the function with correct arguments', () => { const func = vi.fn(); const throttleMs = 50; const throttledFunc = throttle(func, throttleMs); diff --git a/src/string/_internal/getWords.spec.ts b/src/string/_internal/getWords.spec.ts index 6b66640ea..88ab4dfaa 100644 --- a/src/string/_internal/getWords.spec.ts +++ b/src/string/_internal/getWords.spec.ts @@ -2,61 +2,61 @@ import { describe, expect, it } from 'vitest'; import { getWords } from './getWords'; describe('caseSplitPattern', () => { - it('should match camelCase', async () => { + it('should match camelCase', () => { const str = 'camelCase'; const matches = getWords(str); expect(matches).toEqual(['camel', 'Case']); }); - it('should match snake_case', async () => { + it('should match snake_case', () => { const str = 'snake_case'; const matches = getWords(str); expect(matches).toEqual(['snake', 'case']); }); - it('should match kebab-case', async () => { + it('should match kebab-case', () => { const str = 'kebab-case'; const matches = getWords(str); expect(matches).toEqual(['kebab', 'case']); }); - it('should handle mixed formats', async () => { + it('should handle mixed formats', () => { const str = 'camelCase_snake_case-kebabCase'; const matches = getWords(str); expect(matches).toEqual(['camel', 'Case', 'snake', 'case', 'kebab', 'Case']); }); - it('should match acronyms', async () => { + it('should match acronyms', () => { const str = 'HTTPRequest'; const matches = getWords(str); expect(matches).toEqual(['HTTP', 'Request']); }); - it('should match special characters', async () => { + it('should match special characters', () => { const str = 'special_characters@123'; const matches = getWords(str); expect(matches).toEqual(['special', 'characters', '123']); }); - it('should handle leading and trailing whitespace', async () => { + it('should handle leading and trailing whitespace', () => { const str = ' leading_and_trailing_whitespace '; const matches = getWords(str); expect(matches).toEqual(['leading', 'and', 'trailing', 'whitespace']); }); - it('should handle underscores', async () => { + it('should handle underscores', () => { const str = 'underscore_case_example'; const matches = getWords(str); expect(matches).toEqual(['underscore', 'case', 'example']); }); - it('should handle single character words', async () => { + it('should handle single character words', () => { const str = 'aB'; const matches = getWords(str); expect(matches).toEqual(['a', 'B']); }); - it('should work with hyphens ', () => { + it('should work with hyphens', () => { expect(getWords('--FOO-BAR--')).toEqual(['FOO', 'BAR']); }); diff --git a/src/string/camelCase.spec.ts b/src/string/camelCase.spec.ts index 12372d161..c868c2eb6 100644 --- a/src/string/camelCase.spec.ts +++ b/src/string/camelCase.spec.ts @@ -2,39 +2,35 @@ import { describe, expect, it } from 'vitest'; import { camelCase } from './camelCase'; describe('camelCase', () => { - it('should change camel case to camel case', async () => { + it('should change camel case to camel case', () => { expect(camelCase('camelCase')).toEqual('camelCase'); }); - it('should change space to camel case', async () => { + it('should change space to camel case', () => { expect(camelCase('some whitespace')).toEqual('someWhitespace'); }); - it('should change hyphen to camel case', async () => { + it('should change hyphen to camel case', () => { expect(camelCase('hyphen-text')).toEqual('hyphenText'); }); - it('should change Acronyms to small letter', async () => { + it('should change Acronyms to small letter', () => { expect(camelCase('HTTPRequest')).toEqual('httpRequest'); }); - it('should handle leading and trailing whitespace', async () => { - expect(camelCase(' leading and trailing whitespace')).toEqual('leadingAndTrailingWhitespace'); + it('should handle leading and trailing whitespace', () => { + expect(camelCase(' leading and trailing whitespace ')).toEqual('leadingAndTrailingWhitespace'); }); - it('should handle special characters correctly', async () => { + it('should handle special characters correctly', () => { expect(camelCase('special@characters!')).toEqual('specialCharacters'); }); - it('should handle strings that are already in camel_case', async () => { - expect(camelCase('camel_case')).toEqual('camelCase'); - }); - - it('should work with an empty string', async () => { + it('should work with an empty string', () => { expect(camelCase('')).toEqual(''); }); - it('should work with screaming camel case', async () => { + it('should work with screaming camel case', () => { expect(camelCase('FOO_BAR')).toEqual('fooBar'); }); }); diff --git a/src/string/capitalize.spec.ts b/src/string/capitalize.spec.ts index 8edbf498d..a0c4947d8 100644 --- a/src/string/capitalize.spec.ts +++ b/src/string/capitalize.spec.ts @@ -2,31 +2,31 @@ import { describe, it, expect } from 'vitest'; import { capitalize } from './capitalize'; describe('capitalize', () => { - it('should converts the first character of string to upper case', async () => { + it('should converts the first character of string to upper case', () => { expect(capitalize('fred')).toEqual('Fred'); }); - it('should converts the first character of string to upper case and the remaining to lower case.', async () => { + it('should converts the first character of string to upper case and the remaining to lower case.', () => { expect(capitalize('FRED')).toEqual('Fred'); }); - it('should handle special characters correctly', async () => { + it('should handle special characters correctly', () => { expect(capitalize('special@characters!')).toEqual('Special@characters!'); }); - it('should handle hyphen correctly', async () => { + it('should handle hyphen correctly', () => { expect(capitalize('hyphen-text')).toEqual('Hyphen-text'); }); - it('should handle leading whitespace', async () => { + it('should handle leading whitespace', () => { expect(capitalize(' fred')).toEqual(' fred'); }); - it('should handle strings that are already in capitalize', async () => { + it('should handle strings that are already in capitalize', () => { expect(capitalize('Fred')).toEqual('Fred'); }); - it('should work with an empty string', async () => { + it('should work with an empty string', () => { expect(capitalize('')).toEqual(''); }); }); diff --git a/src/string/kebabCase.spec.ts b/src/string/kebabCase.spec.ts index 91d30513b..a5b74fb0f 100644 --- a/src/string/kebabCase.spec.ts +++ b/src/string/kebabCase.spec.ts @@ -2,47 +2,47 @@ import { describe, it, expect } from 'vitest'; import { kebabCase } from './kebabCase'; describe('kebabCase', () => { - it('should change camel case to kebab case', async () => { + it('should change camel case to kebab case', () => { expect(kebabCase('camelCase')).toEqual('camel-case'); }); - it('should change space to dash', async () => { + it('should change space to dash', () => { expect(kebabCase('some whitespace')).toEqual('some-whitespace'); }); - it('should change hyphen to dash', async () => { + it('should change hyphen to dash', () => { expect(kebabCase('hyphen-text')).toEqual('hyphen-text'); }); - it('should change Acronyms to small letter', async () => { + it('should change Acronyms to small letter', () => { expect(kebabCase('HTTPRequest')).toEqual('http-request'); }); - it('should handle leading and trailing whitespace', async () => { - expect(kebabCase(' leading and trailing whitespace')).toEqual('leading-and-trailing-whitespace'); + it('should handle leading and trailing whitespace', () => { + expect(kebabCase(' leading and trailing whitespace ')).toEqual('leading-and-trailing-whitespace'); }); - it('should handle special characters correctly', async () => { + it('should handle special characters correctly', () => { expect(kebabCase('special@characters!')).toEqual('special-characters'); }); - it('should handle strings that are already in snake_case', async () => { + it('should handle strings that are already in snake_case', () => { expect(kebabCase('snake_case')).toEqual('snake-case'); }); - it('should work with an empty string', async () => { + it('should work with an empty string', () => { expect(kebabCase('')).toEqual(''); }); - it('should work with an leading and trailing underscores', async () => { + it('should work with an leading and trailing underscores', () => { expect(kebabCase('__foo_bar___')).toEqual('foo-bar'); }); - it('should work with screaming snake case', async () => { + it('should work with screaming snake case', () => { expect(kebabCase('FOO_BAR')).toEqual('foo-bar'); }); - it('should work with capitalized words', async () => { + it('should work with capitalized words', () => { expect(kebabCase('Foo Bar')).toEqual('foo-bar'); }); }); diff --git a/src/string/lowerCase.spec.ts b/src/string/lowerCase.spec.ts index 1f3ed3642..4970fe9d5 100644 --- a/src/string/lowerCase.spec.ts +++ b/src/string/lowerCase.spec.ts @@ -2,39 +2,39 @@ import { describe, it, expect } from 'vitest'; import { lowerCase } from './lowerCase'; describe('lowerCase', () => { - it('should change camel case to lower case', async () => { + it('should change camel case to lower case', () => { expect(lowerCase('camelCase')).toEqual('camel case'); }); - it('should change space to space', async () => { + it('should change space to space', () => { expect(lowerCase('some whitespace')).toEqual('some whitespace'); }); - it('should change hyphen to space', async () => { + it('should change hyphen to space', () => { expect(lowerCase('hyphen-text')).toEqual('hyphen text'); }); - it('should change Acronyms to small letter', async () => { + it('should change Acronyms to small letter', () => { expect(lowerCase('HTTPRequest')).toEqual('http request'); }); - it('should handle leading and trailing whitespace', async () => { - expect(lowerCase(' leading and trailing whitespace')).toEqual('leading and trailing whitespace'); + it('should handle leading and trailing whitespace', () => { + expect(lowerCase(' leading and trailing whitespace ')).toEqual('leading and trailing whitespace'); }); - it('should handle special characters correctly', async () => { + it('should handle special characters correctly', () => { expect(lowerCase('special@characters!')).toEqual('special characters'); }); - it('should handle strings that are already in lower case', async () => { + it('should handle strings that are already in lower case', () => { expect(lowerCase('lower_case')).toEqual('lower case'); }); - it('should work with an empty string', async () => { + it('should work with an empty string', () => { expect(lowerCase('')).toEqual(''); }); - it('should work with screaming snake case', async () => { + it('should work with screaming snake case', () => { expect(lowerCase('FOO_BAR')).toEqual('foo bar'); }); }); diff --git a/src/string/pascalCase.spec.ts b/src/string/pascalCase.spec.ts index 90897ed94..5fb29b542 100644 --- a/src/string/pascalCase.spec.ts +++ b/src/string/pascalCase.spec.ts @@ -15,7 +15,7 @@ describe('PascalCase', () => { }); it('should handle leading and trailing whitespace', () => { - expect(pascalCase(' leading and trailing whitespace')).toEqual('LeadingAndTrailingWhitespace'); + expect(pascalCase(' leading and trailing whitespace ')).toEqual('LeadingAndTrailingWhitespace'); }); it('should handle special characters correctly', () => { diff --git a/src/string/snakeCase.spec.ts b/src/string/snakeCase.spec.ts index aabbed08c..c56a57831 100644 --- a/src/string/snakeCase.spec.ts +++ b/src/string/snakeCase.spec.ts @@ -2,39 +2,39 @@ import { describe, it, expect } from 'vitest'; import { snakeCase } from './snakeCase'; describe('snakeCase', () => { - it('should change camel case to snake case', async () => { + it('should change camel case to snake case', () => { expect(snakeCase('camelCase')).toEqual('camel_case'); }); - it('should change space to underscore', async () => { + it('should change space to underscore', () => { expect(snakeCase('some whitespace')).toEqual('some_whitespace'); }); - it('should change hyphen to underscore', async () => { + it('should change hyphen to underscore', () => { expect(snakeCase('hyphen-text')).toEqual('hyphen_text'); }); - it('should change Acronyms to small letter', async () => { + it('should change Acronyms to small letter', () => { expect(snakeCase('HTTPRequest')).toEqual('http_request'); }); - it('should handle leading and trailing whitespace', async () => { - expect(snakeCase(' leading and trailing whitespace')).toEqual('leading_and_trailing_whitespace'); + it('should handle leading and trailing whitespace', () => { + expect(snakeCase(' leading and trailing whitespace ')).toEqual('leading_and_trailing_whitespace'); }); - it('should handle special characters correctly', async () => { + it('should handle special characters correctly', () => { expect(snakeCase('special@characters!')).toEqual('special_characters'); }); - it('should handle strings that are already in snake_case', async () => { + it('should handle strings that are already in snake_case', () => { expect(snakeCase('snake_case')).toEqual('snake_case'); }); - it('should work with an empty string', async () => { + it('should work with an empty string', () => { expect(snakeCase('')).toEqual(''); }); - it('should work with screaming snake case', async () => { + it('should work with screaming snake case', () => { expect(snakeCase('FOO_BAR')).toEqual('foo_bar'); }); }); diff --git a/src/string/trim.spec.ts b/src/string/trim.spec.ts index 2f0277e7d..730269af8 100644 --- a/src/string/trim.spec.ts +++ b/src/string/trim.spec.ts @@ -2,47 +2,47 @@ import { describe, it, expect } from 'vitest'; import { trim } from './trim.ts'; describe('trim', () => { - it('should return the string without the double quotes', async () => { + it('should return the string without the double quotes', () => { expect(trim('"hello, world!"', '"')).toEqual('hello, world!'); }); - it('should return the string without special characters', async () => { + it('should return the string without special characters', () => { expect(trim('!@#$%^&*wow%#$', ['!', '@', '#', '$', '%', '^', '&', '*'])).toEqual('wow'); }); - it('should return the string unchanged when no matching characters are found', async () => { + it('should return the string unchanged when no matching characters are found', () => { expect(trim('hello', 'x')).toEqual('hello'); }); - it('should remove all occurrences of a single character', async () => { + it('should remove all occurrences of a single character', () => { expect(trim('banana', 'a')).toEqual('banan'); }); - it('should remove all occurrences of multiple characters', async () => { + it('should remove all occurrences of multiple characters', () => { expect(trim('abracadabra', ['a', 'b'])).toEqual('racadabr'); }); - it('should handle an empty string', async () => { + it('should handle an empty string', () => { expect(trim('', 'a')).toEqual(''); }); - it('should remove spaces when specified', async () => { + it('should remove spaces when specified', () => { expect(trim('hello world', ' ')).toEqual('hello world'); }); - it('should handle a case where the string is already trimmed', async () => { + it('should handle a case where the string is already trimmed', () => { expect(trim('alreadyTrimmed', 'x')).toEqual('alreadyTrimmed'); }); - it('should return an empty string when all characters are removed', async () => { + it('should return an empty string when all characters are removed', () => { expect(trim('aaaaa', 'a')).toEqual(''); }); - it('should remove numbers from a string', async () => { + it('should remove numbers from a string', () => { expect(trim('123abc456', ['1', '2', '3', '4', '5', '6'])).toEqual('abc'); }); - it('should trim the string without giving the second parameter, which defaults to whitespace', async () => { + it('should trim the string without giving the second parameter, which defaults to whitespace', () => { expect(trim(' hello world ')).toEqual('hello world'); }); }); diff --git a/src/string/trimEnd.spec.ts b/src/string/trimEnd.spec.ts index b8b6884bb..fb9d9e6ff 100644 --- a/src/string/trimEnd.spec.ts +++ b/src/string/trimEnd.spec.ts @@ -2,47 +2,47 @@ import { describe, expect, it } from 'vitest'; import { trimEnd } from './trimEnd.ts'; describe('trimEnd', () => { - it('should remove trailing characters from the string', async () => { + it('should remove trailing characters from the string', () => { expect(trimEnd('hello---', '-')).toEqual('hello'); }); - it('should remove trailing characters when multiple characters are provided', async () => { + it('should remove trailing characters when multiple characters are provided', () => { expect(trimEnd('123000', '0')).toEqual('123'); }); - it('should return the string unchanged when there are no trailing characters to remove', async () => { + it('should return the string unchanged when there are no trailing characters to remove', () => { expect(trimEnd('hello', 'x')).toEqual('hello'); }); - it('should remove trailing occurrences of a single character', async () => { + it('should remove trailing occurrences of a single character', () => { expect(trimEnd('abcabcabc', 'c')).toEqual('abcabcab'); }); - it('should handle an empty string', async () => { + it('should handle an empty string', () => { expect(trimEnd('', 'x')).toEqual(''); }); - it('should remove trailing spaces when specified', async () => { + it('should remove trailing spaces when specified', () => { expect(trimEnd('hello world ', ' ')).toEqual('hello world'); }); - it('should handle a case where the string is already trimmed', async () => { + it('should handle a case where the string is already trimmed', () => { expect(trimEnd('trimmed', 'x')).toEqual('trimmed'); }); - it('should return an empty string when all characters are removed', async () => { + it('should return an empty string when all characters are removed', () => { expect(trimEnd('xxxxx', 'x')).toEqual(''); }); - it('should remove numbers from the end of a string', async () => { + it('should remove numbers from the end of a string', () => { expect(trimEnd('abc123456', '6')).toEqual('abc12345'); }); - it('should handle cases where multiple trailing characters need removal', async () => { + it('should handle cases where multiple trailing characters need removal', () => { expect(trimEnd('abc123abc123abc', 'c')).toEqual('abc123abc123ab'); }); - it('should trim the string without giving the second parameter, which defaults to whitespace', async () => { + it('should trim the string without giving the second parameter, which defaults to whitespace', () => { expect(trimEnd(' hello world ')).toEqual(' hello world'); }); }); diff --git a/src/string/trimStart.spec.ts b/src/string/trimStart.spec.ts index 49bb73de4..5e896a0e3 100644 --- a/src/string/trimStart.spec.ts +++ b/src/string/trimStart.spec.ts @@ -2,47 +2,47 @@ import { describe, expect, it } from 'vitest'; import { trimStart } from './trimStart.ts'; describe('trimStart', () => { - it('should remove leading characters from the string', async () => { + it('should remove leading characters from the string', () => { expect(trimStart('---hello', '-')).toEqual('hello'); }); - it('should remove leading zeros from the string', async () => { + it('should remove leading zeros from the string', () => { expect(trimStart('000123', '0')).toEqual('123'); }); - it('should return the string unchanged when there are no leading characters to remove', async () => { + it('should return the string unchanged when there are no leading characters to remove', () => { expect(trimStart('hello', 'x')).toEqual('hello'); }); - it('should remove leading occurrences of a single character', async () => { + it('should remove leading occurrences of a single character', () => { expect(trimStart('abcabcabc', 'a')).toEqual('bcabcabc'); }); - it('should handle an empty string', async () => { + it('should handle an empty string', () => { expect(trimStart('', 'x')).toEqual(''); }); - it('should remove leading spaces when specified', async () => { + it('should remove leading spaces when specified', () => { expect(trimStart(' hello world', ' ')).toEqual('hello world'); }); - it('should handle a case where the string is already trimmed', async () => { + it('should handle a case where the string is already trimmed', () => { expect(trimStart('trimmed', 'x')).toEqual('trimmed'); }); - it('should return an empty string when all characters are removed', async () => { + it('should return an empty string when all characters are removed', () => { expect(trimStart('xxxxx', 'x')).toEqual(''); }); - it('should remove numbers from the start of a string', async () => { + it('should remove numbers from the start of a string', () => { expect(trimStart('123456abc', '1')).toEqual('23456abc'); }); - it('should handle cases where multiple leading characters need removal', async () => { + it('should handle cases where multiple leading characters need removal', () => { expect(trimStart('aaaabbbcccc', 'a')).toEqual('bbbcccc'); }); - it('should trim the string without giving the second parameter, which defaults to whitespace', async () => { + it('should trim the string without giving the second parameter, which defaults to whitespace', () => { expect(trimStart(' hello world ')).toEqual('hello world '); }); }); diff --git a/src/string/upperCase.spec.ts b/src/string/upperCase.spec.ts index 0234e85ab..94b797045 100644 --- a/src/string/upperCase.spec.ts +++ b/src/string/upperCase.spec.ts @@ -2,39 +2,39 @@ import { describe, it, expect } from 'vitest'; import { upperCase } from './upperCase'; describe('upperCase', () => { - it('should change camel case to upper case', async () => { + it('should change camel case to upper case', () => { expect(upperCase('camelCase')).toEqual('CAMEL CASE'); }); - it('should change space to space', async () => { + it('should change space to space', () => { expect(upperCase('some whitespace')).toEqual('SOME WHITESPACE'); }); - it('should change hyphen to space', async () => { + it('should change hyphen to space', () => { expect(upperCase('hyphen-text')).toEqual('HYPHEN TEXT'); }); - it('should change Acronyms to small letter', async () => { + it('should change Acronyms to small letter', () => { expect(upperCase('HTTPRequest')).toEqual('HTTP REQUEST'); }); - it('should handle leading and trailing whitespace', async () => { - expect(upperCase(' leading and trailing whitespace')).toEqual('LEADING AND TRAILING WHITESPACE'); + it('should handle leading and trailing whitespace', () => { + expect(upperCase(' leading and trailing whitespace ')).toEqual('LEADING AND TRAILING WHITESPACE'); }); - it('should handle special characters correctly', async () => { + it('should handle special characters correctly', () => { expect(upperCase('special@characters!')).toEqual('SPECIAL CHARACTERS'); }); - it('should handle strings that are already in upper case', async () => { + it('should handle strings that are already in upper case', () => { expect(upperCase('upper_case')).toEqual('UPPER CASE'); }); - it('should work with an empty string', async () => { + it('should work with an empty string', () => { expect(upperCase('')).toEqual(''); }); - it('should work with screaming snake case', async () => { + it('should work with screaming snake case', () => { expect(upperCase('FOO_BAR')).toEqual('FOO BAR'); }); });