mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
parent
0659300a23
commit
00ede73105
@ -19,7 +19,7 @@ export default Ember.TextField.extend({
|
||||
|
||||
// if we have a relative url, create the absolute url to be displayed in the input
|
||||
// if (this.get('isRelative')) {
|
||||
if (!validator.isURL(url) && this.get('value').indexOf('mailto:') !== 0) {
|
||||
if (!validator.isURL(url) && url.indexOf('mailto:') !== 0) {
|
||||
url = joinUrlParts(baseUrl, url);
|
||||
}
|
||||
|
||||
|
103
ghost/admin/tests/unit/components/gh-navitem-url-input-test.js
Normal file
103
ghost/admin/tests/unit/components/gh-navitem-url-input-test.js
Normal file
@ -0,0 +1,103 @@
|
||||
/* jshint expr:true */
|
||||
import Ember from 'ember';
|
||||
import {expect} from 'chai';
|
||||
import {
|
||||
describeComponent,
|
||||
it
|
||||
} from 'ember-mocha';
|
||||
|
||||
describeComponent(
|
||||
'gh-navitem-url-input',
|
||||
'GhNavitemUrlInputComponent',
|
||||
{},
|
||||
function () {
|
||||
it('renders', function () {
|
||||
var component = this.subject();
|
||||
|
||||
expect(component._state).to.equal('preRender');
|
||||
|
||||
this.render();
|
||||
|
||||
expect(component._state).to.equal('inDOM');
|
||||
});
|
||||
|
||||
it('renders correctly with a URL that matches the base URL', function () {
|
||||
var component = this.subject({
|
||||
baseUrl: 'http://example.com/'
|
||||
});
|
||||
|
||||
Ember.run(function () {
|
||||
component.set('value', 'http://example.com/');
|
||||
});
|
||||
|
||||
this.render();
|
||||
|
||||
expect(this.$().val()).to.equal('http://example.com/');
|
||||
});
|
||||
|
||||
it('renders correctly with a relative URL', function () {
|
||||
var component = this.subject({
|
||||
baseUrl: 'http://example.com/'
|
||||
});
|
||||
|
||||
Ember.run(function () {
|
||||
component.set('value', '/go/docs');
|
||||
});
|
||||
|
||||
this.render();
|
||||
|
||||
expect(this.$().val()).to.equal('/go/docs');
|
||||
});
|
||||
|
||||
it('renders correctly with a mailto URL', function () {
|
||||
var component = this.subject({
|
||||
baseUrl: 'http://example.com/'
|
||||
});
|
||||
|
||||
Ember.run(function () {
|
||||
component.set('value', 'mailto:someone@example.com');
|
||||
});
|
||||
|
||||
this.render();
|
||||
|
||||
expect(this.$().val()).to.equal('mailto:someone@example.com');
|
||||
});
|
||||
|
||||
it('identifies a URL as relative', function () {
|
||||
var component = this.subject({
|
||||
baseUrl: 'http://example.com/',
|
||||
url: '/go/docs'
|
||||
});
|
||||
|
||||
this.render();
|
||||
|
||||
expect(component.get('isRelative')).to.be.ok;
|
||||
|
||||
Ember.run(function () {
|
||||
component.set('value', 'http://example.com/go/docs');
|
||||
});
|
||||
|
||||
expect(component.get('isRelative')).to.not.be.ok;
|
||||
});
|
||||
|
||||
it('identifies a URL as the base URL', function () {
|
||||
var component = this.subject({
|
||||
baseUrl: 'http://example.com/'
|
||||
});
|
||||
|
||||
this.render();
|
||||
|
||||
Ember.run(function () {
|
||||
component.set('value', 'http://example.com/');
|
||||
});
|
||||
|
||||
expect(component.get('isBaseUrl')).to.be.ok;
|
||||
|
||||
Ember.run(function () {
|
||||
component.set('value', 'http://example.com/go/');
|
||||
});
|
||||
|
||||
expect(component.get('isBaseUrl')).to.not.be.ok;
|
||||
});
|
||||
}
|
||||
);
|
Loading…
Reference in New Issue
Block a user