|
2 | 2 |
|
3 | 3 | set -euo pipefail |
4 | 4 |
|
5 | | -ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd) |
6 | | -export ROOT |
| 5 | +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" |
7 | 6 |
|
8 | | -node <<'JS' |
9 | | -const search = require(`${process.env.ROOT}/shell/plugins/launcher/LauncherSearch.js`) |
10 | | -
|
11 | | -function fail(description, detail) { |
12 | | - if (detail) console.error(detail) |
13 | | - console.error(`not ok - ${description}`) |
14 | | - process.exit(1) |
15 | | -} |
16 | | -
|
17 | | -function pass(description) { |
18 | | - console.log(`ok - ${description}`) |
19 | | -} |
20 | | -
|
21 | | -function assert(condition, description, detail) { |
22 | | - if (!condition) fail(description, detail) |
23 | | - pass(description) |
24 | | -} |
| 7 | +run_node_test <<'JS' |
| 8 | +const search = requireFromRoot('shell/plugins/launcher/LauncherSearch.js') |
25 | 9 |
|
26 | 10 | const entries = [ |
27 | 11 | { |
@@ -69,26 +53,16 @@ const entries = [ |
69 | 53 | ] |
70 | 54 |
|
71 | 55 | const contactMatches = search.sortedEntries(entries, 'contact').map(row => search.entryName(row.entry)) |
72 | | -assert( |
73 | | - contactMatches.length === 1 && contactMatches[0] === 'Google Contacts', |
74 | | - 'contact search only returns direct contact matches', |
75 | | - `matches: ${contactMatches.join(', ')}` |
76 | | -) |
| 56 | +assertDeepEqual(contactMatches, ['Google Contacts'], 'contact search only returns direct contact matches') |
77 | 57 |
|
78 | 58 | assert( |
79 | 59 | search.fuzzyScore(entries[1], 'contact') < 0, |
80 | 60 | 'calculator does not match contact as a loose subsequence' |
81 | 61 | ) |
82 | 62 |
|
83 | 63 | const acronymMatches = search.sortedEntries(entries, 'gc').map(row => search.entryName(row.entry)) |
84 | | -assert( |
85 | | - acronymMatches[0] === 'Google Contacts', |
86 | | - 'short acronym matching still works' |
87 | | -) |
| 64 | +assertEqual(acronymMatches[0], 'Google Contacts', 'short acronym matching still works') |
88 | 65 |
|
89 | 66 | const directMatches = search.sortedEntries(entries, 'obs').map(row => search.entryName(row.entry)) |
90 | | -assert( |
91 | | - directMatches[0] === 'OBS Studio', |
92 | | - 'direct app-name matching still works' |
93 | | -) |
| 67 | +assertEqual(directMatches[0], 'OBS Studio', 'direct app-name matching still works') |
94 | 68 | JS |
0 commit comments