2015-09-16 20:02:06 +03:00
|
|
|
/* jshint scripturl:true */
|
|
|
|
import { expect } from 'chai';
|
|
|
|
import {
|
|
|
|
describeComponent,
|
|
|
|
it
|
|
|
|
} from 'ember-mocha';
|
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
import Ember from 'ember';
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
const {run} = Ember;
|
|
|
|
|
|
|
|
// we want baseUrl to match the running domain so relative URLs are
|
|
|
|
// handled as expected (browser auto-sets the domain when using a.href)
|
|
|
|
let currentUrl = `${window.location.protocol}//${window.location.host}/`;
|
2015-09-16 20:02:06 +03:00
|
|
|
|
|
|
|
describeComponent(
|
|
|
|
'gh-navitem-url-input',
|
2015-10-06 19:31:03 +03:00
|
|
|
'Integration: Component: gh-navitem-url-input', {
|
2015-09-16 20:02:06 +03:00
|
|
|
integration: true
|
|
|
|
},
|
|
|
|
function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
// set defaults
|
|
|
|
this.set('baseUrl', currentUrl);
|
|
|
|
this.set('url', '');
|
2016-02-09 20:16:18 +03:00
|
|
|
this.set('isNew', false);
|
|
|
|
this.on('clearErrors', function () {
|
|
|
|
return null;
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly with blank url', function () {
|
|
|
|
this.render(hbs`
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
expect($input).to.have.length(1);
|
|
|
|
expect($input.hasClass('gh-input')).to.be.true;
|
|
|
|
expect($input.val()).to.equal(currentUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly with relative urls', function () {
|
|
|
|
this.set('url', '/about');
|
|
|
|
this.render(hbs`
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
expect($input.val()).to.equal(`${currentUrl}about`);
|
|
|
|
|
|
|
|
this.set('url', '/about#contact');
|
|
|
|
expect($input.val()).to.equal(`${currentUrl}about#contact`);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly with absolute urls', function () {
|
|
|
|
this.set('url', 'https://example.com:2368/#test');
|
|
|
|
this.render(hbs`
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
expect($input.val()).to.equal('https://example.com:2368/#test');
|
|
|
|
|
|
|
|
this.set('url', 'mailto:test@example.com');
|
|
|
|
expect($input.val()).to.equal('mailto:test@example.com');
|
|
|
|
|
|
|
|
this.set('url', 'tel:01234-5678-90');
|
|
|
|
expect($input.val()).to.equal('tel:01234-5678-90');
|
|
|
|
|
|
|
|
this.set('url', '//protocol-less-url.com');
|
|
|
|
expect($input.val()).to.equal('//protocol-less-url.com');
|
|
|
|
|
|
|
|
this.set('url', '#anchor');
|
|
|
|
expect($input.val()).to.equal('#anchor');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('deletes base URL on backspace', function () {
|
|
|
|
this.render(hbs`
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
expect($input.val()).to.equal(currentUrl);
|
|
|
|
run(() => {
|
|
|
|
// TODO: why is ember's keyEvent helper not available here?
|
|
|
|
let e = Ember.$.Event('keydown');
|
|
|
|
e.keyCode = 8;
|
|
|
|
$input.trigger(e);
|
|
|
|
});
|
|
|
|
expect($input.val()).to.equal('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('deletes base URL on delete', function () {
|
|
|
|
this.render(hbs`
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
expect($input.val()).to.equal(currentUrl);
|
|
|
|
run(() => {
|
|
|
|
// TODO: why is ember's keyEvent helper not available here?
|
|
|
|
let e = Ember.$.Event('keydown');
|
|
|
|
e.keyCode = 46;
|
|
|
|
$input.trigger(e);
|
|
|
|
});
|
|
|
|
expect($input.val()).to.equal('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('adds base url to relative urls on blur', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
this.on('updateUrl', () => {
|
|
|
|
return null;
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
this.render(hbs`
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
run(() => {
|
|
|
|
$input.val('/about').trigger('input');
|
|
|
|
});
|
|
|
|
run(() => {
|
|
|
|
$input.trigger('blur');
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
|
|
|
|
expect($input.val()).to.equal(`${currentUrl}about`);
|
|
|
|
});
|
|
|
|
|
2015-10-16 13:05:24 +03:00
|
|
|
it('adds "mailto:" to email addresses on blur', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
this.on('updateUrl', () => {
|
|
|
|
return null;
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
this.render(hbs`
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
run(() => {
|
|
|
|
$input.val('test@example.com').trigger('input');
|
|
|
|
});
|
|
|
|
run(() => {
|
|
|
|
$input.trigger('blur');
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
|
|
|
|
expect($input.val()).to.equal('mailto:test@example.com');
|
|
|
|
|
|
|
|
// ensure we don't double-up on the mailto:
|
2015-10-28 14:36:45 +03:00
|
|
|
run(() => {
|
|
|
|
$input.trigger('blur');
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
expect($input.val()).to.equal('mailto:test@example.com');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('doesn\'t add base url to invalid urls on blur', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
this.on('updateUrl', () => {
|
|
|
|
return null;
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
this.render(hbs`
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
let changeValue = function (value) {
|
|
|
|
run(() => {
|
|
|
|
$input.val(value).trigger('input').trigger('blur');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
changeValue('with spaces');
|
|
|
|
expect($input.val()).to.equal('with spaces');
|
|
|
|
|
|
|
|
changeValue('/with spaces');
|
|
|
|
expect($input.val()).to.equal('/with spaces');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('doesn\'t mangle invalid urls on blur', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
this.on('updateUrl', () => {
|
|
|
|
return null;
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
this.render(hbs`
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
run(() => {
|
|
|
|
$input.val(`${currentUrl} /test`).trigger('input').trigger('blur');
|
|
|
|
});
|
|
|
|
|
|
|
|
expect($input.val()).to.equal(`${currentUrl} /test`);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('triggers "change" action on blur', function () {
|
|
|
|
let changeActionCallCount = 0;
|
2015-10-28 14:36:45 +03:00
|
|
|
this.on('updateUrl', () => {
|
|
|
|
changeActionCallCount++;
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
|
|
|
|
this.render(hbs `
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
$input.trigger('blur');
|
|
|
|
|
|
|
|
expect(changeActionCallCount).to.equal(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('triggers "change" action on enter', function () {
|
|
|
|
let changeActionCallCount = 0;
|
2015-10-28 14:36:45 +03:00
|
|
|
this.on('updateUrl', () => {
|
|
|
|
changeActionCallCount++;
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
|
|
|
|
this.render(hbs `
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
run(() => {
|
|
|
|
// TODO: why is ember's keyEvent helper not available here?
|
|
|
|
let e = Ember.$.Event('keypress');
|
|
|
|
e.keyCode = 13;
|
|
|
|
$input.trigger(e);
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(changeActionCallCount).to.equal(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('triggers "change" action on CMD-S', function () {
|
|
|
|
let changeActionCallCount = 0;
|
2015-10-28 14:36:45 +03:00
|
|
|
this.on('updateUrl', () => {
|
|
|
|
changeActionCallCount++;
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
|
|
|
|
this.render(hbs `
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
run(() => {
|
|
|
|
// TODO: why is ember's keyEvent helper not available here?
|
|
|
|
let e = Ember.$.Event('keydown');
|
|
|
|
e.keyCode = 83;
|
|
|
|
e.metaKey = true;
|
|
|
|
$input.trigger(e);
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(changeActionCallCount).to.equal(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('sends absolute urls straight through to change action', function () {
|
|
|
|
let expectedUrl = '';
|
|
|
|
|
|
|
|
this.on('updateUrl', (url) => {
|
|
|
|
expect(url).to.equal(expectedUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.render(hbs `
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
let testUrl = (url) => {
|
|
|
|
expectedUrl = url;
|
2015-10-28 14:36:45 +03:00
|
|
|
run(() => {
|
|
|
|
$input.val(url).trigger('input');
|
|
|
|
});
|
|
|
|
run(() => {
|
|
|
|
$input.trigger('blur');
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
testUrl('http://example.com');
|
|
|
|
testUrl('http://example.com/');
|
|
|
|
testUrl('https://example.com');
|
|
|
|
testUrl('//example.com');
|
|
|
|
testUrl('//localhost:1234');
|
|
|
|
testUrl('#anchor');
|
|
|
|
testUrl('mailto:test@example.com');
|
|
|
|
testUrl('tel:12345-567890');
|
|
|
|
testUrl('javascript:alert("testing");');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('strips base url from relative urls before sending to change action', function () {
|
|
|
|
let expectedUrl = '';
|
|
|
|
|
|
|
|
this.on('updateUrl', (url) => {
|
|
|
|
expect(url).to.equal(expectedUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.render(hbs `
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
let testUrl = (url) => {
|
|
|
|
expectedUrl = `/${url}`;
|
2015-10-28 14:36:45 +03:00
|
|
|
run(() => {
|
|
|
|
$input.val(`${currentUrl}${url}`).trigger('input');
|
|
|
|
});
|
|
|
|
run(() => {
|
|
|
|
$input.trigger('blur');
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
};
|
|
|
|
|
2016-02-03 18:47:13 +03:00
|
|
|
testUrl('about/');
|
2015-09-16 20:02:06 +03:00
|
|
|
testUrl('about#contact');
|
2016-02-03 18:47:13 +03:00
|
|
|
testUrl('test/nested/');
|
2015-09-16 20:02:06 +03:00
|
|
|
});
|
|
|
|
|
2015-12-01 18:23:21 +03:00
|
|
|
it('handles links to subdomains of blog domain', function () {
|
2015-09-16 20:02:06 +03:00
|
|
|
let expectedUrl = '';
|
|
|
|
|
2015-12-01 18:23:21 +03:00
|
|
|
this.set('baseUrl', 'http://example.com/');
|
2015-09-16 20:02:06 +03:00
|
|
|
|
|
|
|
this.on('updateUrl', (url) => {
|
|
|
|
expect(url).to.equal(expectedUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.render(hbs `
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-09-16 20:02:06 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
2015-12-01 18:23:21 +03:00
|
|
|
expectedUrl = 'http://test.example.com/';
|
|
|
|
run(() => {
|
|
|
|
$input.val(expectedUrl).trigger('input').trigger('blur');
|
|
|
|
});
|
|
|
|
expect($input.val()).to.equal(expectedUrl);
|
2015-09-16 20:02:06 +03:00
|
|
|
});
|
|
|
|
|
2016-02-03 18:47:13 +03:00
|
|
|
it('adds trailing slash to relative URL', function () {
|
|
|
|
let expectedUrl = '';
|
|
|
|
|
|
|
|
this.on('updateUrl', (url) => {
|
|
|
|
expect(url).to.equal(expectedUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.render(hbs `
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2016-02-03 18:47:13 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
let testUrl = (url) => {
|
|
|
|
expectedUrl = `/${url}/`;
|
|
|
|
run(() => {
|
|
|
|
$input.val(`${currentUrl}${url}`).trigger('input');
|
|
|
|
});
|
|
|
|
run(() => {
|
|
|
|
$input.trigger('blur');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
testUrl('about');
|
|
|
|
testUrl('test/nested');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not add trailing slash on relative URL with [.?#]', function () {
|
|
|
|
let expectedUrl = '';
|
|
|
|
|
|
|
|
this.on('updateUrl', (url) => {
|
|
|
|
expect(url).to.equal(expectedUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.render(hbs `
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2016-02-03 18:47:13 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
let testUrl = (url) => {
|
|
|
|
expectedUrl = `/${url}`;
|
|
|
|
run(() => {
|
|
|
|
$input.val(`${currentUrl}${url}`).trigger('input');
|
|
|
|
});
|
|
|
|
run(() => {
|
|
|
|
$input.trigger('blur');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
testUrl('about#contact');
|
|
|
|
testUrl('test/nested.svg');
|
|
|
|
testUrl('test?gho=sties');
|
|
|
|
testUrl('test/nested?sli=mer');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not add trailing slash on non-relative URLs', function () {
|
|
|
|
let expectedUrl = '';
|
|
|
|
|
|
|
|
this.on('updateUrl', (url) => {
|
|
|
|
expect(url).to.equal(expectedUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.render(hbs `
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2016-02-03 18:47:13 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
let testUrl = (url) => {
|
|
|
|
expectedUrl = `/${url}`;
|
|
|
|
run(() => {
|
|
|
|
$input.val(`${currentUrl}${url}`).trigger('input');
|
|
|
|
});
|
|
|
|
run(() => {
|
|
|
|
$input.trigger('blur');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
testUrl('http://woo.ff/test');
|
|
|
|
testUrl('http://me.ow:2342/nested/test');
|
|
|
|
testUrl('https://wro.om/car#race');
|
|
|
|
testUrl('https://kabo.om/explosion?really=now');
|
|
|
|
});
|
|
|
|
|
2015-12-01 18:23:21 +03:00
|
|
|
describe('with sub-folder baseUrl', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.set('baseUrl', `${currentUrl}blog/`);
|
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
|
2015-12-01 18:23:21 +03:00
|
|
|
it('handles URLs relative to base url', function () {
|
|
|
|
let expectedUrl = '';
|
2015-09-16 20:02:06 +03:00
|
|
|
|
2015-12-01 18:23:21 +03:00
|
|
|
this.on('updateUrl', (url) => {
|
|
|
|
expect(url).to.equal(expectedUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.render(hbs `
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-12-01 18:23:21 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
let testUrl = (url) => {
|
|
|
|
expectedUrl = url;
|
|
|
|
run(() => {
|
|
|
|
$input.val(`${currentUrl}blog${url}`).trigger('input');
|
|
|
|
});
|
|
|
|
run(() => {
|
|
|
|
$input.trigger('blur');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-02-03 18:47:13 +03:00
|
|
|
testUrl('/about/');
|
2015-12-01 18:23:21 +03:00
|
|
|
testUrl('/about#contact');
|
2016-02-03 18:47:13 +03:00
|
|
|
testUrl('/test/nested/');
|
2015-09-16 20:02:06 +03:00
|
|
|
});
|
|
|
|
|
2015-12-01 18:23:21 +03:00
|
|
|
it('handles URLs relative to base host', function () {
|
|
|
|
let expectedUrl = '';
|
2015-09-16 20:02:06 +03:00
|
|
|
|
2015-12-01 18:23:21 +03:00
|
|
|
this.on('updateUrl', (url) => {
|
|
|
|
expect(url).to.equal(expectedUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.render(hbs `
|
2016-02-09 20:16:18 +03:00
|
|
|
{{gh-navitem-url-input baseUrl=baseUrl url=url isNew=isNew change="updateUrl" clearErrors=(action "clearErrors")}}
|
2015-12-01 18:23:21 +03:00
|
|
|
`);
|
|
|
|
let $input = this.$('input');
|
|
|
|
|
|
|
|
let testUrl = (url) => {
|
|
|
|
expectedUrl = url;
|
|
|
|
run(() => {
|
|
|
|
$input.val(url).trigger('input');
|
|
|
|
});
|
|
|
|
run(() => {
|
|
|
|
$input.trigger('blur');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
testUrl(`http://${window.location.host}`);
|
|
|
|
testUrl(`https://${window.location.host}`);
|
|
|
|
testUrl(`http://${window.location.host}/`);
|
|
|
|
testUrl(`https://${window.location.host}/`);
|
|
|
|
testUrl(`http://${window.location.host}/test`);
|
|
|
|
testUrl(`https://${window.location.host}/test`);
|
|
|
|
testUrl(`http://${window.location.host}/#test`);
|
|
|
|
testUrl(`https://${window.location.host}/#test`);
|
|
|
|
testUrl(`http://${window.location.host}/another/folder`);
|
|
|
|
testUrl(`https://${window.location.host}/another/folder`);
|
2015-10-28 14:36:45 +03:00
|
|
|
});
|
2015-09-16 20:02:06 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|