datahub/wherehows-web/tests/unit/components/dataset-aclaccess-test.js
Lee f0e970b465 Request merge ACL page to master (#930)
* finish the alc access page layout, logics and sass files

* Fix css issue and request permission response error message

* finish the testing part

* simplify code finished

* finish spinner

* Finished ACL access page, testing cases, clean code format

* Clean format, address comments, refactor JS code of ACL page to TS

* address comments, replace type any and fix merge issue
2018-02-07 12:32:03 -08:00

36 lines
1.1 KiB
JavaScript

import { moduleForComponent, test } from 'ember-qunit';
import Notifications from 'wherehows-web/services/notifications';
import { accessState } from 'wherehows-web/constants/dataset-aclaccess';
import { accessInfoTesting as accessInfo } from 'wherehows-web/mirage/helpers/aclauth';
moduleForComponent('dataset-aclaccess', 'Unit | Component | dataset aclaccess', {
unit: true,
needs: ['component:empty-state'],
beforeEach() {
this.register('service:notifications', Notifications);
}
});
test('should return the pageSate and users correctly', function(assert) {
const aclaccess = this.subject();
const approved = accessInfo(true);
aclaccess.set('accessInfo', approved);
assert.equal(aclaccess.get('pageState'), 'hasAccess', 'pageState without errors');
assert.ok(aclaccess.get('users'), 'users existed');
});
test('should return state correctly', function(assert) {
const aclaccess = this.subject();
aclaccess.setProperties({
pageState: 'noAccess',
currentUser: 'Abc'
});
assert.equal(aclaccess.get('state').info, accessState('Abc').noAccess.info, 'pageState without errors');
});