-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It is also necessary to implement various input and output parameter assertions for the components
- Loading branch information
1 parent
5f1c97a
commit ae85d78
Showing
35 changed files
with
4,007 additions
and
6,337 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
102 changes: 66 additions & 36 deletions
102
lib/ng-nest/ui/page-header/page-header.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,57 +1,87 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { Component, DebugElement, provideExperimentalZonelessChangeDetection } from '@angular/core'; | ||
import { Component, provideExperimentalZonelessChangeDetection, signal } from '@angular/core'; | ||
import { By } from '@angular/platform-browser'; | ||
import { XPageHeaderComponent } from '@ng-nest/ui/page-header'; | ||
import { XPageHeaderPrefix } from './page-header.property'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
import { XPageHeaderComponent, XPageHeaderPrefix } from '@ng-nest/ui/page-header'; | ||
import { provideHttpClientTesting } from '@angular/common/http/testing'; | ||
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [XPageHeaderComponent], | ||
template: `<x-page-header></x-page-header> ` | ||
}) | ||
class XTestPageHeaderComponent {} | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [XPageHeaderComponent], | ||
template: ` | ||
<x-page-header | ||
[backIcon]="backIcon()" | ||
[backText]="backText()" | ||
[title]="title()" | ||
[subTitle]="subTitle()" | ||
(backClick)="backClick($event)" | ||
> | ||
</x-page-header> | ||
` | ||
}) | ||
class XTestPageHeaderPropertyComponent { | ||
backIcon = signal('fto-arrow-left'); | ||
backText = signal(''); | ||
title = signal(''); | ||
subTitle = signal(''); | ||
|
||
backClickResult = signal<Event | null>(null); | ||
backClick(event: Event) { | ||
this.backClickResult.set(event); | ||
} | ||
} | ||
|
||
describe(XPageHeaderPrefix, () => { | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [TestXPageHeaderComponent], | ||
imports: [BrowserAnimationsModule, XPageHeaderComponent], | ||
imports: [XTestPageHeaderComponent, XTestPageHeaderPropertyComponent], | ||
providers: [ | ||
provideHttpClient(withInterceptorsFromDi()), | ||
provideHttpClientTesting(), | ||
provideExperimentalZonelessChangeDetection() | ||
] | ||
}).compileComponents(); | ||
}); | ||
describe(`default.`, () => { | ||
let fixture: ComponentFixture<TestXPageHeaderComponent>; | ||
let pageheader: DebugElement; | ||
describe('default.', () => { | ||
let fixture: ComponentFixture<XTestPageHeaderComponent>; | ||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TestXPageHeaderComponent); | ||
fixture = TestBed.createComponent(XTestPageHeaderComponent); | ||
fixture.detectChanges(); | ||
pageheader = fixture.debugElement.query(By.directive(XPageHeaderComponent)); | ||
}); | ||
it('should create.', () => { | ||
expect(pageheader).toBeDefined(); | ||
it('define.', () => { | ||
const com = fixture.debugElement.query(By.directive(XPageHeaderComponent)); | ||
expect(com).toBeDefined(); | ||
}); | ||
}); | ||
describe(`input.`, async () => { | ||
let fixture: ComponentFixture<XTestPageHeaderPropertyComponent>; | ||
// let component: XTestPageHeaderPropertyComponent; | ||
beforeEach(async () => { | ||
fixture = TestBed.createComponent(XTestPageHeaderPropertyComponent); | ||
// component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
it('backIcon.', () => { | ||
expect(true).toBe(true); | ||
}); | ||
it('backText.', () => { | ||
expect(true).toBe(true); | ||
}); | ||
it('title.', () => { | ||
expect(true).toBe(true); | ||
}); | ||
it('subTitle.', () => { | ||
expect(true).toBe(true); | ||
}); | ||
it('backClick.', () => { | ||
expect(true).toBe(true); | ||
}); | ||
}); | ||
}); | ||
|
||
@Component({ | ||
template: ` | ||
<div class="row"> | ||
<x-page-header title="标题" subTitle="小标题"> </x-page-header> | ||
</div> | ||
`, | ||
styles: [ | ||
` | ||
:host { | ||
background-color: var(--x-background); | ||
padding: 1rem; | ||
border: 0.0625rem solid var(--x-border); | ||
} | ||
.row:not(:first-child) { | ||
margin-top: 1rem; | ||
} | ||
` | ||
] | ||
}) | ||
class TestXPageHeaderComponent {} |
Oops, something went wrong.