mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +03:00
5b43350112
no issue - cleans up multiple CPs that were only outputting a background image style - moves URL decoding/encoding and `htmlSafe` output into one place
40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
import hbs from 'htmlbars-inline-precompile';
|
|
import {describe, it} from 'mocha';
|
|
import {expect} from 'chai';
|
|
import {setupComponentTest} from 'ember-mocha';
|
|
|
|
describe('Integration: Helper: background-image-style', function () {
|
|
setupComponentTest('background-image-style', {
|
|
integration: true
|
|
});
|
|
|
|
it('renders', function () {
|
|
this.render(hbs`{{background-image-style "test.png"}}`);
|
|
expect(this.$().text().trim()).to.equal('background-image: url(test.png);');
|
|
});
|
|
|
|
it('escapes URLs', function () {
|
|
this.render(hbs`{{background-image-style "test image.png"}}`);
|
|
expect(this.$().text().trim()).to.equal('background-image: url(test%20image.png);');
|
|
});
|
|
|
|
it('handles already escaped URLs', function () {
|
|
this.render(hbs`{{background-image-style "test%20image.png"}}`);
|
|
expect(this.$().text().trim()).to.equal('background-image: url(test%20image.png);');
|
|
});
|
|
|
|
it('handles empty URLs', function () {
|
|
this.set('testImage', undefined);
|
|
this.render(hbs`{{background-image-style testImage}}`);
|
|
expect(this.$().text().trim(), 'undefined').to.equal('');
|
|
|
|
this.set('testImage', null);
|
|
this.render(hbs`{{background-image-style testImage}}`);
|
|
expect(this.$().text().trim(), 'null').to.equal('');
|
|
|
|
this.set('testImage', '');
|
|
this.render(hbs`{{background-image-style testImage}}`);
|
|
expect(this.$().text().trim(), 'blank').to.equal('');
|
|
});
|
|
});
|