ea9c8c03fe
refs https://github.com/TryGhost/Ghost/pull/15550 Pulled out of the rolled up node+ember-js+ember-template rollup linter update PR as it required fairly extensive changes. - bumped package - renamed `no-down-event-binding` to `no-pointer-down-event-binding` - disabled `no-pointer-down-event-binding` rule - disabled `no-triple-curlies` rule - ran `yarn lint:hbs --fix` - updated integration tests to match Octane syntax - fixed various one-off errors - updated .lint-todo
39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
import hbs from 'htmlbars-inline-precompile';
|
|
import sinon from 'sinon';
|
|
import {click, find, findAll, render} from '@ember/test-helpers';
|
|
import {describe, it} from 'mocha';
|
|
import {expect} from 'chai';
|
|
import {setupRenderingTest} from 'ember-mocha';
|
|
|
|
describe('Integration: Component: gh-image-uploader-with-preview', function () {
|
|
setupRenderingTest();
|
|
|
|
it('renders image if provided', async function () {
|
|
let remove = sinon.spy();
|
|
this.set('remove', remove);
|
|
this.set('image', 'http://example.com/test.png');
|
|
|
|
await render(hbs`<GhImageUploaderWithPreview @image={{this.image}} @remove={{this.remove}} />`);
|
|
|
|
expect(findAll('.gh-image-uploader.-with-image').length).to.equal(1);
|
|
expect(find('img').getAttribute('src')).to.equal('http://example.com/test.png');
|
|
});
|
|
|
|
it('renders upload form when no image provided', async function () {
|
|
await render(hbs`<GhImageUploaderWithPreview @image={{this.image}} />`);
|
|
|
|
expect(findAll('input[type="file"]').length).to.equal(1);
|
|
});
|
|
|
|
it('triggers remove action when delete icon is clicked', async function () {
|
|
let remove = sinon.spy();
|
|
this.set('remove', remove);
|
|
this.set('image', 'http://example.com/test.png');
|
|
|
|
await render(hbs`<GhImageUploaderWithPreview @image={{this.image}} @remove={{this.remove}} />`);
|
|
await click('.image-delete');
|
|
|
|
expect(remove.calledOnce).to.be.true;
|
|
});
|
|
});
|