-
Notifications
You must be signed in to change notification settings - Fork 3
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
87ca431
commit 4e03df3
Showing
7 changed files
with
72 additions
and
103 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
44 changes: 17 additions & 27 deletions
44
frontend/src/app/team-management/invite-user-dialog/invite-user-dialog.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 |
---|---|---|
@@ -1,54 +1,44 @@ | ||
import { ComponentFixture, TestBed } from "@angular/core/testing"; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { InviteUserDialogComponent } from "./invite-user-dialog.component"; | ||
import { MatDialogModule } from "@angular/material/dialog"; | ||
import { FormsModule, ReactiveFormsModule } from "@angular/forms"; | ||
import { NewUserComponent } from "../new-user/new-user.component"; | ||
import { PuzzleIconComponent } from "../../shared/custom/puzzle-icon/puzzle-icon.component"; | ||
import { PuzzleIconButtonComponent } from "../../shared/custom/puzzle-icon-button/puzzle-icon-button.component"; | ||
import { InviteUserDialogComponent } from './invite-user-dialog.component'; | ||
import { MatDialogModule } from '@angular/material/dialog'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { NewUserComponent } from '../new-user/new-user.component'; | ||
import { PuzzleIconComponent } from '../../shared/custom/puzzle-icon/puzzle-icon.component'; | ||
import { PuzzleIconButtonComponent } from '../../shared/custom/puzzle-icon-button/puzzle-icon-button.component'; | ||
|
||
describe("InviteUserDialogComponent", () => { | ||
describe('InviteUserDialogComponent', () => { | ||
let component: InviteUserDialogComponent; | ||
let fixture: ComponentFixture<InviteUserDialogComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ | ||
InviteUserDialogComponent, | ||
NewUserComponent, | ||
PuzzleIconComponent, | ||
PuzzleIconButtonComponent | ||
], | ||
imports: [ | ||
MatDialogModule, | ||
FormsModule, | ||
ReactiveFormsModule | ||
] | ||
}) | ||
.compileComponents(); | ||
declarations: [InviteUserDialogComponent, NewUserComponent, PuzzleIconComponent, PuzzleIconButtonComponent], | ||
imports: [MatDialogModule, FormsModule, ReactiveFormsModule], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(InviteUserDialogComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it("should create", () => { | ||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('addUser should add a user to the existing users', () => { | ||
component.addUser(); | ||
expect(component.users.length).toBe(2); | ||
}) | ||
}); | ||
|
||
it('removeUser should remove given user from users array', () => { | ||
const user1 = {firstname: 'user1', lastname: '1user', email: '[email protected]'}; | ||
const user2 = {firstname: 'user2', lastname: '2user', email: '[email protected]'}; | ||
const user3 = {firstname: 'user3', lastname: '3user', email: '[email protected]'}; | ||
const user1 = { firstname: 'user1', lastname: '1user', email: '[email protected]' }; | ||
const user2 = { firstname: 'user2', lastname: '2user', email: '[email protected]' }; | ||
const user3 = { firstname: 'user3', lastname: '3user', email: '[email protected]' }; | ||
component.users = [user1, user2, user3]; | ||
|
||
component.removeUser(user2); | ||
|
||
expect(component.users).toStrictEqual([user1, user3]); | ||
}) | ||
}); | ||
}); |
23 changes: 10 additions & 13 deletions
23
frontend/src/app/team-management/invite-user-dialog/invite-user-dialog.component.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 |
---|---|---|
@@ -1,31 +1,28 @@ | ||
import { Component, ViewChild } from "@angular/core"; | ||
import { NewUser } from "../../shared/types/model/NewUser"; | ||
import { NgForm } from "@angular/forms"; | ||
import { Component, ViewChild } from '@angular/core'; | ||
import { NewUser } from '../../shared/types/model/NewUser'; | ||
import { NgForm } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'app-invite-user-dialog', | ||
templateUrl: './invite-user-dialog.component.html', | ||
styleUrl: './invite-user-dialog.component.scss' | ||
styleUrl: './invite-user-dialog.component.scss', | ||
}) | ||
export class InviteUserDialogComponent { | ||
|
||
@ViewChild('form') form!: NgForm; | ||
|
||
private readonly emptyUser = {firstname: '', lastname: '', email: ''}; | ||
private readonly emptyUser = { firstname: '', lastname: '', email: '' }; | ||
|
||
users: NewUser[] = [{...this.emptyUser}]; | ||
users: NewUser[] = [{ ...this.emptyUser }]; | ||
|
||
constructor() { | ||
} | ||
constructor() {} | ||
|
||
inviteUsers() { | ||
} | ||
inviteUsers() {} | ||
|
||
addUser() { | ||
this.users.push({...this.emptyUser}); | ||
this.users.push({ ...this.emptyUser }); | ||
} | ||
|
||
removeUser(user: NewUser) { | ||
this.users = this.users.filter(u => u !== user); | ||
this.users = this.users.filter((u) => u !== user); | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
frontend/src/app/team-management/new-user/new-user.component.scss
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
40 changes: 14 additions & 26 deletions
40
frontend/src/app/team-management/new-user/new-user.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 |
---|---|---|
@@ -1,44 +1,32 @@ | ||
import { ComponentFixture, TestBed } from "@angular/core/testing"; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { NewUserComponent } from "./new-user.component"; | ||
import { FormsModule, NgForm, ReactiveFormsModule } from "@angular/forms"; | ||
import { SharedModule } from "../../shared/shared.module"; | ||
import { PuzzleIconButtonComponent } from "../../shared/custom/puzzle-icon-button/puzzle-icon-button.component"; | ||
import { PuzzleIconComponent } from "../../shared/custom/puzzle-icon/puzzle-icon.component"; | ||
import { CommonModule } from "@angular/common"; | ||
import { NewUserComponent } from './new-user.component'; | ||
import { FormsModule, NgForm, ReactiveFormsModule } from '@angular/forms'; | ||
import { SharedModule } from '../../shared/shared.module'; | ||
import { PuzzleIconButtonComponent } from '../../shared/custom/puzzle-icon-button/puzzle-icon-button.component'; | ||
import { PuzzleIconComponent } from '../../shared/custom/puzzle-icon/puzzle-icon.component'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
describe("NewUserComponent", () => { | ||
describe('NewUserComponent', () => { | ||
let component: NewUserComponent; | ||
let fixture: ComponentFixture<NewUserComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ | ||
NewUserComponent, | ||
PuzzleIconButtonComponent, | ||
PuzzleIconComponent | ||
], | ||
imports: [ | ||
FormsModule, | ||
ReactiveFormsModule, | ||
SharedModule, | ||
CommonModule | ||
], | ||
providers: [ | ||
NgForm | ||
] | ||
}) | ||
.compileComponents(); | ||
declarations: [NewUserComponent, PuzzleIconButtonComponent, PuzzleIconComponent], | ||
imports: [FormsModule, ReactiveFormsModule, SharedModule, CommonModule], | ||
providers: [NgForm], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(NewUserComponent); | ||
component = fixture.componentInstance; | ||
|
||
component.user = {firstname: '', lastname: '', email: ''}; | ||
component.user = { firstname: '', lastname: '', email: '' }; | ||
|
||
fixture.detectChanges(); | ||
}); | ||
|
||
it("should create", () => { | ||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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