Skip to content

Commit

Permalink
Replace the Upload Handler
Browse files Browse the repository at this point in the history
This import requires us to be using ember-cli-mirage and we aren't
anymore. Plus we were barely using it here and can just as easily check
these values ourselves.
  • Loading branch information
jrjohnson committed Jul 16, 2024
1 parent 4caa2e4 commit 317e9a5
Showing 1 changed file with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { module, test } from 'qunit';
import { setupRenderingTest } from 'test-app/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { uploadHandler } from 'ember-file-upload';
import { selectFiles } from 'ember-file-upload/test-support';
import { setupMirage } from 'test-app/tests/test-support/mirage';
import Service from '@ember/service';
Expand All @@ -13,29 +12,27 @@ module('Integration | Component | learning-material-uploader', function (hooks)
setupMirage(hooks);

test('upload file', async function (assert) {
assert.expect(4);
assert.expect(5);
const iliosConfigMock = Service.extend({
async getMaxUploadSize() {
return 1000;
},
});
this.owner.register('service:iliosConfig', iliosConfigMock);

this.server.post(
'/upload',
uploadHandler(function (db, request) {
const { name } = request.requestBody.file;
assert.strictEqual(name, 'test.file');
return new Response(
200,
{},
{
filename: 'test.file',
fileHash: '1234',
},
);
}),
);
this.server.post('/upload', (schema, request) => {
assert.ok(request.requestBody.has('file'));
const file = request.requestBody.get('file');
assert.strictEqual(file.name, 'test.file');
return new Response(
200,
{},
{
filename: 'test.file',
fileHash: '1234',
},
);
});
let filename = null;
let fileHash = null;

Expand Down

0 comments on commit 317e9a5

Please sign in to comment.