Skip to content

Commit

Permalink
Add more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Apr 19, 2022
1 parent ae2cf00 commit 810afb1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/cspell-grammar/src/mappers/typescript.test.ts
@@ -1,6 +1,23 @@
import { mapRawString } from './typescript';

describe('mappers typescript', () => {
// cspell:ignore Fingerspitzengef Fingerspitzengefühl ˈfɪŋɐˌʃpɪtsənɡəˌfyːl
const sample = {
text: 'Fingerspitzengefühl is a German term.\nIt’s pronounced as follows: [ˈfɪŋɐˌʃpɪtsənɡəˌfyːl]',
hex: '\\x46\\x69\\x6E\\x67\\x65\\x72\\x73\\x70\\x69\\x74\\x7A\\x65\\x6E\\x67\\x65\\x66\\xFC\\x68\\x6C\\x20\\x69\\x73\\x20\
\\x61\\x20\\x47\\x65\\x72\\x6D\\x61\\x6E\\x20\\x74\\x65\\x72\\x6D\\x2E\n\\x49\\x74\\u2019\\x73\\x20\\x70\\x72\\x6F\\x6E\\x6F\\x75\\x6E\
\\x63\\x65\\x64\\x20\\x61\\x73\\x20\\x66\\x6F\\x6C\\x6C\\x6F\\x77\\x73\\x3A\\x20\\x5B\\u02C8\\x66\\u026A\\u014B\\u0250\\u02CC\\u0283\
\\x70\\u026A\\x74\\x73\\u0259\\x6E\\u0261\\u0259\\u02CC\\x66\\x79\\u02D0\\x6C\\x5D',
mixed: 'Fingerspitzengef\\xFChl is a German term.\nIt\\u2019s pronounced as follows: \
[\\u02C8f\\u026A\\u014B\\u0250\\u02CC\\u0283p\\u026Ats\\u0259n\\u0261\\u0259\\u02CCfy\\u02D0l]',
};

const emojis = {
text: 'Emojis 😁🥳🙈🙉🙊',
unicode: 'Emojis \\uD83D\\uDE01\\uD83E\\uDD73\\uD83D\\uDE48\\uD83D\\uDE49\\uD83D\\uDE4A',
codePoint: 'Emojis \\u{1F601}\\u{1F973}\\u{1F648}\\u{1F649}\\u{1F64A}',
};

test.each`
text | expected
${''} | ${''}
Expand All @@ -17,6 +34,12 @@ describe('mappers typescript', () => {
${'a\\x9h'} | ${'ax9h'}
${'a\\u9h'} | ${'au9h'}
${'a\\u{9h}'} | ${'au{9h}'}
${sample.text} | ${sample.text}
${sample.hex} | ${sample.text}
${sample.mixed} | ${sample.text}
${emojis.text} | ${emojis.text}
${emojis.unicode} | ${emojis.text}
${emojis.codePoint} | ${emojis.text}
`('mapRawString $# [$text]', ({ text, expected }) => {
const r = mapRawString(text);
expect(toCharCodes(r.text)).toBe(toCharCodes(expected));
Expand Down

0 comments on commit 810afb1

Please sign in to comment.