2016-12-15 16:52:47 +08:00
|
|
|
moduleFor('component:group-membership-button');
|
2016-12-07 12:06:56 +08:00
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test('canJoinGroup', function(assert) {
|
2016-12-07 12:06:56 +08:00
|
|
|
this.subject().setProperties({
|
|
|
|
model: { public: false }
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(this.subject().get("canJoinGroup"), false, "non public group cannot be joined");
|
2016-12-07 12:06:56 +08:00
|
|
|
|
|
|
|
this.subject().set("model.public", true);
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(this.subject().get("canJoinGroup"), true, "public group can be joined");
|
2016-12-07 12:06:56 +08:00
|
|
|
|
|
|
|
this.subject().setProperties({ currentUser: null, model: { public: true } });
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(this.subject().get("canJoinGroup"), true, "can't join group when not logged in");
|
2016-12-07 12:06:56 +08:00
|
|
|
});
|
2016-12-12 22:46:45 +08:00
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
QUnit.test('userIsGroupUser', function(assert) {
|
2017-01-03 14:36:56 +08:00
|
|
|
this.subject().setProperties({
|
|
|
|
model: { is_group_user: true }
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(this.subject().get('userIsGroupUser'), true);
|
2017-01-03 14:36:56 +08:00
|
|
|
|
|
|
|
this.subject().set('model.is_group_user', false);
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(this.subject().get('userIsGroupUser'), false);
|
2017-01-03 14:36:56 +08:00
|
|
|
|
|
|
|
this.subject().setProperties({ model: { id: 1 }, groupUserIds: [1] });
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(this.subject().get('userIsGroupUser'), true);
|
2017-01-03 14:36:56 +08:00
|
|
|
|
|
|
|
this.subject().set('groupUserIds', [3]);
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(this.subject().get('userIsGroupUser'), false);
|
2017-01-03 14:36:56 +08:00
|
|
|
|
|
|
|
this.subject().set('groupUserIds', undefined);
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(this.subject().get('userIsGroupUser'), false);
|
2017-03-16 11:33:55 +08:00
|
|
|
|
|
|
|
this.subject().setProperties({
|
|
|
|
groupUserIds: [1, 3],
|
|
|
|
model: { id: 1, is_group_user: false }
|
|
|
|
});
|
|
|
|
|
2017-06-15 01:57:58 +08:00
|
|
|
assert.equal(this.subject().get('userIsGroupUser'), false);
|
2017-01-03 14:36:56 +08:00
|
|
|
});
|