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