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"> |
<Modal @ref="@ModalRef" Closing="@OnModalClosing"> |
||||
<ModalContent Centered="@CenterMessage"> |
<ModalContent Centered="@CenterMessage"> |
||||
<ModalHeader> |
@if (!Title.IsNullOrEmpty()) |
||||
<ModalTitle> |
{ |
||||
@Title |
<ModalHeader> |
||||
</ModalTitle> |
<ModalTitle> |
||||
</ModalHeader> |
@Title |
||||
|
</ModalTitle> |
||||
|
</ModalHeader> |
||||
|
} |
||||
<ModalBody> |
<ModalBody> |
||||
@if ( ShowMessageIcon ) |
@if ( ShowMessageIcon ) |
||||
{ |
{ |
||||
<DisplayHeading Size="DisplayHeadingSize.Is2" Alignment="TextAlignment.Center"> |
<DisplayHeading Size="DisplayHeadingSize.Is2" TextAlignment="TextAlignment.Center"> |
||||
<Icon Name="@MessageIcon" Style="@MessageIconStyle" /> |
<Icon Name="@MessageIcon" Style="@MessageIconStyle" /> |
||||
</DisplayHeading> |
</DisplayHeading> |
||||
} |
} |
||||
<Text Alignment="TextAlignment.Center"> |
<Paragraph TextAlignment="TextAlignment.Center" Margin="Margin.Is0.FromBottom"> |
||||
@Message |
@Message |
||||
</Text> |
</Paragraph> |
||||
</ModalBody> |
</ModalBody> |
||||
<ModalFooter> |
<ModalFooter class="d-flex justify-content-center"> |
||||
@if ( IsConfirmation ) |
@if ( IsConfirmation ) |
||||
{ |
{ |
||||
<Button Color="Color.Danger" Padding="Padding.Is2.OnX" Clicked="@OnCancelClicked"> |
<Button Color="Color.Danger" Padding="Padding.Is3.OnX" Margin="Margin.Is1.OnX" Clicked="@OnCancelClicked"> |
||||
@if ( Options?.CancelButtonIcon != null ) |
@if ( Options?.CancelButtonIcon != null ) |
||||
{ |
{ |
||||
<Icon Name="@Options.CancelButtonIcon" Margin="Margin.Is2.FromEnd" /> |
<Icon Name="@Options.CancelButtonIcon" Margin="Margin.Is2.FromEnd" /> |
||||
} |
} |
||||
@CancelButtonText |
@CancelButtonText |
||||
</Button> |
</Button> |
||||
<Button Color="Color.Primary" Padding="Padding.Is2.OnX" Clicked="@OnConfirmClicked"> |
<Button Color="Color.Primary" Padding="Padding.Is3.OnX" Margin="Margin.Is1.OnX" Clicked="@OnConfirmClicked"> |
||||
@if ( Options?.ConfirmButtonIcon != null ) |
@if ( Options?.ConfirmButtonIcon != null ) |
||||
{ |
{ |
||||
<Icon Name="@Options.ConfirmButtonIcon" Margin="Margin.Is2.FromEnd" /> |
<Icon Name="@Options.ConfirmButtonIcon" Margin="Margin.Is2.FromEnd" /> |
||||
} |
} |
||||
@ConfirmButtonText |
@ConfirmButtonText |
||||
</Button> |
</Button> |
||||
} |
} |
||||
else |
else |
||||
{ |
{ |
||||
<Button Color="Color.Primary" Padding="Padding.Is2.OnX" Clicked="@OnOkClicked"> |
<Button Color="Color.Primary" Padding="Padding.Is3.OnX" Margin="Margin.Is1.OnX" Clicked="@OnOkClicked"> |
||||
@if ( Options?.OkButtonIcon != null ) |
@if ( Options?.OkButtonIcon != null ) |
||||
{ |
{ |
||||
<Icon Name="@Options.OkButtonIcon" Margin="Margin.Is2.FromEnd" /> |
<Icon Name="@Options.OkButtonIcon" Margin="Margin.Is2.FromEnd" /> |
||||
} |
} |
||||
@OkButtonText |
@OkButtonText |
||||
</Button> |
</Button> |
||||
} |
} |
||||
</ModalFooter> |
</ModalFooter> |
||||
</ModalContent> |
</ModalContent> |
||||
</Modal> |
</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