Ghost/ghost/admin/tests/unit/components/gh-url-preview-test.js

39 lines
1.0 KiB
JavaScript
Raw Normal View History

2016-11-24 01:50:57 +03:00
import {describe, it} from 'mocha';
import {setupComponentTest} from 'ember-mocha';
2015-02-18 23:02:48 +03:00
2016-11-24 01:50:57 +03:00
describe('Unit: Component: gh-url-preview', function () {
setupComponentTest('gh-url-preview', {
2017-03-29 01:22:02 +03:00
unit: true,
needs: ['service:config']
2016-11-24 01:50:57 +03:00
});
2015-02-18 23:02:48 +03:00
2016-11-24 01:50:57 +03:00
it('generates the correct preview URL with a prefix', function () {
let component = this.subject({
prefix: 'tag',
slug: 'test-slug',
tagName: 'p',
classNames: 'test-class',
2015-02-18 23:02:48 +03:00
2016-11-24 01:50:57 +03:00
config: {blogUrl: 'http://my-ghost-blog.com'}
2015-02-18 23:02:48 +03:00
});
2016-11-24 01:50:57 +03:00
this.render();
2015-02-18 23:02:48 +03:00
2016-11-24 01:50:57 +03:00
expect(component.get('url')).to.equal('my-ghost-blog.com/tag/test-slug/');
});
2015-02-18 23:02:48 +03:00
2016-11-24 01:50:57 +03:00
it('generates the correct preview URL without a prefix', function () {
let component = this.subject({
slug: 'test-slug',
tagName: 'p',
classNames: 'test-class',
2015-02-18 23:02:48 +03:00
2016-11-24 01:50:57 +03:00
config: {blogUrl: 'http://my-ghost-blog.com'}
2015-02-18 23:02:48 +03:00
});
2016-11-24 01:50:57 +03:00
this.render();
expect(component.get('url')).to.equal('my-ghost-blog.com/test-slug/');
});
});