Fix highlighting of current user in contributor list

Fixes #72

Introduces a helper to determine if a contributor is the current user.
This commit is contained in:
2019-04-03 01:34:39 +02:00
parent 2954955e39
commit 88be3525b5
4 changed files with 56 additions and 5 deletions
@@ -0,0 +1,38 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Helper | is-current-user', function (hooks) {
setupTest(hooks);
test('should be true if the given contributor is the current user', function (assert) {
const kredits = this.owner.lookup('service:kredits');
const currentUser = {
account: '0xD4264570B12dA659Ee4BBd41c3509B7b1F9c23AC'
}
kredits.set('currentUser', currentUser);
const contributor = {
account: '0xD4264570B12dA659Ee4BBd41c3509B7b1F9c23AC'
}
const isCurrentUser = this.owner.factoryFor('helper:is-current-user').create();
assert.ok(isCurrentUser.compute([contributor]));
});
test('should be false if the given contributor is not the current user', function (assert) {
const kredits = this.owner.lookup('service:kredits');
const currentUser = {
account: '0xD4264570B12dA659Ee4BBd41c3509B7b1F9c23AC'
}
kredits.set('currentUser', currentUser);
const contributor = {
account: '0xA4264570B12dA659Ee4BBd51c3509B7b1F9c23AC'
}
const isCurrentUser = this.owner.factoryFor('helper:is-current-user').create();
assert.notOk(isCurrentUser.compute([contributor]));
});
});