👨🏻‍💻👩🏻‍💻 Use Ant Design like a Pro!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

64 lines
1.5 KiB

import { describe, expect, it } from 'vitest';
import access from './access';
describe('access', () => {
it('should return canAdmin true when user has admin access', () => {
const initialState = {
currentUser: {
userid: '1',
name: 'Admin User',
avatar: 'https://example.com/avatar.png',
access: 'admin',
},
};
const result = access(initialState);
expect(result.canAdmin).toBe(true);
});
it('should return canAdmin false when user has non-admin access', () => {
const initialState = {
currentUser: {
userid: '2',
name: 'Regular User',
avatar: 'https://example.com/avatar.png',
access: 'user',
},
};
const result = access(initialState);
expect(result.canAdmin).toBe(false);
});
it('should return canAdmin false when user access is undefined', () => {
const initialState = {
currentUser: {
userid: '3',
name: 'Guest User',
avatar: 'https://example.com/avatar.png',
},
};
const result = access(initialState);
expect(result.canAdmin).toBe(false);
});
it('should return canAdmin false when currentUser is undefined', () => {
const initialState = {
currentUser: undefined,
};
const result = access(initialState);
expect(result.canAdmin).toBeFalsy();
});
it('should return canAdmin false when initialState is undefined', () => {
const result = access(undefined);
expect(result.canAdmin).toBeFalsy();
});
});