|
4 | 4 | * - Caret : Cursor position in text (numeric)
|
5 | 5 | * - Term : User input, any string value, can be empty
|
6 | 6 | * - Token : Matched part of term (part left, part right)
|
7 |
| - * - Word : Result (combined tokens, if any) |
| 7 | + * - Text : Result (combined tokens, if any) |
8 | 8 | *
|
9 | 9 | * ###
|
10 | 10 | *
|
|
13 | 13 | *
|
14 | 14 | * Required
|
15 | 15 | * - Input data expectations + assumptions:
|
| 16 | + * - Text can be anything (including special characters, numbers, ...) |
16 | 17 | * - All values are strings
|
17 | 18 | * - Term can be empty
|
18 | 19 | * - Multi-byte support (= No RegEx for a-z possible)
|
|
39 | 40 | *
|
40 | 41 | * Pseudo-type annotations similar to TypeScript/Flow:
|
41 | 42 | * - constructor()
|
42 |
| - * - getWordAtCaretPosition(string text, uint caretPosition): string |
| 43 | + * - getTextAtCaretPosition(string text, uint caretPosition): string |
43 | 44 | *
|
44 | 45 | * ###
|
45 | 46 | *
|
|
52 | 53 | * - No result : '' : * | Empty
|
53 | 54 | * - No result : ' ' : * | Whitespace
|
54 | 55 | * - No result : ' A ' : Before | Whitespace
|
55 |
| - * - No result : ' A ' : After | Whitespace |
| 56 | + * - No result : ' 1 ' : After | Whitespace – Numeric |
56 | 57 | * - Result : 'A' : Before | Match (right)
|
57 |
| - * - Result : 'A' : After | Match (left) |
| 58 | + * - Result : '1' : After | Match (left) – Numeric |
58 | 59 | * - Result : 'AA' : Inner | Match (left + right)
|
| 60 | + * - Result : '#' : Before | Match (right) – Special character |
59 | 61 | * - ---------- : ---- : --------------------------------------
|
60 | 62 | */
|
61 | 63 | const TermTextSearch = require('./term-text-search');
|
62 | 64 |
|
63 | 65 | const instance = new TermTextSearch();
|
64 | 66 |
|
65 |
| -describe('xxx', () => { |
| 67 | +describe('Term text search', () => { |
66 | 68 |
|
67 |
| - test('', () => { |
68 |
| - //const result = instance.search(''); |
| 69 | + test('no result for empty text', () => { |
| 70 | + //const result = instance.getTextAtCaretPosition(''); |
69 | 71 | //expect(result).toStrictEqual([]);
|
70 | 72 | });
|
71 | 73 |
|
|
0 commit comments