mirror of https://github.com/abpframework/abp.git
39 changed files with 4030 additions and 3461 deletions
@ -1,49 +1,52 @@ |
|||
<Modal @ref="@ModalRef" Closing="@OnModalClosing"> |
|||
<ModalContent Centered="@CenterMessage"> |
|||
<ModalHeader> |
|||
<ModalTitle> |
|||
@Title |
|||
</ModalTitle> |
|||
</ModalHeader> |
|||
@if (!Title.IsNullOrEmpty()) |
|||
{ |
|||
<ModalHeader> |
|||
<ModalTitle> |
|||
@Title |
|||
</ModalTitle> |
|||
</ModalHeader> |
|||
} |
|||
<ModalBody> |
|||
@if ( ShowMessageIcon ) |
|||
{ |
|||
<DisplayHeading Size="DisplayHeadingSize.Is2" Alignment="TextAlignment.Center"> |
|||
<Icon Name="@MessageIcon" Style="@MessageIconStyle" /> |
|||
<DisplayHeading Size="DisplayHeadingSize.Is2" TextAlignment="TextAlignment.Center"> |
|||
<Icon Name="@MessageIcon" Style="@MessageIconStyle" /> |
|||
</DisplayHeading> |
|||
} |
|||
<Text Alignment="TextAlignment.Center"> |
|||
<Paragraph TextAlignment="TextAlignment.Center" Margin="Margin.Is0.FromBottom"> |
|||
@Message |
|||
</Text> |
|||
</Paragraph> |
|||
</ModalBody> |
|||
<ModalFooter> |
|||
@if ( IsConfirmation ) |
|||
{ |
|||
<Button Color="Color.Danger" Padding="Padding.Is2.OnX" Clicked="@OnCancelClicked"> |
|||
@if ( Options?.CancelButtonIcon != null ) |
|||
{ |
|||
<Icon Name="@Options.CancelButtonIcon" Margin="Margin.Is2.FromEnd" /> |
|||
} |
|||
@CancelButtonText |
|||
</Button> |
|||
<Button Color="Color.Primary" Padding="Padding.Is2.OnX" Clicked="@OnConfirmClicked"> |
|||
@if ( Options?.ConfirmButtonIcon != null ) |
|||
{ |
|||
<Icon Name="@Options.ConfirmButtonIcon" Margin="Margin.Is2.FromEnd" /> |
|||
} |
|||
@ConfirmButtonText |
|||
</Button> |
|||
} |
|||
else |
|||
{ |
|||
<Button Color="Color.Primary" Padding="Padding.Is2.OnX" Clicked="@OnOkClicked"> |
|||
@if ( Options?.OkButtonIcon != null ) |
|||
{ |
|||
<Icon Name="@Options.OkButtonIcon" Margin="Margin.Is2.FromEnd" /> |
|||
} |
|||
@OkButtonText |
|||
</Button> |
|||
} |
|||
<ModalFooter class="d-flex justify-content-center"> |
|||
@if ( IsConfirmation ) |
|||
{ |
|||
<Button Color="Color.Danger" Padding="Padding.Is3.OnX" Margin="Margin.Is1.OnX" Clicked="@OnCancelClicked"> |
|||
@if ( Options?.CancelButtonIcon != null ) |
|||
{ |
|||
<Icon Name="@Options.CancelButtonIcon" Margin="Margin.Is2.FromEnd" /> |
|||
} |
|||
@CancelButtonText |
|||
</Button> |
|||
<Button Color="Color.Primary" Padding="Padding.Is3.OnX" Margin="Margin.Is1.OnX" Clicked="@OnConfirmClicked"> |
|||
@if ( Options?.ConfirmButtonIcon != null ) |
|||
{ |
|||
<Icon Name="@Options.ConfirmButtonIcon" Margin="Margin.Is2.FromEnd" /> |
|||
} |
|||
@ConfirmButtonText |
|||
</Button> |
|||
} |
|||
else |
|||
{ |
|||
<Button Color="Color.Primary" Padding="Padding.Is3.OnX" Margin="Margin.Is1.OnX" Clicked="@OnOkClicked"> |
|||
@if ( Options?.OkButtonIcon != null ) |
|||
{ |
|||
<Icon Name="@Options.OkButtonIcon" Margin="Margin.Is2.FromEnd" /> |
|||
} |
|||
@OkButtonText |
|||
</Button> |
|||
} |
|||
</ModalFooter> |
|||
</ModalContent> |
|||
</Modal> |
|||
@ -0,0 +1,100 @@ |
|||
import { CoreTestingModule } from "@abp/ng.core/testing"; |
|||
import { ThemeBasicTestingModule } from "@abp/ng.theme.basic/testing"; |
|||
import { ThemeSharedTestingModule } from "@abp/ng.theme.shared/testing"; |
|||
import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; |
|||
import { NgxValidateCoreModule } from "@ngx-validate/core"; |
|||
import { HomeComponent } from "./home.component"; |
|||
import { OAuthService } from 'angular-oauth2-oidc'; |
|||
import { AuthService } from '@abp/ng.core'; |
|||
|
|||
|
|||
describe("HomeComponent", () => { |
|||
let fixture: ComponentFixture<HomeComponent>; |
|||
const mockOAuthService = jasmine.createSpyObj('OAuthService', ['hasValidAccessToken']) |
|||
const mockAuthService = jasmine.createSpyObj('AuthService', ['navigateToLogin']) |
|||
beforeEach( |
|||
waitForAsync(() => { |
|||
TestBed.configureTestingModule({ |
|||
declarations: [HomeComponent], |
|||
imports: [ |
|||
CoreTestingModule.withConfig(), |
|||
ThemeSharedTestingModule.withConfig(), |
|||
ThemeBasicTestingModule.withConfig(), |
|||
NgxValidateCoreModule, |
|||
], |
|||
providers: [ |
|||
/* mock providers here */ |
|||
{ |
|||
provide: OAuthService, |
|||
useValue: mockOAuthService |
|||
}, |
|||
{ |
|||
provide: AuthService, |
|||
useValue: mockAuthService |
|||
} |
|||
], |
|||
}).compileComponents(); |
|||
}) |
|||
); |
|||
|
|||
beforeEach(() => { |
|||
fixture = TestBed.createComponent(HomeComponent); |
|||
fixture.detectChanges(); |
|||
}); |
|||
|
|||
it("should be initiated", () => { |
|||
expect(fixture.componentInstance).toBeTruthy(); |
|||
}); |
|||
|
|||
|
|||
|
|||
describe('when login state is true', () => { |
|||
beforeAll(() => { |
|||
mockOAuthService.hasValidAccessToken.and.returnValue(true) |
|||
}); |
|||
|
|||
it("hasLoggedIn should be true", () => { |
|||
|
|||
expect(fixture.componentInstance.hasLoggedIn).toBeTrue(); |
|||
expect(mockOAuthService.hasValidAccessToken).toHaveBeenCalled() |
|||
}) |
|||
|
|||
it("button should not be exists", () => { |
|||
const element = fixture.nativeElement |
|||
const button = element.querySelector('[role="button"]') |
|||
expect(button).toBeNull() |
|||
}) |
|||
|
|||
}) |
|||
|
|||
describe('when login state is false', () => { |
|||
beforeAll(() => { |
|||
mockOAuthService.hasValidAccessToken.and.returnValue(false) |
|||
}); |
|||
|
|||
it("hasLoggedIn should be false", () => { |
|||
|
|||
expect(fixture.componentInstance.hasLoggedIn).toBeFalse(); |
|||
expect(mockOAuthService.hasValidAccessToken).toHaveBeenCalled() |
|||
}) |
|||
|
|||
it("button should be exists", () => { |
|||
const element = fixture.nativeElement |
|||
const button = element.querySelector('[role="button"]') |
|||
expect(button).toBeDefined() |
|||
}) |
|||
describe('when button clicked', () => { |
|||
|
|||
beforeEach(() => { |
|||
const element = fixture.nativeElement |
|||
const button = element.querySelector('[role="button"]') |
|||
button.click() |
|||
}); |
|||
|
|||
it("navigateToLogin have been called", () => { |
|||
expect(mockAuthService.navigateToLogin).toHaveBeenCalled() |
|||
}) |
|||
}) |
|||
}) |
|||
|
|||
}); |
|||
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 38 KiB |
File diff suppressed because it is too large
Loading…
Reference in new issue