DEV: Add test for avatar-uploader (#15633)

Follow up to 64b089072a.
This commit is contained in:
Dan Ungureanu 2022-01-21 19:51:24 +02:00 committed by GitHub
parent d0f4f408af
commit 984089c94a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import pretender from "discourse/tests/helpers/create-pretender";
import {
createFile,
discourseModule,
} from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
discourseModule("Integration | Component | avatar-uploader", function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
pretender.post("/uploads.json", () => {
return [200, { "Content-Type": "application/json" }, {}];
});
});
componentTest("default", {
template: hbs`{{avatar-uploader
id="avatar-uploader"
done=done
}}`,
async test(assert) {
const done = assert.async();
this.set("done", () => {
assert.ok(true, "action is called after avatar is uploaded");
done();
});
await this.container
.lookup("service:app-events")
.trigger("upload-mixin:avatar-uploader:add-files", [
createFile("avatar.png"),
]);
},
});
});