-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mirko Mollik <[email protected]>
- Loading branch information
Mirko Mollik
committed
May 12, 2024
1 parent
09b52eb
commit d48f8c4
Showing
4 changed files
with
42 additions
and
36 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,16 +1,52 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { AppComponent } from './app.component'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { IssuerService } from './issuer.service'; | ||
import { MatSnackBar } from '@angular/material/snack-bar'; | ||
import { of } from 'rxjs'; | ||
|
||
describe('AppComponent', () => { | ||
let component: AppComponent; | ||
let fixture: ComponentFixture<AppComponent>; | ||
|
||
const mockIssuerService = { | ||
getUrl: jest.fn().mockReturnValue(of('')), | ||
uri: 'test-uri', | ||
}; | ||
|
||
const mockSnackBar = { | ||
open: jest.fn(), | ||
}; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [AppComponent, RouterTestingModule], | ||
declarations: [AppComponent], | ||
providers: [ | ||
{ provide: IssuerService, useValue: mockIssuerService }, | ||
{ provide: MatSnackBar, useValue: mockSnackBar }, | ||
], | ||
}).compileComponents(); | ||
}); | ||
|
||
it('should render title', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture = TestBed.createComponent(AppComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should generate QR code', async () => { | ||
await component.generate(); | ||
expect(mockIssuerService.getUrl).toHaveBeenCalled(); | ||
expect(component.qrCodeField.value).toBe('test-uri'); | ||
}); | ||
|
||
it('should copy value to clipboard', () => { | ||
component.copyValue(); | ||
expect(mockSnackBar.open).toHaveBeenCalledWith( | ||
'URL copied to clipboard', | ||
'Close', | ||
{ duration: 3000 } | ||
); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.