-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-user
- Loading branch information
Showing
19 changed files
with
5,703 additions
and
959 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Route } from '@angular/router' | ||
|
||
import { ActivationComponent } from './activation.component' | ||
|
||
export const activationRoute: Route = { | ||
path: 'activate', | ||
component: ActivationComponent, | ||
data: { | ||
authorities: [], | ||
pageTitle: 'activate.title.string', | ||
}, | ||
} |
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 @@ | ||
<p>activation works!</p> |
Empty file.
55 changes: 55 additions & 0 deletions
55
ui/src/app/account/activation/activation.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,55 @@ | ||
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing' | ||
Check warning on line 1 in ui/src/app/account/activation/activation.component.spec.ts GitHub Actions / format
|
||
|
||
import { ActivationComponent } from './activation.component' | ||
import { ActivationService } from './activation.service' | ||
import { ActivatedRoute } from '@angular/router' | ||
import { async, of, throwError } from 'rxjs' | ||
import { RouterTestingModule } from '@angular/router/testing' | ||
|
||
describe('ActivationComponent', () => { | ||
let component: ActivationComponent | ||
let fixture: ComponentFixture<ActivationComponent> | ||
let activationServiceSpy: jasmine.SpyObj<ActivationService> | ||
|
||
beforeEach(() => { | ||
activationServiceSpy = jasmine.createSpyObj('ActivationService', ['get']) | ||
|
||
TestBed.configureTestingModule({ | ||
declarations: [ActivationComponent], | ||
imports: [RouterTestingModule], | ||
providers: [{ provide: ActivationService, useValue: activationServiceSpy }], | ||
}).compileComponents() | ||
|
||
fixture = TestBed.createComponent(ActivationComponent) | ||
component = fixture.componentInstance | ||
fixture.detectChanges() | ||
|
||
activationServiceSpy = TestBed.inject(ActivationService) as jasmine.SpyObj<ActivationService> | ||
}) | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
|
||
it('non-error response from server when sending key should indicate success', () => { | ||
activationServiceSpy.get.and.returnValue(of({})) | ||
component.ngOnInit() | ||
expect(component.success).toBeTruthy() | ||
expect(component.error).toBeFalsy() | ||
}) | ||
|
||
it('error response from server when sending key should indicate failure', () => { | ||
activationServiceSpy.get.and.returnValue(throwError(() => new Error('error'))) | ||
component.ngOnInit() | ||
|
||
expect(component.success).toBeFalsy() | ||
expect(component.error).toBeTruthy() | ||
}) | ||
}) | ||
|
||
export class MockActivatedRoute extends ActivatedRoute { | ||
constructor() { | ||
super() | ||
this.queryParams = of({ key: 'key' }) | ||
} | ||
} |
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,38 @@ | ||
import { Component, OnInit } from '@angular/core' | ||
import { ActivatedRoute, Router } from '@angular/router' | ||
import { ActivationService } from './activation.service' | ||
|
||
@Component({ | ||
selector: 'app-activation', | ||
templateUrl: './activation.component.html', | ||
styleUrls: ['./activation.component.scss'], | ||
}) | ||
export class ActivationComponent implements OnInit { | ||
error: string | null = null | ||
success: string | null = null | ||
|
||
constructor( | ||
private activationService: ActivationService, | ||
private route: ActivatedRoute, | ||
private router: Router | ||
) {} | ||
|
||
ngOnInit() { | ||
this.route.queryParams.subscribe((params) => { | ||
this.activationService.get(params['key']).subscribe({ | ||
next: () => { | ||
this.error = null | ||
this.success = 'OK' | ||
}, | ||
error: () => { | ||
this.success = null | ||
this.error = 'ERROR' | ||
}, | ||
}) | ||
}) | ||
} | ||
|
||
login() { | ||
this.router.navigate(['/login']) | ||
} | ||
} |
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,14 @@ | ||
import { Injectable } from '@angular/core' | ||
import { HttpClient, HttpParams } from '@angular/common/http' | ||
import { Observable } from 'rxjs' | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class ActivationService { | ||
constructor(private http: HttpClient) {} | ||
|
||
get(key: string): Observable<any> { | ||
return this.http.get('/services/userservice/api/activate', { | ||
params: new HttpParams().set('key', key), | ||
}) | ||
} | ||
} |
Oops, something went wrong.