A fork of https://github.com/ueokande/vim-vixen
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.6 KiB
49 lines
1.6 KiB
6 years ago
|
import * as parsers from 'shared/urls';
|
||
|
|
||
|
describe("shared/commands/parsers", () => {
|
||
6 years ago
|
describe('#searchUrl', () => {
|
||
6 years ago
|
const config = {
|
||
|
default: 'google',
|
||
|
engines: {
|
||
|
google: 'https://google.com/search?q={}',
|
||
|
yahoo: 'https://yahoo.com/search?q={}',
|
||
|
}
|
||
|
};
|
||
|
|
||
|
it('convertes search url', () => {
|
||
6 years ago
|
expect(parsers.searchUrl('google.com', config))
|
||
6 years ago
|
.to.equal('http://google.com');
|
||
6 years ago
|
expect(parsers.searchUrl('google apple', config))
|
||
6 years ago
|
.to.equal('https://google.com/search?q=apple');
|
||
6 years ago
|
expect(parsers.searchUrl('yahoo apple', config))
|
||
6 years ago
|
.to.equal('https://yahoo.com/search?q=apple');
|
||
6 years ago
|
expect(parsers.searchUrl('google apple banana', config))
|
||
6 years ago
|
.to.equal('https://google.com/search?q=apple%20banana');
|
||
6 years ago
|
expect(parsers.searchUrl('yahoo C++CLI', config))
|
||
6 years ago
|
.to.equal('https://yahoo.com/search?q=C%2B%2BCLI');
|
||
|
});
|
||
|
|
||
|
it('user default search engine', () => {
|
||
6 years ago
|
expect(parsers.searchUrl('apple banana', config))
|
||
6 years ago
|
.to.equal('https://google.com/search?q=apple%20banana');
|
||
|
});
|
||
6 years ago
|
|
||
|
it('searches with a word containing a colon', () => {
|
||
6 years ago
|
expect(parsers.searchUrl('foo:', config))
|
||
6 years ago
|
.to.equal('https://google.com/search?q=foo%3A');
|
||
6 years ago
|
expect(parsers.searchUrl('std::vector', config))
|
||
6 years ago
|
.to.equal('https://google.com/search?q=std%3A%3Avector');
|
||
|
});
|
||
6 years ago
|
});
|
||
6 years ago
|
|
||
|
describe('#normalizeUrl', () => {
|
||
|
it('normalize urls', () => {
|
||
|
expect(parsers.normalizeUrl('https://google.com/'))
|
||
|
.to.equal('https://google.com/');
|
||
|
expect(parsers.normalizeUrl('google.com'))
|
||
|
.to.equal('http://google.com');
|
||
|
});
|
||
|
});
|
||
6 years ago
|
});
|
||
|
|