diff --git a/templates/app/angular/src/app/home/home.component.html b/templates/app/angular/src/app/home/home.component.html
index 2733150b71..f4d41daf4f 100644
--- a/templates/app/angular/src/app/home/home.component.html
+++ b/templates/app/angular/src/app/home/home.component.html
@@ -14,6 +14,7 @@
[state]="{ redirectUrl: '/' }"
class="px-4 btn btn-primary ml-1"
role="button"
- > {{ 'AbpIdentity::Login' | abpLocalization }} {{ 'AbpAccount::Login' | abpLocalization }}
diff --git a/templates/app/angular/src/app/home/home.component.spec.ts b/templates/app/angular/src/app/home/home.component.spec.ts
new file mode 100644
index 0000000000..c0c7686591
--- /dev/null
+++ b/templates/app/angular/src/app/home/home.component.spec.ts
@@ -0,0 +1,51 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { OAuthService } from 'angular-oauth2-oidc';
+import { HomeComponent } from './home.component';
+import { HomeModule } from './home.module';
+import { RouterTestingModule } from '@angular/router/testing';
+import { NgxsModule } from '@ngxs/store';
+import { By } from '@angular/platform-browser';
+
+describe('HomeComponent', () => {
+ let component: HomeComponent;
+ let fixture: ComponentFixture;
+ let mockOAuthService: { hasValidAccessToken: () => boolean };
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ imports: [HomeModule, NgxsModule.forRoot(), RouterTestingModule],
+ providers: [{ provide: OAuthService, useValue: { hasValidAccessToken: () => false } }],
+ });
+ fixture = TestBed.createComponent(HomeComponent);
+ component = fixture.componentInstance;
+ mockOAuthService = TestBed.get(OAuthService);
+ fixture.detectChanges();
+ });
+
+ describe('#hasLoggedIn', () => {
+ it('should return the hasValidAccessToken method of oAuthService', () => {
+ const spy = spyOn(mockOAuthService, 'hasValidAccessToken');
+ spy.and.returnValue(false);
+
+ expect(component.hasLoggedIn).toBe(false);
+ expect(spy).toHaveBeenCalled();
+ });
+ });
+
+ describe('login button', () => {
+ it('should display', () => {
+ const button = fixture.debugElement.query(By.css('[routerLink="/account/login"]'));
+ expect(button).toBeTruthy();
+ expect(button.nativeElement.textContent).toContain('AbpAccount::Login');
+ });
+
+ it('should not display when user logged in', () => {
+ const spy = spyOn(mockOAuthService, 'hasValidAccessToken');
+ spy.and.returnValue(true);
+ fixture.detectChanges();
+
+ const button = fixture.debugElement.query(By.css('#login-button'));
+ expect(button).toBeFalsy();
+ });
+ });
+});