-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30559 from HardikChoudhary24/fix/input-error
input of '[' and other special characters fixed (cherry picked from commit d651cab)
- Loading branch information
1 parent
d3e8a1e
commit 0416a66
Showing
2 changed files
with
65 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import convertToLTRForComposer from '@libs/convertToLTRForComposer'; | ||
import CONST from '@src/CONST'; | ||
|
||
describe('convertToLTRForComposer', () => { | ||
test('Input without RTL characters remains unchanged', () => { | ||
// Test when input contains no RTL characters | ||
const inputText = 'Hello, world!'; | ||
const result = convertToLTRForComposer(inputText); | ||
expect(result).toBe(inputText); | ||
}); | ||
|
||
test('Input with RTL characters is prefixed with LTR marker', () => { | ||
// Test when input contains RTL characters | ||
const inputText = 'مثال'; | ||
const result = convertToLTRForComposer(inputText); | ||
expect(result).toBe(`${CONST.UNICODE.LTR}${inputText}`); | ||
}); | ||
|
||
test('Input with mixed RTL and LTR characters is prefixed with LTR marker', () => { | ||
// Test when input contains mix of RTL and LTR characters | ||
const inputText = 'مثال test '; | ||
const result = convertToLTRForComposer(inputText); | ||
expect(result).toBe(`${CONST.UNICODE.LTR}${inputText}`); | ||
}); | ||
|
||
test('Input with only space remains unchanged', () => { | ||
// Test when input contains only spaces | ||
const inputText = ' '; | ||
const result = convertToLTRForComposer(inputText); | ||
expect(result).toBe(inputText); | ||
}); | ||
|
||
test('Input with existing LTR marker remains unchanged', () => { | ||
// Test when input already starts with the LTR marker | ||
const inputText = `${CONST.UNICODE.LTR}مثال`; | ||
const result = convertToLTRForComposer(inputText); | ||
expect(result).toBe(inputText); | ||
}); | ||
|
||
test('Input starting with native emojis remains unchanged', () => { | ||
// Test when input starts with the native emojis | ||
const inputText = '🧶'; | ||
const result = convertToLTRForComposer(inputText); | ||
expect(result).toBe(inputText); | ||
}); | ||
|
||
test('Input is empty', () => { | ||
// Test when input is empty to check for draft comments | ||
const inputText = ''; | ||
const result = convertToLTRForComposer(inputText); | ||
expect(result.length).toBe(0); | ||
}); | ||
|
||
test('input with special characters remains unchanged', () => { | ||
// Test when input contains special characters | ||
const specialCharacters = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '-', '=', '{', '}', '[', ']', '"', ':', ';', '<', '>', '?', '`', '~']; | ||
specialCharacters.forEach((character) => { | ||
const result = convertToLTRForComposer(character); | ||
expect(result).toBe(character); | ||
}); | ||
}); | ||
}); |