-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1127 from aneoconsulting/tests/profile-page
test: profile page
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { User } from '@aneoconsultingfr/armonik.api.angular'; | ||
import { TestBed } from '@angular/core/testing'; | ||
import { IconsService } from '@services/icons.service'; | ||
import { ShareUrlService } from '@services/share-url.service'; | ||
import { UserService } from '@services/user.service'; | ||
import { IndexComponent } from './index.component'; | ||
import { PermissionGroup } from './types'; | ||
|
||
describe('IndexComponent', () => { | ||
let component: IndexComponent; | ||
|
||
const returnedUrl = 'some-url'; | ||
const mockShareUrlService = { | ||
generateSharableURL: jest.fn(() => returnedUrl), | ||
}; | ||
|
||
const user: User.AsObject = { | ||
username: 'ArmoniK', | ||
permissions: ['Sessions:list', 'Sessions:get', 'Sessions:cancel', 'Tasks:list'], | ||
roles: ['Operator', 'User'] | ||
}; | ||
|
||
const mockUserService = { | ||
user: user | ||
}; | ||
|
||
beforeEach(() => { | ||
component = TestBed.configureTestingModule({ | ||
providers: [ | ||
IndexComponent, | ||
{ provide: ShareUrlService, useValue: mockShareUrlService }, | ||
{ provide: UserService, useValue: mockUserService }, | ||
IconsService | ||
] | ||
}).inject(IndexComponent); | ||
component.ngOnInit(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeDefined(); | ||
}); | ||
|
||
describe('Initialisation', () => { | ||
it('should init the sharableUrl', () => { | ||
expect(component.sharableURL).toBe(returnedUrl); | ||
}); | ||
}); | ||
|
||
it('should allows to get user', () => { | ||
expect(component.user).toBe(user); | ||
}); | ||
|
||
it('should get Icons', () => { | ||
expect(component.getIcon('profile')).toEqual('account_circle'); | ||
}); | ||
|
||
it('should group permissions', () => { | ||
expect(component.groupedPermissions()).toEqual<PermissionGroup[]>([ | ||
{ | ||
name: 'sessions', | ||
permissions: [ | ||
'list', 'get', 'cancel' | ||
] | ||
}, | ||
{ | ||
name: 'tasks', | ||
permissions: [ | ||
'list' | ||
] | ||
} | ||
]); | ||
}); | ||
}); |
c67892e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JUnit
Files coverage (99%)