-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add component tests for account request table * modify tests * remove old tests * remove comment * remove unnecessary code * add tests * update disabled criteria * remove extra builders and update snaps
- Loading branch information
1 parent
2bd06e2
commit 4682dff
Showing
12 changed files
with
1,703 additions
and
404 deletions.
There are no files selected for viewing
758 changes: 758 additions & 0 deletions
758
...ponents/account-requests-table/__snapshots__/account-request-table.component.spec.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
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
497 changes: 497 additions & 0 deletions
497
src/web/app/components/account-requests-table/account-request-table.component.spec.ts
Large diffs are not rendered by default.
Oops, something went wrong.
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
215 changes: 215 additions & 0 deletions
215
...le/admin-edit-request-modal/__snapshots__/admin-edit-request-modal.component.spec.ts.snap
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 |
---|---|---|
@@ -0,0 +1,215 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`RejectWithReasonModal should show empty fields 1`] = ` | ||
<tm-edit-request-modal | ||
accountRequestComments="" | ||
accountRequestEmail="" | ||
accountRequestInstitution="" | ||
accountRequestName="" | ||
activeModal={[Function NgbActiveModal]} | ||
> | ||
<div | ||
class="modal-header bg-primary" | ||
> | ||
<h5 | ||
class="modal-title text-white" | ||
> | ||
<div> | ||
Edit Account Request for | ||
</div> | ||
</h5> | ||
<button | ||
class="btn-close" | ||
type="button" | ||
/> | ||
</div><div | ||
class="modal-body" | ||
id="reject-account-request-modal" | ||
> | ||
<div> | ||
<label> | ||
<b> | ||
Name: | ||
</b> | ||
</label> | ||
<input | ||
class="form-control" | ||
id="request-name" | ||
type="text" | ||
/> | ||
</div> | ||
<div> | ||
<label> | ||
<b> | ||
Email: | ||
</b> | ||
</label> | ||
<input | ||
class="form-control" | ||
id="request-email" | ||
type="text" | ||
/> | ||
</div> | ||
<div> | ||
<label> | ||
<b> | ||
Institution, Country: | ||
</b> | ||
</label> | ||
<input | ||
class="form-control" | ||
id="request-institution" | ||
type="text" | ||
/> | ||
</div> | ||
<div | ||
class="row" | ||
> | ||
<div | ||
class="col-12" | ||
> | ||
<div> | ||
<label> | ||
<b> | ||
Comments: | ||
</b> | ||
</label> | ||
</div> | ||
<div | ||
class="form-group" | ||
> | ||
<textarea | ||
class="form-control" | ||
id="request-comments" | ||
rows="5" | ||
/> | ||
</div> | ||
</div> | ||
<div | ||
class="modal-footer" | ||
> | ||
<button | ||
class="btn btn-light" | ||
type="button" | ||
> | ||
Cancel | ||
</button> | ||
<button | ||
class="btn btn-primary" | ||
id="btn-confirm-edit-request" | ||
type="button" | ||
> | ||
Save | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</tm-edit-request-modal> | ||
`; | ||
|
||
exports[`RejectWithReasonModal should show populated data 1`] = ` | ||
<tm-edit-request-modal | ||
accountRequestComments={[Function String]} | ||
accountRequestEmail={[Function String]} | ||
accountRequestInstitution={[Function String]} | ||
accountRequestName={[Function String]} | ||
activeModal={[Function NgbActiveModal]} | ||
> | ||
<div | ||
class="modal-header bg-primary" | ||
> | ||
<h5 | ||
class="modal-title text-white" | ||
> | ||
<div> | ||
Edit Account Request for John Doe | ||
</div> | ||
</h5> | ||
<button | ||
class="btn-close" | ||
type="button" | ||
/> | ||
</div><div | ||
class="modal-body" | ||
id="reject-account-request-modal" | ||
> | ||
<div> | ||
<label> | ||
<b> | ||
Name: | ||
</b> | ||
</label> | ||
<input | ||
class="form-control" | ||
id="request-name" | ||
type="text" | ||
/> | ||
</div> | ||
<div> | ||
<label> | ||
<b> | ||
Email: | ||
</b> | ||
</label> | ||
<input | ||
class="form-control" | ||
id="request-email" | ||
type="text" | ||
/> | ||
</div> | ||
<div> | ||
<label> | ||
<b> | ||
Institution, Country: | ||
</b> | ||
</label> | ||
<input | ||
class="form-control" | ||
id="request-institution" | ||
type="text" | ||
/> | ||
</div> | ||
<div | ||
class="row" | ||
> | ||
<div | ||
class="col-12" | ||
> | ||
<div> | ||
<label> | ||
<b> | ||
Comments: | ||
</b> | ||
</label> | ||
</div> | ||
<div | ||
class="form-group" | ||
> | ||
<textarea | ||
class="form-control" | ||
id="request-comments" | ||
rows="5" | ||
/> | ||
</div> | ||
</div> | ||
<div | ||
class="modal-footer" | ||
> | ||
<button | ||
class="btn btn-light" | ||
type="button" | ||
> | ||
Cancel | ||
</button> | ||
<button | ||
class="btn btn-primary" | ||
id="btn-confirm-edit-request" | ||
type="button" | ||
> | ||
Save | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</tm-edit-request-modal> | ||
`; |
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
60 changes: 60 additions & 0 deletions
60
...ccount-requests-table/admin-edit-request-modal/admin-edit-request-modal.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { EditRequestModalComponent } from './admin-edit-request-modal.component'; | ||
|
||
describe('RejectWithReasonModal', () => { | ||
let fixture: ComponentFixture<EditRequestModalComponent>; | ||
let component: EditRequestModalComponent; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [], | ||
imports: [ | ||
HttpClientTestingModule, | ||
], | ||
providers: [NgbActiveModal], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(EditRequestModalComponent); | ||
fixture.detectChanges(); | ||
component = fixture.componentInstance; | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should show empty fields', () => { | ||
expect(fixture).toMatchSnapshot(); | ||
}); | ||
|
||
it('should show populated data', () => { | ||
component.accountRequestName = 'John Doe'; | ||
component.accountRequestEmail = '[email protected]'; | ||
component.accountRequestInstitution = 'NUS'; | ||
component.accountRequestComments = 'Comments'; | ||
fixture.detectChanges(); | ||
expect(fixture).toMatchSnapshot(); | ||
}); | ||
|
||
it('should close modal with data', () => { | ||
const spyActiveModal = jest.spyOn(component.activeModal, 'close'); | ||
component.accountRequestName = 'John Doe'; | ||
component.accountRequestEmail = '[email protected]'; | ||
component.accountRequestInstitution = 'NUS'; | ||
component.accountRequestComments = 'Comments'; | ||
fixture.detectChanges(); | ||
component.edit(); | ||
expect(spyActiveModal).toHaveBeenCalled(); | ||
expect(spyActiveModal).toHaveBeenCalledWith({ | ||
accountRequestName: 'John Doe', | ||
accountRequestEmail: '[email protected]', | ||
accountRequestInstitution: 'NUS', | ||
accountRequestComment: 'Comments', | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.