62553cdf92
no issue - adds `gh-image-uploader` that handles image uploads in a fully ember fashion and with no dependency on `uploader.js` - adds `gh-image-uploader-with-preview` that can fully replace the old `gh-uploader` - replace uses of `gh-uploader` in PSM & TSM with `gh-image-uploader-with-preview` - updates the editor preview image handling to use the new `gh-image-uploader-with-preview` component - updates the image upload modal to use `gh-image-uploader` (utilises the `saveButton=false` flag which means the preview has to be handled externally to avoid auto-replacement when typing a URL) - removes all old `uploader.js` related code - adds custom `RequestEntityTooLargeError` and `UnsupportedMediaTypeError` errors to our `ajax` service
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
/* jshint expr:true */
|
|
import { expect } from 'chai';
|
|
import {
|
|
describeComponent,
|
|
it
|
|
} from 'ember-mocha';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import Ember from 'ember';
|
|
import sinon from 'sinon';
|
|
|
|
const {run} = Ember;
|
|
|
|
describeComponent(
|
|
'gh-image-uploader-with-preview',
|
|
'Integration: Component: gh-image-uploader-with-preview',
|
|
{
|
|
integration: true
|
|
},
|
|
function() {
|
|
it('renders image if provided', function() {
|
|
this.set('image', 'http://example.com/test.png');
|
|
|
|
this.render(hbs`{{gh-image-uploader-with-preview image=image}}`);
|
|
|
|
expect(this.$('.gh-image-uploader.--with-image').length).to.equal(1);
|
|
expect(this.$('img').attr('src')).to.equal('http://example.com/test.png');
|
|
});
|
|
|
|
it('renders upload form when no image provided', function () {
|
|
this.render(hbs`{{gh-image-uploader-with-preview image=image}}`);
|
|
|
|
expect(this.$('input[type="file"]').length).to.equal(1);
|
|
});
|
|
|
|
it('triggers remove action when delete icon is clicked', function () {
|
|
let remove = sinon.spy();
|
|
this.set('remove', remove);
|
|
this.set('image', 'http://example.com/test.png');
|
|
|
|
this.render(hbs`{{gh-image-uploader-with-preview image=image remove=remove}}`);
|
|
run(() => {
|
|
this.$('.icon-trash').click();
|
|
});
|
|
|
|
expect(remove.calledOnce).to.be.true;
|
|
});
|
|
}
|
|
);
|