cartodb-4.42/lib/assets/test/spec/new-dashboard/unit/specs/components/UserDropdown.spec.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
import { mount } from '@vue/test-utils';
import UserDropdown from 'new-dashboard/components/NavigationBar/UserDropdown';
const $t = key => key;
describe('UserDropdown.vue', () => {
let user;
beforeEach(() => {
user = {
avatar_url: '//cartodb-libs.global.ssl.fastly.net/cartodbui/assets/unversioned/images/avatars/avatar_ghost_yellow.png',
username: 'Test user',
email: 'user@test.com'
};
});
it('should render dropdown open with notifications badge', () => {
const userDropdown = mount(UserDropdown, {
propsData: {
userModel: user,
notificationsCount: 2
},
mocks: { $t }
});
expect(userDropdown).toMatchSnapshot();
});
it('should render dropdown closed', () => {
const userDropdown = mount(UserDropdown, {
propsData: {
open: true,
userModel: user,
notificationsCount: 0
},
mocks: { $t }
});
expect(userDropdown).toMatchSnapshot();
});
it('should render organization link if user is org_admin', () => {
const overridenUser = {
...user,
org_admin: true
};
const userDropdown = mount(UserDropdown, {
propsData: {
open: true,
userModel: overridenUser,
notificationsCount: 0
},
mocks: { $t }
});
expect(userDropdown).toMatchSnapshot();
});
});