Fix frontend coverage
This commit is contained in:
parent
59d51f0942
commit
b7cac15901
@ -403,13 +403,16 @@ describe('AppFrameComponent', () => {
|
||||
const toastInfoSpy = jest.spyOn(toastService, 'showInfo')
|
||||
jest.spyOn(messagesService, 'get').mockReturnValue(
|
||||
of([
|
||||
{ level: 'warning', message: 'Test warning', tags: '' },
|
||||
{ level: 'error', message: 'Test error', tags: '' },
|
||||
{ level: 'success', message: 'Test success', tags: '' },
|
||||
{ level: 'info', message: 'Test info', tags: '' },
|
||||
{ level: 'debug', message: 'Test debug', tags: '' },
|
||||
])
|
||||
)
|
||||
component.ngOnInit()
|
||||
httpTestingController.expectOne(`${environment.apiBaseUrl}messages/`)
|
||||
expect(toastErrorSpy).toHaveBeenCalled()
|
||||
expect(toastInfoSpy).toHaveBeenCalled()
|
||||
expect(toastErrorSpy).toHaveBeenCalledTimes(2)
|
||||
expect(toastInfoSpy).toHaveBeenCalledTimes(3)
|
||||
})
|
||||
})
|
||||
|
@ -267,28 +267,26 @@ describe('ProfileEditDialogComponent', () => {
|
||||
expect(getProvidersSpy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should remove disconnected social account from component', async () => {
|
||||
it('should remove disconnected social account from component, show error if needed', async () => {
|
||||
const disconnectSpy = jest.spyOn(profileService, 'disconnectSocialAccount')
|
||||
disconnectSpy.mockReturnValue(of(socialAccount.id))
|
||||
|
||||
let resolve
|
||||
const p = new Promise((r) => (resolve = r))
|
||||
|
||||
const getSpy = jest.spyOn(profileService, 'get')
|
||||
getSpy.mockImplementation(() => {
|
||||
resolve()
|
||||
return of(profile)
|
||||
})
|
||||
|
||||
getSpy.mockImplementation(() => of(profile))
|
||||
component.ngOnInit()
|
||||
|
||||
await p
|
||||
const errorSpy = jest.spyOn(toastService, 'showError')
|
||||
|
||||
expect(getSpy).toHaveBeenCalled()
|
||||
expect(component.socialAccounts).toContainEqual(socialAccount)
|
||||
|
||||
// fail first
|
||||
disconnectSpy.mockReturnValueOnce(
|
||||
throwError(() => new Error('unable to disconnect'))
|
||||
)
|
||||
component.disconnectSocialAccount(socialAccount.id)
|
||||
expect(errorSpy).toHaveBeenCalled()
|
||||
|
||||
// succeed
|
||||
disconnectSpy.mockReturnValue(of(socialAccount.id))
|
||||
component.disconnectSocialAccount(socialAccount.id)
|
||||
expect(disconnectSpy).toHaveBeenCalled()
|
||||
expect(component.socialAccounts).not.toContainEqual(socialAccount)
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user