-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
86 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,82 @@ | ||
import { test } from 'zora' | ||
|
||
import { getFastAutocomplete } from '../../browser/components/urlBox.js' | ||
|
||
export async function urlBox() { | ||
test('Fast autocomplete', (test) => { | ||
test.test('URL: google.com', (test) => { | ||
const result = getFastAutocomplete('google.com') | ||
test.ok(result, 'result exists') | ||
test.ok(result.length > 0, 'result has length') | ||
test.equal(result[0]?.display, 'https://google.com', 'title is correct') | ||
test.equal(result[0]?.url, 'https://google.com', 'url is correct') | ||
test.equal(result[1]?.display, 'google.com', 'title is correct') | ||
test.equal( | ||
result[1]?.url, | ||
'https://duckduckgo.com/?q=google.com', | ||
'url is correct', | ||
) | ||
}) | ||
|
||
test.test('URL: https://google.com', (test) => { | ||
const result = getFastAutocomplete('https://google.com') | ||
test.ok(result, 'result exists') | ||
test.ok(result.length > 0, 'result has length') | ||
test.equal(result[0]?.display, 'https://google.com', 'title is correct') | ||
test.equal(result[0]?.url, 'https://google.com', 'url is correct') | ||
test.equal(result[1]?.display, 'https://google.com', 'title is correct') | ||
test.equal( | ||
result[1]?.url, | ||
'https://duckduckgo.com/?q=https://google.com', | ||
'url is correct', | ||
) | ||
}) | ||
|
||
test.test('URL: google.com/test', (test) => { | ||
const result = getFastAutocomplete('google.com/test') | ||
test.ok(result, 'result exists') | ||
test.ok(result.length > 0, 'result has length') | ||
test.equal( | ||
result[0]?.display, | ||
'https://google.com/test', | ||
'title is correct', | ||
) | ||
test.equal(result[0]?.url, 'https://google.com/test', 'url is correct') | ||
test.equal(result[1]?.display, 'google.com/test', 'title is correct') | ||
test.equal( | ||
result[1]?.url, | ||
'https://duckduckgo.com/?q=google.com/test', | ||
'url is correct', | ||
) | ||
}) | ||
|
||
test.test('URLProvider: https://abc.notarealurl/test', (test) => { | ||
const result = getFastAutocomplete('https://abc.notarealurl/test') | ||
test.ok(result, 'result exists') | ||
test.equal(result.length, 1, 'result has length') | ||
test.equal( | ||
result[0]?.display, | ||
'https://abc.notarealurl/test', | ||
'title is correct', | ||
) | ||
test.equal( | ||
result[0]?.url, | ||
'https://duckduckgo.com/?q=https://abc.notarealurl/test', | ||
'url is correct', | ||
) | ||
}) | ||
|
||
test.test('URLProvider: about:blank', (test) => { | ||
const result = getFastAutocomplete('about:blank') | ||
test.eq(result.length, 2, 'There should be 2 result') | ||
test.eq(result[0]?.display, 'about:blank', 'The title should be correct') | ||
test.eq(result[0]?.url, 'about:blank', 'The url should be correct') | ||
test.eq(result[1]?.display, 'about:blank', 'The title should be correct') | ||
test.eq( | ||
result[1]?.url, | ||
'https://duckduckgo.com/?q=about:blank', | ||
'The url should be correct', | ||
) | ||
}) | ||
}) | ||
} |