2018-06-15 11:03:24 -04:00
|
|
|
moduleFor("component:group-membership-button");
|
2016-12-06 23:06:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
QUnit.test("canJoinGroup", function(assert) {
|
2016-12-06 23:06:56 -05:00
|
|
|
this.subject().setProperties({
|
2017-07-27 22:37:10 -04:00
|
|
|
model: { public_admission: false, is_group_user: true }
|
2016-12-06 23:06:56 -05:00
|
|
|
});
|
|
|
|
|
2017-07-27 22:37:10 -04:00
|
|
|
assert.equal(
|
2018-06-15 11:03:24 -04:00
|
|
|
this.subject().get("canJoinGroup"),
|
|
|
|
false,
|
2017-07-27 22:37:10 -04:00
|
|
|
"can't join group if public_admission is false"
|
|
|
|
);
|
2016-12-06 23:06:56 -05:00
|
|
|
|
2017-07-27 22:37:10 -04:00
|
|
|
this.subject().set("model.public_admission", true);
|
2016-12-06 23:06:56 -05:00
|
|
|
|
2017-07-27 22:37:10 -04:00
|
|
|
assert.equal(
|
2018-06-15 11:03:24 -04:00
|
|
|
this.subject().get("canJoinGroup"),
|
|
|
|
false,
|
2017-07-27 22:37:10 -04:00
|
|
|
"can't join group if user is already in the group"
|
|
|
|
);
|
2016-12-06 23:06:56 -05:00
|
|
|
|
2017-07-27 22:37:10 -04:00
|
|
|
this.subject().set("model.is_group_user", false);
|
2016-12-06 23:06:56 -05:00
|
|
|
|
2017-07-27 22:37:10 -04:00
|
|
|
assert.equal(
|
2018-06-15 11:03:24 -04:00
|
|
|
this.subject().get("canJoinGroup"),
|
|
|
|
true,
|
2017-07-27 22:37:10 -04:00
|
|
|
"allowed to join group"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
QUnit.test("canLeaveGroup", function(assert) {
|
2017-07-27 22:37:10 -04:00
|
|
|
this.subject().setProperties({
|
|
|
|
model: { public_exit: false, is_group_user: false }
|
|
|
|
});
|
|
|
|
|
|
|
|
assert.equal(
|
2018-06-15 11:03:24 -04:00
|
|
|
this.subject().get("canLeaveGroup"),
|
|
|
|
false,
|
2017-07-27 22:37:10 -04:00
|
|
|
"can't leave group if public_exit is false"
|
|
|
|
);
|
|
|
|
|
|
|
|
this.subject().set("model.public_exit", true);
|
|
|
|
|
|
|
|
assert.equal(
|
2018-06-15 11:03:24 -04:00
|
|
|
this.subject().get("canLeaveGroup"),
|
|
|
|
false,
|
2017-07-27 22:37:10 -04:00
|
|
|
"can't leave group if user is not in the group"
|
|
|
|
);
|
|
|
|
|
|
|
|
this.subject().set("model.is_group_user", true);
|
|
|
|
|
|
|
|
assert.equal(
|
2018-06-15 11:03:24 -04:00
|
|
|
this.subject().get("canLeaveGroup"),
|
|
|
|
true,
|
2017-07-27 22:37:10 -04:00
|
|
|
"allowed to leave group"
|
|
|
|
);
|
2016-12-06 23:06:56 -05:00
|
|
|
});
|
2016-12-12 09:46:45 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
QUnit.test("userIsGroupUser", function(assert) {
|
2017-01-03 01:36:56 -05:00
|
|
|
this.subject().setProperties({
|
|
|
|
model: { is_group_user: true }
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(this.subject().get("userIsGroupUser"), true);
|
2017-01-03 01:36:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
this.subject().set("model.is_group_user", false);
|
2017-01-03 01:36:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(this.subject().get("userIsGroupUser"), false);
|
2017-01-03 01:36:56 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
this.subject().set("model.is_group_user", null);
|
2017-03-15 23:33:55 -04:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(this.subject().get("userIsGroupUser"), false);
|
2017-01-03 01:36:56 -05:00
|
|
|
});
|