mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
Let streets named for keys and codes through, and share a request in flight
From review of the first pass: - Places again: "Secret Key Lake", "Access Token Road", "GATE CODE LANE", "OTP Bank", "Auth Code ABCD Street", "California 90210-1234", "Cambridge MA. 02139-4307", "12, 10115 Berlin". A key after a space must be long, a bare code must hold a digit or be capitals after a label that is not and end the line, and ZIP+4 follows a state's code or name. - Private now: "gate code: abcd", "PIN A7B2", "OTP-ABCDEF", "login code ab-12-cd", "auth_token=abc". - The same text asked while its request is out waits for that answer, however slow it is. - A street without a house number is not named by the street alone. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
9539287a7c
commit
3404730d41
2 files changed
+183
-103
No files matched your search
@@ -385,3 +385,45 @@ test('two houses on one street are two suggestions, asked once', async () => {
|
||||
assert.deepEqual(second, first);
|
||||
assert.equal(sent, 1);
|
||||
});
|
||||
|
||||
test('streets named for keys, tokens and codes, and ZIP+4 after a state, are places', () => {
|
||||
for (const line of [
|
||||
'Secret Key Lake',
|
||||
'Access Token Road',
|
||||
'Api Key Lane',
|
||||
'GATE CODE LANE',
|
||||
'SECURITY CODE PLAZA',
|
||||
'OTP Bank',
|
||||
'MFA BOSTON',
|
||||
'Auth Code ABCD Street',
|
||||
'California 90210-1234',
|
||||
'Austin Texas 78701-1234',
|
||||
'Cambridge MA. 02139-4307',
|
||||
'12, 10115 Berlin',
|
||||
])
|
||||
assert.equal(mayBePrivate(line), false, line);
|
||||
for (const line of [
|
||||
'gate code: abcd',
|
||||
'PIN A7B2',
|
||||
'PIN is A7B2',
|
||||
'OTP-ABCDEF',
|
||||
'OTP – ABCDEF',
|
||||
'login code ab-12-cd',
|
||||
'auth_token=abc',
|
||||
])
|
||||
assert.equal(mayBePrivate(line), true, line);
|
||||
});
|
||||
|
||||
test('the same text asked again while its request is out is sent once', async () => {
|
||||
let sent = 0;
|
||||
const service = createPlaceSuggester({
|
||||
endpoint: 'https://fixture.test/api/',
|
||||
fetchImpl: async () => {
|
||||
sent++;
|
||||
await new Promise((resolve) => setTimeout(resolve, 700));
|
||||
return Response.json({ features: [] });
|
||||
},
|
||||
});
|
||||
await Promise.all([service.suggest('Paris'), service.suggest('Paris')]);
|
||||
assert.equal(sent, 1);
|
||||
});
|
||||
Reference in new issue
Block a user