This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/unit/controllers/avatar-selector-test.js
Robin Ward 23f24bfb51 REFACTOR: Move javascript tests inside discourse app
This is where they should be as far as ember is concerned. Note this is
a huge commit and we should be really careful everything continues to
work properly.
2020-10-02 11:29:36 -04:00

42 lines
1010 B
JavaScript

import { mapRoutes } from "discourse/mapping-router";
moduleFor("controller:avatar-selector", "controller:avatar-selector", {
beforeEach() {
this.registry.register("router:main", mapRoutes());
},
needs: ["controller:modal"],
});
QUnit.test("avatarTemplate", function (assert) {
const avatarSelectorController = this.subject();
avatarSelectorController.setProperties({
selected: "system",
user: {
system_avatar_upload_id: 1,
gravatar_avatar_upload_id: 2,
custom_avatar_upload_id: 3,
},
});
assert.equal(
avatarSelectorController.get("selectedUploadId"),
1,
"we are using system by default"
);
avatarSelectorController.set("selected", "gravatar");
assert.equal(
avatarSelectorController.get("selectedUploadId"),
2,
"we are using gravatar when set"
);
avatarSelectorController.set("selected", "custom");
assert.equal(
avatarSelectorController.get("selectedUploadId"),
3,
"we are using custom when set"
);
});