-
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.
- Loading branch information
1 parent
c2cb2ab
commit 1c6458c
Showing
56 changed files
with
449 additions
and
692 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
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
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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import {AvatarComponent} from './avatar.component'; | ||
import {AuthService} from "@auth0/auth0-angular"; | ||
import {createComponentFactory, Spectator} from "@ngneat/spectator/jest"; | ||
import { AuthService } from '@auth0/auth0-angular'; | ||
import { createComponentFactory, Spectator } from '@ngneat/spectator/jest'; | ||
import { AvatarComponent } from './avatar.component'; | ||
|
||
describe('AvatarComponent', () => { | ||
let spectator: Spectator<AvatarComponent>; | ||
const createComponent = createComponentFactory({ | ||
component: AvatarComponent, | ||
declareComponent: false, | ||
providers: [ | ||
{ | ||
provide: AuthService, useValue: { | ||
isLoading$: false | ||
} | ||
} | ||
|
||
] | ||
provide: AuthService, | ||
useValue: { | ||
isLoading$: false, | ||
}, | ||
}, | ||
], | ||
}); | ||
beforeEach(async () => { | ||
spectator = createComponent(); | ||
|
@@ -40,35 +41,35 @@ describe('AvatarComponent', () => { | |
expect(spectator.query('div')?.textContent).toEqual('IL'); | ||
}); | ||
it('should have initials based on the email address', () => { | ||
spectator.setInput('avatarText', '[email protected]') | ||
spectator.setInput('avatarText', '[email protected]'); | ||
expect(spectator.query('div')?.textContent).toEqual('TV'); | ||
}); | ||
it('should not break on wrong input', () => { | ||
spectator.setInput('avatarText', 'tijs') | ||
spectator.setInput('avatarText', 'tijs'); | ||
expect(spectator.query('div')?.textContent).toEqual('T'); | ||
}); | ||
it('should not break on empty input', () => { | ||
spectator.setInput('avatarText', '') | ||
spectator.setInput('avatarText', ''); | ||
expect(spectator.query('div')?.textContent).toEqual('L'); | ||
spectator.setInput('avatarText', undefined) | ||
spectator.setInput('avatarText', undefined); | ||
expect(spectator.query('div')?.textContent).toEqual('L'); | ||
}); | ||
|
||
it('should handle an image', () => { | ||
let src: string = 'https://localhost:8080/image.png' | ||
spectator.setInput('avatarImage', src) | ||
expect(spectator.query('div')).toBeNull() | ||
expect(spectator.query('img')).toBeDefined() | ||
expect(spectator.query('img')?.getAttribute('src')).toEqual(src) | ||
let src: string = 'https://localhost:8080/image.png'; | ||
spectator.setInput('avatarImage', src); | ||
expect(spectator.query('div')).toBeNull(); | ||
expect(spectator.query('img')).toBeDefined(); | ||
expect(spectator.query('img')?.getAttribute('src')).toEqual(src); | ||
}); | ||
|
||
it('should ignore an empty image and revert to default', () => { | ||
let src: string = '' | ||
spectator.setInput('avatarImage', src) | ||
spectator.setInput('avatarText', '') | ||
expect(spectator.query('div')).toBeDefined() | ||
expect(spectator.query('img')).toBeNull() | ||
let src: string = ''; | ||
spectator.setInput('avatarImage', src); | ||
spectator.setInput('avatarText', ''); | ||
expect(spectator.query('div')).toBeDefined(); | ||
expect(spectator.query('img')).toBeNull(); | ||
expect(spectator.query('div')?.textContent).toEqual('L'); | ||
}); | ||
}) | ||
}); | ||
}); |
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
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
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
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
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
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
12 changes: 11 additions & 1 deletion
12
src/app/components/forms/form-error-message/form-error-message.component.spec.ts
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
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
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
Oops, something went wrong.