Skip to content

Commit

Permalink
chore: 馃 upgrade prettier to v3 (#642)
Browse files Browse the repository at this point in the history
* chore: 馃 upgrade prettier to v3

- upgrade to prettier v3

* style: 馃拕 format code with prettier v3
  • Loading branch information
chimurai committed Mar 4, 2024
1 parent 8164446 commit e6f2a52
Show file tree
Hide file tree
Showing 142 changed files with 463 additions and 491 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -77,7 +77,7 @@
"karma-jasmine-html-reporter": "2.1.0",
"lint-staged": "^13.1.0",
"ng-packagr": "17.0.2",
"prettier": "2.3.2",
"prettier": "3.2.5",
"rxjs": "7.8.1",
"standard-version": "^9.1.0",
"ts-node": "10.1.0",
Expand Down
2 changes: 1 addition & 1 deletion projects/spectator/jest/src/lib/matchers-types.ts
Expand Up @@ -18,7 +18,7 @@ declare namespace jest {

toContainText(text: string | string[] | ((text: string) => boolean), exact?: boolean): boolean;

toHaveExactText(text: string | string[] | ((text: string) => boolean), options?: {trim: boolean}): boolean;
toHaveExactText(text: string | string[] | ((text: string) => boolean), options?: { trim: boolean }): boolean;

toHaveExactTrimmedText(text: string | string[] | ((text: string) => boolean)): boolean;

Expand Down
9 changes: 4 additions & 5 deletions projects/spectator/jest/src/lib/mock.ts
Expand Up @@ -4,11 +4,10 @@ import { FactoryProvider, AbstractType, Type } from '@angular/core';
import { installProtoMethods, CompatibleSpy, SpyObject as BaseSpyObject } from '@ngneat/spectator';
import { jest } from '@jest/globals';

export type SpyObject<T> = BaseSpyObject<T> &
{
[P in keyof T]: T[P] &
(T[P] extends (...args: any[]) => infer R ? (R extends (...args: any[]) => any ? jest.Mock<R> : jest.Mock<T[P]>) : T[P]);
};
export type SpyObject<T> = BaseSpyObject<T> & {
[P in keyof T]: T[P] &
(T[P] extends (...args: any[]) => infer R ? (R extends (...args: any[]) => any ? jest.Mock<R> : jest.Mock<T[P]>) : T[P]);
};

/**
* @publicApi
Expand Down
10 changes: 5 additions & 5 deletions projects/spectator/jest/src/lib/spectator-directive.ts
Expand Up @@ -25,31 +25,31 @@ export class SpectatorDirective<D, H = HostComponent> extends BaseSpectatorDirec
*/
export type SpectatorDirectiveFactory<D, H = HostComponent> = <HP>(
template: string,
overrides?: SpectatorDirectiveOverrides<H, HP>
overrides?: SpectatorDirectiveOverrides<H, HP>,
) => SpectatorDirective<D, H & HostComponent extends H ? HP : unknown>;

/**
* @publicApi
*/
export type PresetSpectatorDirectiveFactory<D, H> = <HP>(
template?: string,
overrides?: SpectatorDirectiveOverrides<H, HP>
overrides?: SpectatorDirectiveOverrides<H, HP>,
) => SpectatorDirective<D, H & HostComponent extends H ? HP : unknown>;

/**
* @publicApi
*/
export function createDirectiveFactory<D, H = HostComponent>(
options: SpectatorDirectiveOptions<D, H> & { template: string }
options: SpectatorDirectiveOptions<D, H> & { template: string },
): PresetSpectatorDirectiveFactory<D, H>;
/**
* @publicApi
*/
export function createDirectiveFactory<D, H = HostComponent>(
typeOrOptions: Type<D> | SpectatorDirectiveOptions<D, H>
typeOrOptions: Type<D> | SpectatorDirectiveOptions<D, H>,
): SpectatorDirectiveFactory<D, H>;
export function createDirectiveFactory<D, H = HostComponent>(
typeOrOptions: Type<D> | SpectatorDirectiveOptions<D, H>
typeOrOptions: Type<D> | SpectatorDirectiveOptions<D, H>,
): SpectatorDirectiveFactory<D, H> {
return baseCreateDirectiveFactory({
mockProvider,
Expand Down
6 changes: 3 additions & 3 deletions projects/spectator/jest/src/lib/spectator-host.ts
Expand Up @@ -25,22 +25,22 @@ export class SpectatorHost<C, H = HostComponent> extends BaseSpectatorHost<C, H>
*/
export type SpectatorHostFactory<C, H> = <HP>(
template: string,
overrides?: SpectatorHostOverrides<H, HP>
overrides?: SpectatorHostOverrides<H, HP>,
) => SpectatorHost<C, H & HostComponent extends H ? HP : unknown>;

/**
* @publicApi
*/
export type PresetSpectatorHostFactory<C, H> = <HP>(
template?: string,
overrides?: SpectatorHostOverrides<H, HP>
overrides?: SpectatorHostOverrides<H, HP>,
) => SpectatorHost<C, H & (HostComponent extends H ? HP : unknown)>;

/**
* @publicApi
*/
export function createHostFactory<C, H = HostComponent>(
options: SpectatorHostOptions<C, H> & { template: string }
options: SpectatorHostOptions<C, H> & { template: string },
): PresetSpectatorHostFactory<C, H>;
/**
* @publicApi
Expand Down
4 changes: 2 additions & 2 deletions projects/spectator/jest/src/lib/spectator-http.ts
Expand Up @@ -6,7 +6,7 @@ import {
HttpMethod,
SpectatorHttp as BaseSpectatorHttp,
SpectatorHttpOptions,
Token
Token,
} from '@ngneat/spectator';

import { mockProvider, SpyObject } from './mock';
Expand Down Expand Up @@ -34,6 +34,6 @@ export type SpectatorHttpFactory<S> = (overrides?: CreateHttpOverrides<S>) => Sp
export function createHttpFactory<S>(typeOrOptions: SpectatorHttpOptions<S> | Type<S>): SpectatorHttpFactory<S> {
return baseCreateHttpFactory({
mockProvider,
...(isType(typeOrOptions) ? { service: typeOrOptions } : typeOrOptions)
...(isType(typeOrOptions) ? { service: typeOrOptions } : typeOrOptions),
}) as SpectatorHttpFactory<S>;
}
6 changes: 3 additions & 3 deletions projects/spectator/jest/src/lib/spectator-pipe.ts
Expand Up @@ -6,7 +6,7 @@ import {
SpectatorPipe as BaseSpectatorPipe,
SpectatorPipeOptions,
SpectatorPipeOverrides,
Token
Token,
} from '@ngneat/spectator';

import { mockProvider, SpyObject } from './mock';
Expand All @@ -25,7 +25,7 @@ export class SpectatorPipe<P, H = HostComponent> extends BaseSpectatorPipe<P, H>
*/
export type SpectatorPipeFactory<P, H> = <HP>(
templateOrOverrides?: string | SpectatorPipeOverrides<H, HP>,
overrides?: SpectatorPipeOverrides<H, HP>
overrides?: SpectatorPipeOverrides<H, HP>,
) => SpectatorPipe<P, H & (HostComponent extends H ? HP : unknown)>;

/**
Expand All @@ -34,6 +34,6 @@ export type SpectatorPipeFactory<P, H> = <HP>(
export function createPipeFactory<P, H = HostComponent>(typeOrOptions: Type<P> | SpectatorPipeOptions<P, H>): SpectatorPipeFactory<P, H> {
return baseCreatePipeFactory({
mockProvider,
...(isType(typeOrOptions) ? { pipe: typeOrOptions } : typeOrOptions)
...(isType(typeOrOptions) ? { pipe: typeOrOptions } : typeOrOptions),
}) as SpectatorPipeFactory<P, H>;
}
4 changes: 2 additions & 2 deletions projects/spectator/jest/src/lib/spectator-routing.ts
Expand Up @@ -5,7 +5,7 @@ import {
SpectatorRouting as BaseSpectatorRouting,
SpectatorRoutingOptions,
SpectatorRoutingOverrides,
Token
Token,
} from '@ngneat/spectator';

import { mockProvider, SpyObject } from './mock';
Expand All @@ -30,6 +30,6 @@ export type SpectatorRoutingFactory<C> = (overrides?: SpectatorRoutingOverrides<
export function createRoutingFactory<C>(typeOrOptions: SpectatorRoutingOptions<C> | Type<C>): SpectatorRoutingFactory<C> {
return baseCreateRoutingFactory({
mockProvider,
...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions)
...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions),
}) as SpectatorRoutingFactory<C>;
}
4 changes: 2 additions & 2 deletions projects/spectator/jest/src/lib/spectator-service.ts
Expand Up @@ -5,7 +5,7 @@ import {
SpectatorServiceOverrides,
SpectatorServiceOptions,
SpectatorService as BaseSpectatorService,
Token
Token,
} from '@ngneat/spectator';

import { mockProvider, SpyObject } from './mock';
Expand All @@ -28,6 +28,6 @@ export type SpectatorServiceFactory<S> = (overrides?: SpectatorServiceOverrides<
export function createServiceFactory<S>(typeOrOptions: SpectatorServiceOptions<S> | Type<S>): SpectatorServiceFactory<S> {
return baseCreateServiceFactory({
mockProvider,
...(isType(typeOrOptions) ? { service: typeOrOptions } : typeOrOptions)
...(isType(typeOrOptions) ? { service: typeOrOptions } : typeOrOptions),
}) as SpectatorServiceFactory<S>;
}
4 changes: 2 additions & 2 deletions projects/spectator/jest/src/lib/spectator.ts
Expand Up @@ -5,7 +5,7 @@ import {
Spectator as BaseSpectator,
SpectatorOptions,
SpectatorOverrides,
Token
Token,
} from '@ngneat/spectator';

import { mockProvider, SpyObject } from './mock';
Expand All @@ -18,7 +18,7 @@ export type SpectatorFactory<C> = (options?: SpectatorOverrides<C>) => Spectator
export function createComponentFactory<C>(typeOrOptions: SpectatorOptions<C> | Type<C>): SpectatorFactory<C> {
return baseCreateComponentFactory({
mockProvider,
...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions)
...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions),
}) as SpectatorFactory<C>;
}

Expand Down
2 changes: 1 addition & 1 deletion projects/spectator/jest/test/auth.service.spec.ts
Expand Up @@ -11,7 +11,7 @@ describe('AuthService', () => {
let spectator: SpectatorService<AuthService>;
const createService = createServiceFactory({
service: AuthService,
mocks: [DateService]
mocks: [DateService],
});

beforeEach(() => (spectator = createService()));
Expand Down
10 changes: 5 additions & 5 deletions projects/spectator/jest/test/button/button.component.spec.ts
Expand Up @@ -9,7 +9,7 @@ describe('ButtonComponent', () => {

const createComponent = createComponentFactory<ButtonComponent>({
component: ButtonComponent,
componentProviders: [mockProvider(QueryService)]
componentProviders: [mockProvider(QueryService)],
});

beforeEach(() => (spectator = createComponent()));
Expand All @@ -26,23 +26,23 @@ describe('ButtonComponent', () => {

it('should set the title according to the [title]', () => {
spectator = createComponent({
props: { title: 'Click' }
props: { title: 'Click' },
});

expect(spectator.query('button')).toHaveText('Click');
});

it('should emit the $event on click', () => {
let output;
spectator.output<{ type: string }>('click').subscribe(result => (output = result));
spectator.output<{ type: string }>('click').subscribe((result) => (output = result));

spectator.component.onClick({ type: 'click' });
expect(output).toEqual({ type: 'click' });
});

it('should mock the service', () => {
spectator = createComponent({
detectChanges: false
detectChanges: false,
});
spectator.inject(QueryService, true).selectName.mockReturnValue(of('Netanel'));
spectator.detectChanges();
Expand All @@ -56,7 +56,7 @@ describe('ButtonComponent', () => {
const createComponent = createComponentFactory<ButtonComponent>({
component: ButtonComponent,
componentProviders: [mockProvider(QueryService)],
detectChanges: false
detectChanges: false,
});

beforeEach(() => (spectator = createComponent()));
Expand Down
Expand Up @@ -9,7 +9,7 @@ describe('ConsumeDynamicComponent', () => {
const createHost = createHostFactory({
declarations: [DynamicComponent],
entryComponents: [DynamicComponent],
component: ConsumeDynamicComponent
component: ConsumeDynamicComponent,
});

it('should work', () => {
Expand Down
6 changes: 3 additions & 3 deletions projects/spectator/jest/test/consumer.service.spec.ts
Expand Up @@ -13,9 +13,9 @@ describe('ConsumerService', () => {
providers: [
mockProvider(ProviderService, {
obs$: new Subject<string>(),
method: () => randomNumber
})
]
method: () => randomNumber,
}),
],
});

beforeEach(() => (spectator = createService()));
Expand Down
Expand Up @@ -16,7 +16,7 @@ describe('DomSelectorsComponent', () => {
let spectator: Spectator<DomSelectorsComponent>;
const createComponent = createComponentFactory({
component: DomSelectorsComponent,
imports: [DomSelectorsNestedComponent]
imports: [DomSelectorsNestedComponent],
});

beforeEach(() => {
Expand Down Expand Up @@ -101,23 +101,23 @@ describe('DomSelectorsComponent', () => {

it('should support `collapseWhitespace` option', () => {
let element = spectator.query(
byTextContent('deeply NESTED', { selector: '#text-content-span-1', exact: true, collapseWhitespace: false })
byTextContent('deeply NESTED', { selector: '#text-content-span-1', exact: true, collapseWhitespace: false }),
);
expect(element).toBeNull();
element = spectator.query(
byTextContent('deeply NESTED', { selector: '#text-content-span-1', exact: true, collapseWhitespace: false })
byTextContent('deeply NESTED', { selector: '#text-content-span-1', exact: true, collapseWhitespace: false }),
);
expect(element).toHaveId('text-content-span-1');
});

it('should support custom normalizer', () => {
const toLowerCase = (text: string) => text.toLowerCase();
let element = spectator.query(
byTextContent('deeply NESTED', { selector: '#text-content-span-1', exact: true, normalizer: toLowerCase })
byTextContent('deeply NESTED', { selector: '#text-content-span-1', exact: true, normalizer: toLowerCase }),
);
expect(element).toBeNull();
element = spectator.query(
byTextContent('deeply nested', { selector: '#text-content-span-1', exact: true, normalizer: toLowerCase })
byTextContent('deeply nested', { selector: '#text-content-span-1', exact: true, normalizer: toLowerCase }),
);
expect(element).toHaveId('text-content-span-1');
});
Expand Down Expand Up @@ -150,7 +150,7 @@ describe('DomSelectorsComponent', () => {

it('should support `collapseWhitespace` option', () => {
const element = spectator.query(
byTextContent(/^deeply\s\sNESTED$/, { selector: '#text-content-span-1', collapseWhitespace: false })
byTextContent(/^deeply\s\sNESTED$/, { selector: '#text-content-span-1', collapseWhitespace: false }),
);
expect(element).toHaveId('text-content-span-1');
});
Expand Down
Expand Up @@ -3,13 +3,12 @@ import { SpectatorHost, createHostFactory } from '@ngneat/spectator/jest';
import { TestFocusComponent } from '../../../test/focus/test-focus.component';

describe('SpectatorHost.focus() in jest', () => {

const createHost = createHostFactory(TestFocusComponent);
let host: SpectatorHost<TestFocusComponent>;

beforeEach(() => {
host = createHost('<app-test-focus></app-test-focus>');
})
});

it('sets document.activeElement', () => {
host.focus('#button1');
Expand All @@ -30,7 +29,6 @@ describe('SpectatorHost.focus() in jest', () => {
expect(host.component.blurCount('button2')).toBe(0);
});


it('calling focus() multiple times does not cause multiple patches', () => {
host.focus('#button1');
host.focus();
Expand All @@ -40,5 +38,4 @@ describe('SpectatorHost.focus() in jest', () => {
expect(host.component.focusCount('button1')).toBe(2);
expect(host.component.blurCount('button1')).toBe(1);
});

});
Expand Up @@ -9,7 +9,7 @@ import { Component, ChangeDetectionStrategy } from '@angular/core';
<option value="3">3</option>
</select>
`,
changeDetection: ChangeDetectionStrategy.OnPush
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FormSelectComponent {
/**
Expand Down

0 comments on commit e6f2a52

Please sign in to comment.