Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove standalone tag #1865

Merged
merged 4 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions packages/abc/cell/cell.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Component, DebugElement, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserModule, By, DomSanitizer } from '@angular/platform-browser';
import { NoopAnimationsModule, provideNoopAnimations } from '@angular/platform-browser/animations';
import { provideNoopAnimations } from '@angular/platform-browser/animations';
import { Router } from '@angular/router';
import { of } from 'rxjs';

import { cleanCdkOverlayHtml, createTestContext } from '@delon/testing';
import { WINDOW } from '@delon/util/token';
import type { NzSafeAny } from 'ng-zorro-antd/core/types';
import { provideNzIconsTesting } from 'ng-zorro-antd/icon/testing';
import { NzImageService } from 'ng-zorro-antd/image';
import { NzTooltipDirective } from 'ng-zorro-antd/tooltip';

import { CellComponent } from './cell.component';
Expand All @@ -29,8 +28,7 @@ describe('abc: cell', () => {
const moduleAction = (): void => {
TestBed.configureTestingModule({
providers: [provideNzIconsTesting(), provideNoopAnimations()],
imports: [CellModule, BrowserModule],
declarations: [TestComponent, TestWidget]
imports: [CellModule, BrowserModule]
});
};

Expand Down Expand Up @@ -117,22 +115,16 @@ describe('abc: cell', () => {
page.update(['1.jpg', '2.jpg'], { img: {} }).count('.img', 2);
});
it('should be preview array', () => {
const imgSrv = TestBed.inject(NzImageService);
spyOn(imgSrv, 'preview').and.returnValue({
switchTo: () => {}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any);
page
.update(['1.jpg', '2.jpg'], { img: { big: true } })
.count('.img', 2)
.click('.img');
expect(imgSrv.preview).toHaveBeenCalled();
const progress = document.querySelector('.ant-image-preview-operations-progress')?.innerHTML?.trim();
expect(progress).toBe('1 / 2');
});
it('should be disabled preview when big is false', () => {
const imgSrv = TestBed.inject(NzImageService);
spyOn(imgSrv, 'preview');
page.update(['1.jpg', '2.jpg'], { img: {} }).count('.img', 2).click('.img');
expect(imgSrv.preview).not.toHaveBeenCalled();
expect(document.querySelector('.ant-image-preview-operations-progress') == null).toBe(true);
});
it('should be reset big image', () => {
page.update(['1.jpg', '2.jpg'], { img: { big: src => `new${src}` } }).click('.img');
Expand Down Expand Up @@ -298,9 +290,7 @@ describe('abc: cell', () => {
describe('[widget]', () => {
it('via provideCellWidgets', () => {
TestBed.configureTestingModule({
imports: [CellModule, NoopAnimationsModule],
declarations: [TestComponent, TestWidget],
providers: [provideCellWidgets({ KEY: TestWidget.KEY, type: TestWidget })]
providers: [provideCellWidgets({ KEY: TestWidget.KEY, type: TestWidget }), provideNoopAnimations()]
});
({ fixture, dl, context } = createTestContext(TestComponent));
page = new PageObject();
Expand Down Expand Up @@ -356,9 +346,7 @@ describe('abc: cell', () => {
});

@Component({
template: `{{ data.result.text }}-{{ data.options.widget.data }}`,
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false
template: `{{ data.result.text }}-{{ data.options.widget.data }}`
})
class TestWidget {
static readonly KEY = 'test';
Expand All @@ -377,8 +365,7 @@ class TestWidget {
[disabled]="disabled"
/>
`,
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false
imports: [CellComponent]
})
class TestComponent {
@ViewChild('comp', { static: true })
Expand Down
18 changes: 5 additions & 13 deletions packages/abc/date-picker/range.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import { Component, DebugElement, ViewChild } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { provideNoopAnimations } from '@angular/platform-browser/animations';

import { differenceInDays } from 'date-fns';

import { createTestContext, dispatchMouseEvent } from '@delon/testing';
import { AlainDateRangePickerShortcut } from '@delon/util/config';
import { NzDatePickerModule } from 'ng-zorro-antd/date-picker';
import { NzDatePickerComponent, NzRangePickerComponent } from 'ng-zorro-antd/date-picker';

import { DatePickerModule } from './date-picker.module';
import { RangePickerDirective } from './range.directive';

registerLocaleData(zh);
Expand All @@ -24,10 +23,6 @@ describe('abc: date-picker: nz-range-picker[extend]', () => {

it('should be throw error when not attached to nz-range-picker component', () => {
expect(() => {
TestBed.configureTestingModule({
imports: [DatePickerModule, FormsModule, NoopAnimationsModule, NzDatePickerModule],
declarations: [TestThrowComponent]
});
createTestContext(TestThrowComponent);
fixture.detectChanges();
}).toThrow();
Expand All @@ -36,8 +31,7 @@ describe('abc: date-picker: nz-range-picker[extend]', () => {
describe('', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [DatePickerModule, FormsModule, NoopAnimationsModule, NzDatePickerModule],
declarations: [TestComponent]
providers: [provideNoopAnimations()]
});
({ fixture, dl, context } = createTestContext(TestComponent));
fixture.detectChanges();
Expand Down Expand Up @@ -119,8 +113,7 @@ describe('abc: date-picker: nz-range-picker[extend]', () => {
[shortcut]="shortcut"
/>
`,
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false
imports: [FormsModule, NzRangePickerComponent, NzDatePickerComponent, RangePickerDirective]
})
class TestComponent {
@ViewChild('comp', { static: true }) comp!: RangePickerDirective;
Expand All @@ -130,8 +123,7 @@ class TestComponent {

@Component({
template: ` <div [(ngModel)]="i.start" extend [(ngModelEnd)]="i.end"></div> `,
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false
imports: [FormsModule, RangePickerDirective]
})
class TestThrowComponent {
i: { start?: Date; end?: Date } = {};
Expand Down
9 changes: 4 additions & 5 deletions packages/abc/error-collect/error-collect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { Component, DebugElement, OnInit, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AbstractControl, UntypedFormBuilder, UntypedFormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { provideNoopAnimations } from '@angular/platform-browser/animations';

import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NzFormModule } from 'ng-zorro-antd/form';
import { NzInputDirective } from 'ng-zorro-antd/input';

import { ErrorCollectComponent } from './error-collect.component';
import { ErrorCollectModule } from './error-collect.module';

describe('abc: error-collect', () => {
let fixture: ComponentFixture<TestComponent>;
Expand All @@ -17,8 +18,7 @@ describe('abc: error-collect', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ErrorCollectModule, ReactiveFormsModule, NzFormModule],
declarations: [TestComponent]
providers: [provideNoopAnimations()]
});
});

Expand Down Expand Up @@ -98,8 +98,7 @@ describe('abc: error-collect', () => {
<error-collect #ec [freq]="freq" [offsetTop]="offsetTop" />
</form>
`,
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false
imports: [NzFormModule, NzInputDirective, ErrorCollectComponent, ReactiveFormsModule]
})
class TestComponent implements OnInit {
freq = 20;
Expand Down
8 changes: 2 additions & 6 deletions packages/abc/hotkey/hotkey.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ import { Component, ViewChild } from '@angular/core';
import { TestBed } from '@angular/core/testing';

import { HotkeyDirective } from './hotkey.directive';
import { HotkeyModule } from './hotkey.module';
import { createTestContext } from '../../testing';

describe('abc: hotkey', () => {
let context: TestComponent;

function genModule(isBrowser: boolean): void {
TestBed.configureTestingModule({
imports: [HotkeyModule],
providers: [{ provide: Platform, useValue: { isBrowser } }],
declarations: [TestComponent]
providers: [{ provide: Platform, useValue: { isBrowser } }]
});
({ context } = createTestContext(TestComponent));
spyOn(context, 'focus');
Expand Down Expand Up @@ -44,8 +41,7 @@ describe('abc: hotkey', () => {

@Component({
template: `<input #el hotkey="q" class="ipt" (focus)="focus()" />`,
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false
imports: [HotkeyDirective]
})
class TestComponent {
@ViewChild(HotkeyDirective, { static: true }) readonly comp!: HotkeyDirective;
Expand Down
25 changes: 23 additions & 2 deletions packages/abc/st/st-filter.component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NgTemplateOutlet } from '@angular/common';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Expand All @@ -8,8 +9,17 @@ import {
ViewEncapsulation,
inject
} from '@angular/core';
import { FormsModule } from '@angular/forms';

import type { LocaleData } from '@delon/theme';
import { NzCheckboxComponent } from 'ng-zorro-antd/checkbox';
import { NzDatePickerComponent, NzRangePickerComponent } from 'ng-zorro-antd/date-picker';
import { NzDropDownModule } from 'ng-zorro-antd/dropdown';
import { NzIconDirective } from 'ng-zorro-antd/icon';
import { NzInputDirective } from 'ng-zorro-antd/input';
import { NzInputNumberComponent } from 'ng-zorro-antd/input-number';
import { NzMenuModule } from 'ng-zorro-antd/menu';
import { NzRadioComponent } from 'ng-zorro-antd/radio';

import type { STColumnFilter, STColumnFilterMenu, STIcon } from './st.interfaces';
import type { _STColumn } from './st.types';
Expand Down Expand Up @@ -133,8 +143,19 @@ import type { _STColumn } from './st.types';
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false
imports: [
FormsModule,
NzDropDownModule,
NzIconDirective,
NzInputDirective,
NzInputNumberComponent,
NzRangePickerComponent,
NzDatePickerComponent,
NgTemplateOutlet,
NzMenuModule,
NzCheckboxComponent,
NzRadioComponent
]
})
export class STFilterComponent {
private readonly cdr = inject(ChangeDetectorRef);
Expand Down
4 changes: 1 addition & 3 deletions packages/abc/st/st-row.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export class STRowSource {
}

@Directive({
selector: '[st-row]',
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false
selector: '[st-row]'
})
export class STRowDirective implements OnInit {
private readonly source = inject(STRowSource, { host: true });
Expand Down
4 changes: 1 addition & 3 deletions packages/abc/st/st-widget-host.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { STWidgetRegistry } from './st-widget';
import { STColumn, STData } from './st.interfaces';

@Directive({
selector: '[st-widget-host]',
// eslint-disable-next-line @angular-eslint/prefer-standalone
standalone: false
selector: '[st-widget-host]'
})
export class STWidgetHostDirective implements OnInit {
private readonly stWidgetRegistry = inject(STWidgetRegistry);
Expand Down
Loading
Loading