discourse/test/javascripts/controllers/avatar-selector-test.js.es6

42 lines
1006 B
Plaintext
Raw Normal View History

2018-06-15 11:03:24 -04:00
import { mapRoutes } from "discourse/mapping-router";
2016-11-08 14:29:50 -05:00
2014-07-30 17:53:14 -04:00
moduleFor("controller:avatar-selector", "controller:avatar-selector", {
2017-06-14 13:57:58 -04:00
beforeEach() {
2018-06-15 11:03:24 -04:00
this.registry.register("router:main", mapRoutes());
2016-11-08 14:29:50 -05:00
},
2018-06-15 11:03:24 -04:00
needs: ["controller:modal"]
2014-07-30 17:53:14 -04:00
});
2017-06-14 13:57:58 -04:00
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
}
});
2018-06-15 11:03:24 -04:00
assert.equal(
avatarSelectorController.get("selectedUploadId"),
1,
"we are using system by default"
);
2018-06-15 11:03:24 -04:00
avatarSelectorController.set("selected", "gravatar");
assert.equal(
avatarSelectorController.get("selectedUploadId"),
2,
"we are using gravatar when set"
);
avatarSelectorController.set("selected", "custom");
2018-06-15 11:03:24 -04:00
assert.equal(
avatarSelectorController.get("selectedUploadId"),
3,
"we are using custom when set"
);
});