Ghost/ghost/admin/tests/integration/helpers/background-image-style-test.js
Kevin Ansfield 5b43350112 Add {{background-image-style}} helper
no issue
- cleans up multiple CPs that were only outputting a background image style
- moves URL decoding/encoding and `htmlSafe` output into one place
2018-05-14 13:04:53 +01:00

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('');
});
});