2018-05-14 15:04:53 +03:00
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
import {describe, it} from 'mocha';
|
|
|
|
import {expect} from 'chai';
|
2019-01-02 12:58:55 +03:00
|
|
|
import {render} from '@ember/test-helpers';
|
|
|
|
import {setupRenderingTest} from 'ember-mocha';
|
2018-05-14 15:04:53 +03:00
|
|
|
|
|
|
|
describe('Integration: Helper: background-image-style', function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
setupRenderingTest();
|
2018-05-14 15:04:53 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
it('renders', async function () {
|
|
|
|
await render(hbs`{{background-image-style "test.png"}}`);
|
|
|
|
expect(this.element).to.have.trimmed.text('background-image: url(test.png);');
|
2018-05-14 15:04:53 +03:00
|
|
|
});
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
it('escapes URLs', async function () {
|
|
|
|
await render(hbs`{{background-image-style "test image.png"}}`);
|
|
|
|
expect(this.element).to.have.trimmed.text('background-image: url(test%20image.png);');
|
2018-05-14 15:04:53 +03:00
|
|
|
});
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
it('handles already escaped URLs', async function () {
|
|
|
|
await render(hbs`{{background-image-style "test%20image.png"}}`);
|
|
|
|
expect(this.element).to.have.trimmed.text('background-image: url(test%20image.png);');
|
2018-05-14 15:04:53 +03:00
|
|
|
});
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
it('handles empty URLs', async function () {
|
2018-05-14 15:04:53 +03:00
|
|
|
this.set('testImage', undefined);
|
2019-01-02 12:58:55 +03:00
|
|
|
await render(hbs`{{background-image-style testImage}}`);
|
|
|
|
expect(this.element, 'undefined').to.have.trimmed.text('');
|
2018-05-14 15:04:53 +03:00
|
|
|
|
|
|
|
this.set('testImage', null);
|
2019-01-02 12:58:55 +03:00
|
|
|
await render(hbs`{{background-image-style testImage}}`);
|
|
|
|
expect(this.element, 'null').to.have.trimmed.text('');
|
2018-05-14 15:04:53 +03:00
|
|
|
|
|
|
|
this.set('testImage', '');
|
2019-01-02 12:58:55 +03:00
|
|
|
await render(hbs`{{background-image-style testImage}}`);
|
|
|
|
expect(this.element, 'blank').to.have.trimmed.text('');
|
2018-05-14 15:04:53 +03:00
|
|
|
});
|
|
|
|
});
|