-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a test to check if the form is disabled if the amount exceeds the available account space.
- Loading branch information
1 parent
3c68d0a
commit 6b2fe30
Showing
5 changed files
with
53 additions
and
24 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,11 +1,12 @@ | ||
import { AccountService } from '@shared/services/account/account.service'; | ||
/* @format */ | ||
import { Shallow } from 'shallow-render'; | ||
import { HttpClient, HttpHandler } from '@angular/common/http'; | ||
import { CoreModule } from '@core/core.module'; | ||
import { Dialog } from '@root/app/dialog/dialog.service'; | ||
import { AccountService } from '@shared/services/account/account.service'; | ||
import { AccountVO } from '../../../models/account-vo'; | ||
import { GiftStorageComponent } from './gift-storage.component'; | ||
import { fakeAsync, tick } from '@angular/core/testing'; | ||
|
||
describe('GiftStorageComponent', () => { | ||
let shallow: Shallow<GiftStorageComponent>; | ||
|
@@ -35,18 +36,21 @@ describe('GiftStorageComponent', () => { | |
|
||
instance.availableSpace = '10'; | ||
|
||
instance.giftForm.controls.email.setValue('[email protected]'); | ||
await instance.giftForm.controls.email.setValue('[email protected]'); | ||
instance.giftForm.controls.amount.setValue('1'); | ||
|
||
instance.isAsyncValidating = false; | ||
|
||
instance.giftForm.updateValueAndValidity(); | ||
fixture.detectChanges(); | ||
await fixture.whenStable(); | ||
|
||
const button: HTMLButtonElement = find('.btn-primary').nativeElement; | ||
|
||
expect(button.disabled).toBe(false); | ||
}); | ||
|
||
it('the button is disabled if the email is not valid', async () => { | ||
it('disables the submit button if the email is not valid', async () => { | ||
const { find, instance, fixture } = await shallow.render(); | ||
|
||
instance.availableSpace = '5'; | ||
|
@@ -62,6 +66,24 @@ describe('GiftStorageComponent', () => { | |
expect(button.disabled).toBe(true); | ||
}); | ||
|
||
it('disables the submit button if the amount entered exceeds the available amount', async () => { | ||
const { find, instance, fixture } = await shallow.render(); | ||
|
||
instance.availableSpace = '5'; | ||
|
||
await instance.giftForm.controls.email.setValue('[email protected]'); | ||
instance.giftForm.controls.amount.setValue('10'); | ||
|
||
instance.giftForm.updateValueAndValidity(); | ||
|
||
fixture.detectChanges(); | ||
await fixture.whenStable(); | ||
|
||
const button: HTMLButtonElement = find('.btn-primary').nativeElement; | ||
|
||
expect(button.disabled).toBe(true); | ||
}); | ||
|
||
it('calls submitStorageGiftForm when the form is valid', async () => { | ||
const { instance } = await shallow.render(); | ||
|
||
|
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