Skip to content

Commit

Permalink
Refactor admin settings index unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Jan 4, 2023
1 parent dd7ece0 commit a2652d9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
22 changes: 0 additions & 22 deletions packages/web-app-admin-settings/tests/unit/index.spec.js

This file was deleted.

31 changes: 31 additions & 0 deletions packages/web-app-admin-settings/tests/unit/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import index from '../../src/index'

describe('navItems', () => {
beforeEach(() => {
;(window as any).Vue = {}
})
describe('user management', () => {
it.each([true, false])('should be enabled according to the permissions', (enabled) => {
;(window as any).Vue.$permissionManager = {
hasUserManagement: () => enabled
}
expect(index.navItems.find((n) => n.name === 'Users').enabled()).toBe(enabled)
})
})
describe('group management', () => {
it.each([true, false])('should be enabled according to the permissions', (enabled) => {
;(window as any).Vue.$permissionManager = {
hasUserManagement: () => enabled
}
expect(index.navItems.find((n) => n.name === 'Groups').enabled()).toBe(enabled)
})
})
describe('space management', () => {
it.each([true, false])('should be enabled according to the permissions', (enabled) => {
;(window as any).Vue.$permissionManager = {
hasSpaceManagement: () => enabled
}
expect(index.navItems.find((n) => n.name === 'Spaces').enabled()).toBe(enabled)
})
})
})

0 comments on commit a2652d9

Please sign in to comment.