open-vault/ui/tests/helpers/components/sidebar-nav.js
hc-github-team-secure-vault-core 5a6be772eb
backport of commit 52baf01e5352968d623502a4f49dbda12a4dc322 (#21580)
Co-authored-by: Jordan Reimer <zofskeez@gmail.com>
2023-07-05 10:16:02 -06:00

28 lines
885 B
JavaScript

import { allFeatures } from 'vault/helpers/all-features';
import sinon from 'sinon';
export const stubFeaturesAndPermissions = (owner, isEnterprise = false, setCluster = false) => {
const permissions = owner.lookup('service:permissions');
const hasNavPermission = sinon.stub(permissions, 'hasNavPermission');
hasNavPermission.returns(true);
sinon.stub(permissions, 'navPathParams');
const version = owner.lookup('service:version');
const features = sinon.stub(version, 'features');
features.value(allFeatures());
sinon.stub(version, 'isEnterprise').value(isEnterprise);
const auth = owner.lookup('service:auth');
sinon.stub(auth, 'authData').value({});
if (setCluster) {
owner.lookup('service:currentCluster').setCluster({
id: 'foo',
anyReplicationEnabled: true,
usingRaft: true,
});
}
return { hasNavPermission, features };
};