diff --git a/package.json b/package.json index a2219354..a258d538 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/projects/spectator/jest/src/lib/matchers-types.ts b/projects/spectator/jest/src/lib/matchers-types.ts index fe5ad8ab..6daa9c55 100644 --- a/projects/spectator/jest/src/lib/matchers-types.ts +++ b/projects/spectator/jest/src/lib/matchers-types.ts @@ -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; diff --git a/projects/spectator/jest/src/lib/mock.ts b/projects/spectator/jest/src/lib/mock.ts index 14736701..a7e00404 100644 --- a/projects/spectator/jest/src/lib/mock.ts +++ b/projects/spectator/jest/src/lib/mock.ts @@ -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 = BaseSpyObject & - { - [P in keyof T]: T[P] & - (T[P] extends (...args: any[]) => infer R ? (R extends (...args: any[]) => any ? jest.Mock : jest.Mock) : T[P]); - }; +export type SpyObject = BaseSpyObject & { + [P in keyof T]: T[P] & + (T[P] extends (...args: any[]) => infer R ? (R extends (...args: any[]) => any ? jest.Mock : jest.Mock) : T[P]); +}; /** * @publicApi diff --git a/projects/spectator/jest/src/lib/spectator-directive.ts b/projects/spectator/jest/src/lib/spectator-directive.ts index f4c3ccc6..6950d4bc 100644 --- a/projects/spectator/jest/src/lib/spectator-directive.ts +++ b/projects/spectator/jest/src/lib/spectator-directive.ts @@ -25,7 +25,7 @@ export class SpectatorDirective extends BaseSpectatorDirec */ export type SpectatorDirectiveFactory = ( template: string, - overrides?: SpectatorDirectiveOverrides + overrides?: SpectatorDirectiveOverrides, ) => SpectatorDirective; /** @@ -33,23 +33,23 @@ export type SpectatorDirectiveFactory = ( */ export type PresetSpectatorDirectiveFactory = ( template?: string, - overrides?: SpectatorDirectiveOverrides + overrides?: SpectatorDirectiveOverrides, ) => SpectatorDirective; /** * @publicApi */ export function createDirectiveFactory( - options: SpectatorDirectiveOptions & { template: string } + options: SpectatorDirectiveOptions & { template: string }, ): PresetSpectatorDirectiveFactory; /** * @publicApi */ export function createDirectiveFactory( - typeOrOptions: Type | SpectatorDirectiveOptions + typeOrOptions: Type | SpectatorDirectiveOptions, ): SpectatorDirectiveFactory; export function createDirectiveFactory( - typeOrOptions: Type | SpectatorDirectiveOptions + typeOrOptions: Type | SpectatorDirectiveOptions, ): SpectatorDirectiveFactory { return baseCreateDirectiveFactory({ mockProvider, diff --git a/projects/spectator/jest/src/lib/spectator-host.ts b/projects/spectator/jest/src/lib/spectator-host.ts index afc98fbe..ca9eb371 100644 --- a/projects/spectator/jest/src/lib/spectator-host.ts +++ b/projects/spectator/jest/src/lib/spectator-host.ts @@ -25,7 +25,7 @@ export class SpectatorHost extends BaseSpectatorHost */ export type SpectatorHostFactory = ( template: string, - overrides?: SpectatorHostOverrides + overrides?: SpectatorHostOverrides, ) => SpectatorHost; /** @@ -33,14 +33,14 @@ export type SpectatorHostFactory = ( */ export type PresetSpectatorHostFactory = ( template?: string, - overrides?: SpectatorHostOverrides + overrides?: SpectatorHostOverrides, ) => SpectatorHost; /** * @publicApi */ export function createHostFactory( - options: SpectatorHostOptions & { template: string } + options: SpectatorHostOptions & { template: string }, ): PresetSpectatorHostFactory; /** * @publicApi diff --git a/projects/spectator/jest/src/lib/spectator-http.ts b/projects/spectator/jest/src/lib/spectator-http.ts index 795fa149..e73b2c3e 100644 --- a/projects/spectator/jest/src/lib/spectator-http.ts +++ b/projects/spectator/jest/src/lib/spectator-http.ts @@ -6,7 +6,7 @@ import { HttpMethod, SpectatorHttp as BaseSpectatorHttp, SpectatorHttpOptions, - Token + Token, } from '@ngneat/spectator'; import { mockProvider, SpyObject } from './mock'; @@ -34,6 +34,6 @@ export type SpectatorHttpFactory = (overrides?: CreateHttpOverrides) => Sp export function createHttpFactory(typeOrOptions: SpectatorHttpOptions | Type): SpectatorHttpFactory { return baseCreateHttpFactory({ mockProvider, - ...(isType(typeOrOptions) ? { service: typeOrOptions } : typeOrOptions) + ...(isType(typeOrOptions) ? { service: typeOrOptions } : typeOrOptions), }) as SpectatorHttpFactory; } diff --git a/projects/spectator/jest/src/lib/spectator-pipe.ts b/projects/spectator/jest/src/lib/spectator-pipe.ts index 17abc252..3da22582 100644 --- a/projects/spectator/jest/src/lib/spectator-pipe.ts +++ b/projects/spectator/jest/src/lib/spectator-pipe.ts @@ -6,7 +6,7 @@ import { SpectatorPipe as BaseSpectatorPipe, SpectatorPipeOptions, SpectatorPipeOverrides, - Token + Token, } from '@ngneat/spectator'; import { mockProvider, SpyObject } from './mock'; @@ -25,7 +25,7 @@ export class SpectatorPipe extends BaseSpectatorPipe */ export type SpectatorPipeFactory = ( templateOrOverrides?: string | SpectatorPipeOverrides, - overrides?: SpectatorPipeOverrides + overrides?: SpectatorPipeOverrides, ) => SpectatorPipe; /** @@ -34,6 +34,6 @@ export type SpectatorPipeFactory = ( export function createPipeFactory(typeOrOptions: Type

| SpectatorPipeOptions): SpectatorPipeFactory { return baseCreatePipeFactory({ mockProvider, - ...(isType(typeOrOptions) ? { pipe: typeOrOptions } : typeOrOptions) + ...(isType(typeOrOptions) ? { pipe: typeOrOptions } : typeOrOptions), }) as SpectatorPipeFactory; } diff --git a/projects/spectator/jest/src/lib/spectator-routing.ts b/projects/spectator/jest/src/lib/spectator-routing.ts index b6141acd..d8bd9019 100644 --- a/projects/spectator/jest/src/lib/spectator-routing.ts +++ b/projects/spectator/jest/src/lib/spectator-routing.ts @@ -5,7 +5,7 @@ import { SpectatorRouting as BaseSpectatorRouting, SpectatorRoutingOptions, SpectatorRoutingOverrides, - Token + Token, } from '@ngneat/spectator'; import { mockProvider, SpyObject } from './mock'; @@ -30,6 +30,6 @@ export type SpectatorRoutingFactory = (overrides?: SpectatorRoutingOverrides< export function createRoutingFactory(typeOrOptions: SpectatorRoutingOptions | Type): SpectatorRoutingFactory { return baseCreateRoutingFactory({ mockProvider, - ...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions) + ...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions), }) as SpectatorRoutingFactory; } diff --git a/projects/spectator/jest/src/lib/spectator-service.ts b/projects/spectator/jest/src/lib/spectator-service.ts index 11e3e89e..5f5629eb 100644 --- a/projects/spectator/jest/src/lib/spectator-service.ts +++ b/projects/spectator/jest/src/lib/spectator-service.ts @@ -5,7 +5,7 @@ import { SpectatorServiceOverrides, SpectatorServiceOptions, SpectatorService as BaseSpectatorService, - Token + Token, } from '@ngneat/spectator'; import { mockProvider, SpyObject } from './mock'; @@ -28,6 +28,6 @@ export type SpectatorServiceFactory = (overrides?: SpectatorServiceOverrides< export function createServiceFactory(typeOrOptions: SpectatorServiceOptions | Type): SpectatorServiceFactory { return baseCreateServiceFactory({ mockProvider, - ...(isType(typeOrOptions) ? { service: typeOrOptions } : typeOrOptions) + ...(isType(typeOrOptions) ? { service: typeOrOptions } : typeOrOptions), }) as SpectatorServiceFactory; } diff --git a/projects/spectator/jest/src/lib/spectator.ts b/projects/spectator/jest/src/lib/spectator.ts index 5ace27ae..cbefc4ee 100644 --- a/projects/spectator/jest/src/lib/spectator.ts +++ b/projects/spectator/jest/src/lib/spectator.ts @@ -5,7 +5,7 @@ import { Spectator as BaseSpectator, SpectatorOptions, SpectatorOverrides, - Token + Token, } from '@ngneat/spectator'; import { mockProvider, SpyObject } from './mock'; @@ -18,7 +18,7 @@ export type SpectatorFactory = (options?: SpectatorOverrides) => Spectator export function createComponentFactory(typeOrOptions: SpectatorOptions | Type): SpectatorFactory { return baseCreateComponentFactory({ mockProvider, - ...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions) + ...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions), }) as SpectatorFactory; } diff --git a/projects/spectator/jest/test/auth.service.spec.ts b/projects/spectator/jest/test/auth.service.spec.ts index 306da96d..30a9611c 100644 --- a/projects/spectator/jest/test/auth.service.spec.ts +++ b/projects/spectator/jest/test/auth.service.spec.ts @@ -11,7 +11,7 @@ describe('AuthService', () => { let spectator: SpectatorService; const createService = createServiceFactory({ service: AuthService, - mocks: [DateService] + mocks: [DateService], }); beforeEach(() => (spectator = createService())); diff --git a/projects/spectator/jest/test/button/button.component.spec.ts b/projects/spectator/jest/test/button/button.component.spec.ts index 862a7297..4574225d 100644 --- a/projects/spectator/jest/test/button/button.component.spec.ts +++ b/projects/spectator/jest/test/button/button.component.spec.ts @@ -9,7 +9,7 @@ describe('ButtonComponent', () => { const createComponent = createComponentFactory({ component: ButtonComponent, - componentProviders: [mockProvider(QueryService)] + componentProviders: [mockProvider(QueryService)], }); beforeEach(() => (spectator = createComponent())); @@ -26,7 +26,7 @@ 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'); @@ -34,7 +34,7 @@ describe('ButtonComponent', () => { 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' }); @@ -42,7 +42,7 @@ describe('ButtonComponent', () => { it('should mock the service', () => { spectator = createComponent({ - detectChanges: false + detectChanges: false, }); spectator.inject(QueryService, true).selectName.mockReturnValue(of('Netanel')); spectator.detectChanges(); @@ -56,7 +56,7 @@ describe('ButtonComponent', () => { const createComponent = createComponentFactory({ component: ButtonComponent, componentProviders: [mockProvider(QueryService)], - detectChanges: false + detectChanges: false, }); beforeEach(() => (spectator = createComponent())); diff --git a/projects/spectator/jest/test/consum-dynamic/consume-dynamic.component.spec.ts b/projects/spectator/jest/test/consum-dynamic/consume-dynamic.component.spec.ts index 6918c143..2f8925fb 100644 --- a/projects/spectator/jest/test/consum-dynamic/consume-dynamic.component.spec.ts +++ b/projects/spectator/jest/test/consum-dynamic/consume-dynamic.component.spec.ts @@ -9,7 +9,7 @@ describe('ConsumeDynamicComponent', () => { const createHost = createHostFactory({ declarations: [DynamicComponent], entryComponents: [DynamicComponent], - component: ConsumeDynamicComponent + component: ConsumeDynamicComponent, }); it('should work', () => { diff --git a/projects/spectator/jest/test/consumer.service.spec.ts b/projects/spectator/jest/test/consumer.service.spec.ts index 382ddbb8..f2250b41 100644 --- a/projects/spectator/jest/test/consumer.service.spec.ts +++ b/projects/spectator/jest/test/consumer.service.spec.ts @@ -13,9 +13,9 @@ describe('ConsumerService', () => { providers: [ mockProvider(ProviderService, { obs$: new Subject(), - method: () => randomNumber - }) - ] + method: () => randomNumber, + }), + ], }); beforeEach(() => (spectator = createService())); diff --git a/projects/spectator/jest/test/dom-selectors/dom-selectors.component.spec.ts b/projects/spectator/jest/test/dom-selectors/dom-selectors.component.spec.ts index 090bc771..d020a8cf 100644 --- a/projects/spectator/jest/test/dom-selectors/dom-selectors.component.spec.ts +++ b/projects/spectator/jest/test/dom-selectors/dom-selectors.component.spec.ts @@ -16,7 +16,7 @@ describe('DomSelectorsComponent', () => { let spectator: Spectator; const createComponent = createComponentFactory({ component: DomSelectorsComponent, - imports: [DomSelectorsNestedComponent] + imports: [DomSelectorsNestedComponent], }); beforeEach(() => { @@ -101,11 +101,11 @@ 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'); }); @@ -113,11 +113,11 @@ describe('DomSelectorsComponent', () => { 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'); }); @@ -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'); }); diff --git a/projects/spectator/jest/test/focus/test-focus.component.spec.ts b/projects/spectator/jest/test/focus/test-focus.component.spec.ts index b33f6f11..a13c2ebd 100644 --- a/projects/spectator/jest/test/focus/test-focus.component.spec.ts +++ b/projects/spectator/jest/test/focus/test-focus.component.spec.ts @@ -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; beforeEach(() => { host = createHost(''); - }) + }); it('sets document.activeElement', () => { host.focus('#button1'); @@ -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(); @@ -40,5 +38,4 @@ describe('SpectatorHost.focus() in jest', () => { expect(host.component.focusCount('button1')).toBe(2); expect(host.component.blurCount('button1')).toBe(1); }); - }); diff --git a/projects/spectator/jest/test/form-select/form-select.component.ts b/projects/spectator/jest/test/form-select/form-select.component.ts index 5178826c..40992104 100644 --- a/projects/spectator/jest/test/form-select/form-select.component.ts +++ b/projects/spectator/jest/test/form-select/form-select.component.ts @@ -9,7 +9,7 @@ import { Component, ChangeDetectionStrategy } from '@angular/core'; `, - changeDetection: ChangeDetectionStrategy.OnPush + changeDetection: ChangeDetectionStrategy.OnPush, }) export class FormSelectComponent { /** diff --git a/projects/spectator/jest/test/injection-and-mocking.spec.ts b/projects/spectator/jest/test/injection-and-mocking.spec.ts index 7e2f0692..b4bd0a04 100644 --- a/projects/spectator/jest/test/injection-and-mocking.spec.ts +++ b/projects/spectator/jest/test/injection-and-mocking.spec.ts @@ -4,7 +4,7 @@ import { Spectator, SpectatorHost, SpectatorService, - createServiceFactory + createServiceFactory, } from '@ngneat/spectator/jest'; import { InjectionToken } from '@angular/core'; @@ -24,13 +24,13 @@ describe('Injection tokens', () => { QueryService, { provide: AbstractQueryService, - useExisting: QueryService + useExisting: QueryService, }, { provide: MY_TOKEN, - useExisting: QueryService - } - ] + useExisting: QueryService, + }, + ], }); let spectator: Spectator; @@ -76,13 +76,13 @@ describe('Injection tokens', () => { QueryService, { provide: AbstractQueryService, - useExisting: QueryService + useExisting: QueryService, }, { provide: MY_TOKEN, - useExisting: QueryService - } - ] + useExisting: QueryService, + }, + ], }); let host: SpectatorHost; @@ -128,13 +128,13 @@ describe('Injection tokens', () => { QueryService, { provide: AbstractQueryService, - useExisting: QueryService + useExisting: QueryService, }, { provide: MY_TOKEN, - useExisting: QueryService - } - ] + useExisting: QueryService, + }, + ], }); let spectator: SpectatorService; diff --git a/projects/spectator/jest/test/matchers/matchers.spec.ts b/projects/spectator/jest/test/matchers/matchers.spec.ts index 19481965..24111e64 100644 --- a/projects/spectator/jest/test/matchers/matchers.spec.ts +++ b/projects/spectator/jest/test/matchers/matchers.spec.ts @@ -32,16 +32,19 @@ describe('Matchers', () => { let spectator: Spectator; beforeEach(() => { - if(!window.customElements.get("custom-element")) { - window.customElements.define("custom-element", class extends HTMLElement { - connectedCallback() { - if (this.isConnected && !this.shadowRoot) { - const el = document.createElement("div") - el.id = "shadow-dom" - this.attachShadow({ mode: 'open' }).appendChild(el); + if (!window.customElements.get('custom-element')) { + window.customElements.define( + 'custom-element', + class extends HTMLElement { + connectedCallback() { + if (this.isConnected && !this.shadowRoot) { + const el = document.createElement('div'); + el.id = 'shadow-dom'; + this.attachShadow({ mode: 'open' }).appendChild(el); + } } - } - }) + }, + ); } spectator = createComponent(); }); @@ -118,9 +121,7 @@ describe('Matchers', () => { }); it('should detect elements with hidden parents through shadow DOMs', () => { - expect( - document.querySelector('custom-element')?.shadowRoot?.querySelector("#shadow-dom") - ).toBeHidden(); + expect(document.querySelector('custom-element')?.shadowRoot?.querySelector('#shadow-dom')).toBeHidden(); }); it('should detect elements whose computed styles are display: none', () => { diff --git a/projects/spectator/jest/test/mock.spec.ts b/projects/spectator/jest/test/mock.spec.ts index ccbd1401..8afada1e 100644 --- a/projects/spectator/jest/test/mock.spec.ts +++ b/projects/spectator/jest/test/mock.spec.ts @@ -5,12 +5,12 @@ import { WidgetService } from '../../test/widget.service'; describe('mockProvider', () => { it('should not modify the object passed in 2nd argument when running the mock factory', () => { const customPropertiesAndMethods: Partial> = { - testingProperty: 'overriden' + testingProperty: 'overriden', }; const { useFactory: factory } = mockProvider(WidgetService, customPropertiesAndMethods); factory(); expect(customPropertiesAndMethods).toEqual({ - testingProperty: 'overriden' + testingProperty: 'overriden', }); }); }); diff --git a/projects/spectator/jest/test/no-overwritten-providers/no-overwritten-providers.component.spec.ts b/projects/spectator/jest/test/no-overwritten-providers/no-overwritten-providers.component.spec.ts index 9e256fde..95e9fb4b 100644 --- a/projects/spectator/jest/test/no-overwritten-providers/no-overwritten-providers.component.spec.ts +++ b/projects/spectator/jest/test/no-overwritten-providers/no-overwritten-providers.component.spec.ts @@ -8,7 +8,7 @@ describe('ComponentWithoutOverwrittenProvidersComponent', () => { describe('with options', () => { const createHost = createHostFactory({ component: ComponentWithoutOverwrittenProvidersComponent, - componentProviders: [mockProvider(DummyService)] + componentProviders: [mockProvider(DummyService)], }); it('should not overwrite components providers and work using createHostFactory', () => { diff --git a/projects/spectator/jest/test/override-component.spec.ts b/projects/spectator/jest/test/override-component.spec.ts index 82cfbc60..691d6321 100644 --- a/projects/spectator/jest/test/override-component.spec.ts +++ b/projects/spectator/jest/test/override-component.spec.ts @@ -52,7 +52,7 @@ describe('Override Component', () => { }, ], ], - } as any) + } as any), ).toThrowError('Can not override non standalone component'); }); diff --git a/projects/spectator/jest/test/override-directive.spec.ts b/projects/spectator/jest/test/override-directive.spec.ts index 93faa051..0c437434 100644 --- a/projects/spectator/jest/test/override-directive.spec.ts +++ b/projects/spectator/jest/test/override-directive.spec.ts @@ -1,9 +1,6 @@ -import { - createDirectiveFactory, - SpectatorDirective, -} from '@ngneat/spectator'; +import { createDirectiveFactory, SpectatorDirective } from '@ngneat/spectator'; import { Directive, Inject, InjectionToken } from '@angular/core'; -import { overrideDirectives } from "../../src/lib/spectator/create-factory"; +import { overrideDirectives } from '../../src/lib/spectator/create-factory'; // Created only for testing purpose export const directiveProviderToken = new InjectionToken('DirectiveProviderToken'); @@ -36,7 +33,7 @@ describe('Override Directive', () => { }, ], ], - } as any) + } as any), ).toThrowError('Can not override non standalone directive'); }); @@ -54,7 +51,7 @@ describe('Override Directive', () => { }, ], ], - template: `

Testing Directive Providers
` + template: `
Testing Directive Providers
`, }); beforeEach(() => { diff --git a/projects/spectator/jest/test/override-module.spec.ts b/projects/spectator/jest/test/override-module.spec.ts index e1a3eab2..27b4f5c5 100644 --- a/projects/spectator/jest/test/override-module.spec.ts +++ b/projects/spectator/jest/test/override-module.spec.ts @@ -22,7 +22,7 @@ describe('Override Module With Component Factory', () => { const createComponent = createComponentFactory({ component: TestComponent, imports: [SomeModule], - overrideModules: [[SomeModule, { set: { declarations: [AveragePipe], exports: [AveragePipe] } }]] + overrideModules: [[SomeModule, { set: { declarations: [AveragePipe], exports: [AveragePipe] } }]], }); beforeEach(() => { @@ -41,7 +41,7 @@ describe('Override Module With Directive Factory', () => { directive: SomeDirective, host: TestComponent, imports: [SomeModule], - overrideModules: [[SomeModule, { set: { declarations: [AveragePipe], exports: [AveragePipe] } }]] + overrideModules: [[SomeModule, { set: { declarations: [AveragePipe], exports: [AveragePipe] } }]], }); beforeEach(() => { @@ -59,7 +59,7 @@ describe('Override Module With Host Factory', () => { const createHost = createHostFactory({ component: TestComponent, imports: [SomeModule], - overrideModules: [[SomeModule, { set: { declarations: [AveragePipe], exports: [AveragePipe] } }]] + overrideModules: [[SomeModule, { set: { declarations: [AveragePipe], exports: [AveragePipe] } }]], }); beforeEach(() => { diff --git a/projects/spectator/jest/test/override-pipe.spec.ts b/projects/spectator/jest/test/override-pipe.spec.ts index 7f5f522a..eb6ed50c 100644 --- a/projects/spectator/jest/test/override-pipe.spec.ts +++ b/projects/spectator/jest/test/override-pipe.spec.ts @@ -1,12 +1,12 @@ import { Pipe, PipeTransform } from '@angular/core'; -import { createPipeFactory, SpectatorPipe } from "@ngneat/spectator"; -import { overridePipes } from "../../src/lib/spectator/create-factory"; +import { createPipeFactory, SpectatorPipe } from '@ngneat/spectator'; +import { overridePipes } from '../../src/lib/spectator/create-factory'; // Created only for testing purpose @Pipe({ name: `standalonePipe`, standalone: true, - pure: false + pure: false, }) export class StandalonePipe implements PipeTransform { public transform(value: number[]): number[] { @@ -29,12 +29,12 @@ describe('Override Pipe', () => { [ MockNonStandalonePipe, { - remove: {imports: []}, - add: {imports: []}, + remove: { imports: [] }, + add: { imports: [] }, }, ], ], - } as any) + } as any), ).toThrowError('Can not override non standalone pipe'); }); @@ -59,8 +59,8 @@ describe('Override Pipe', () => { }); it('should render a StandaloneWithImportsComponent', () => { - expect(spectator).toBeTruthy() - expect(spectator.element).toHaveText('1,2,3') + expect(spectator).toBeTruthy(); + expect(spectator.element).toHaveText('1,2,3'); }); }); }); diff --git a/projects/spectator/jest/test/todos-data.service.spec.ts b/projects/spectator/jest/test/todos-data.service.spec.ts index fdeabc04..c65037c4 100644 --- a/projects/spectator/jest/test/todos-data.service.spec.ts +++ b/projects/spectator/jest/test/todos-data.service.spec.ts @@ -7,7 +7,7 @@ import { TodosDataService, UserService } from '../../test/todos-data.service'; describe('HttpClient testing', () => { const http = createHttpFactory({ service: TodosDataService, - mocks: [UserService] + mocks: [UserService], }); it('can test HttpClient.get', () => { diff --git a/projects/spectator/jest/test/view-children/view-children.component.spec.ts b/projects/spectator/jest/test/view-children/view-children.component.spec.ts index 02c6bb78..b81b9ca5 100644 --- a/projects/spectator/jest/test/view-children/view-children.component.spec.ts +++ b/projects/spectator/jest/test/view-children/view-children.component.spec.ts @@ -10,7 +10,7 @@ describe('ViewChildrenComponent', () => { const createComponent = createComponentFactory({ component: ViewChildrenComponent, providers: [ChildServiceService], - declarations: [ChildComponent] + declarations: [ChildComponent], }); beforeEach(() => (spectator = createComponent())); @@ -24,7 +24,7 @@ describe('ViewChildrenComponent', () => { const div = spectator.query('div'); const component = spectator.query(ChildComponent); spectator.query(ChildComponent, { - read: ElementRef + read: ElementRef, }); const button = spectator.query('button'); @@ -52,7 +52,7 @@ describe('ContentChild', () => { const createHost = createHostFactory({ component: ViewChildrenComponent, providers: [ChildServiceService], - declarations: [ChildComponent] + declarations: [ChildComponent], }); it('should get also the content childs', () => { diff --git a/projects/spectator/jest/test/widget.service.spec.ts b/projects/spectator/jest/test/widget.service.spec.ts index c103f10f..00696d4e 100644 --- a/projects/spectator/jest/test/widget.service.spec.ts +++ b/projects/spectator/jest/test/widget.service.spec.ts @@ -7,7 +7,7 @@ describe('WidgetService', () => { let spectator: SpectatorService; const createService = createServiceFactory({ service: WidgetService, - mocks: [WidgetDataService] + mocks: [WidgetDataService], }); beforeEach(() => (spectator = createService())); diff --git a/projects/spectator/jest/test/widget/widget.component.spec.ts b/projects/spectator/jest/test/widget/widget.component.spec.ts index 81d05682..e234a461 100644 --- a/projects/spectator/jest/test/widget/widget.component.spec.ts +++ b/projects/spectator/jest/test/widget/widget.component.spec.ts @@ -8,7 +8,7 @@ describe('WidgetComponent', () => { const createHost = createHostFactory({ component: WidgetComponent, - mocks: [WidgetService] + mocks: [WidgetService], }); it('should work', () => { diff --git a/projects/spectator/schematics/src/spectator/index.ts b/projects/spectator/schematics/src/spectator/index.ts index 1755b609..a5bacb44 100644 --- a/projects/spectator/schematics/src/spectator/index.ts +++ b/projects/spectator/schematics/src/spectator/index.ts @@ -40,7 +40,7 @@ export function spectatorComponentSchematic(options: ComponentOptions): Rule { ...options, }), move(movePath), - ] + ], ); return mergeWith(specTemplateRule, MergeStrategy.Default); diff --git a/projects/spectator/src/lib/base/dom-spectator.ts b/projects/spectator/src/lib/base/dom-spectator.ts index 41815a56..04faef7e 100644 --- a/projects/spectator/src/lib/base/dom-spectator.ts +++ b/projects/spectator/src/lib/base/dom-spectator.ts @@ -22,7 +22,12 @@ const KEY_UP = 'keyup'; * @internal */ export abstract class DomSpectator extends BaseSpectator { - constructor(public fixture: ComponentFixture, public debugElement: DebugElement, protected instance: I, public element: Element) { + constructor( + public fixture: ComponentFixture, + public debugElement: DebugElement, + protected instance: I, + public element: Element, + ) { super(); } @@ -40,7 +45,7 @@ export abstract class DomSpectator extends BaseSpectator { public query(directive: Type, options?: { parentSelector?: Type | string }): R | null; public query( directiveOrSelector: Type | string, - options: { read: Token; root?: boolean; parentSelector?: Type | string } + options: { read: Token; root?: boolean; parentSelector?: Type | string }, ): R | null; public query(directiveOrSelector: QueryType, options?: QueryOptions): R | Element | null { if ((options || {}).root) { @@ -80,7 +85,7 @@ export abstract class DomSpectator extends BaseSpectator { public queryAll(directive: Type, options?: { parentSelector: Type | string }): R[]; public queryAll( directiveOrSelector: Type | string, - options: { read: Token; root?: boolean; parentSelector?: Type | string } + options: { read: Token; root?: boolean; parentSelector?: Type | string }, ): R[]; public queryAll(directiveOrSelector: QueryType, options?: QueryOptions): R[] | Element[] { if ((options || {}).root) { @@ -118,7 +123,7 @@ export abstract class DomSpectator extends BaseSpectator { public queryLast(directive: Type, options?: { parentSelector: Type | string }): R | null; public queryLast( directiveOrSelector: Type | string, - options: { read: Token; root?: boolean; parentSelector?: Type | string } + options: { read: Token; root?: boolean; parentSelector?: Type | string }, ): R | null; public queryLast(directiveOrSelector: QueryType, options?: QueryOptions): R | Element | null { let result: (R | Element)[] = []; @@ -209,7 +214,7 @@ export abstract class DomSpectator extends BaseSpectator { type: string, x: number = 0, y: number = 0, - event: MouseEvent = createMouseEvent(type, x, y) + event: MouseEvent = createMouseEvent(type, x, y), ): MouseEvent { const element = this.getNativeElement(selector); @@ -230,7 +235,7 @@ export abstract class DomSpectator extends BaseSpectator { selector: SpectatorElement = this.element, type: string, keyOrKeyCode: string | number | KeyboardEventOptions, - target?: Element + target?: Element, ): KeyboardEvent { const element = this.getNativeElement(selector); @@ -256,7 +261,7 @@ export abstract class DomSpectator extends BaseSpectator { directiveOrSelector: Type | string | DebugElement, eventName: K, eventObj: EventEmitterType, - options?: { root: boolean } + options?: { root: boolean }, ) { const triggerDebugElement = this.getDebugElement(directiveOrSelector, options); if (!triggerDebugElement) { @@ -314,7 +319,7 @@ export abstract class DomSpectator extends BaseSpectator { public selectOption( selector: SpectatorElement = this.element, options: string | string[] | HTMLOptionElement | HTMLOptionElement[], - config: { emitEvents: boolean } = { emitEvents: true } + config: { emitEvents: boolean } = { emitEvents: true }, ): void { if (!selector) { throw new Error(`Cannot find select: ${selector}`); @@ -354,7 +359,7 @@ export abstract class DomSpectator extends BaseSpectator { private getDebugElement( directiveOrSelector: string | DebugElement | Type, - options?: { root: boolean } + options?: { root: boolean }, ): DebugElement | undefined { const debugElement = options?.root ? this.getRootDebugElement() : this.debugElement; diff --git a/projects/spectator/src/lib/base/options.ts b/projects/spectator/src/lib/base/options.ts index 65e3696e..c62d43b4 100644 --- a/projects/spectator/src/lib/base/options.ts +++ b/projects/spectator/src/lib/base/options.ts @@ -1,4 +1,4 @@ -import {Component, Directive, NgModule, Pipe, Provider, SchemaMetadata, Type} from '@angular/core'; +import { Component, Directive, NgModule, Pipe, Provider, SchemaMetadata, Type } from '@angular/core'; import { MetadataOverride, ModuleTeardownOptions } from '@angular/core/testing'; import { merge } from '../internals/merge'; diff --git a/projects/spectator/src/lib/dispatch-events.ts b/projects/spectator/src/lib/dispatch-events.ts index 0739b1ca..21ae55fb 100644 --- a/projects/spectator/src/lib/dispatch-events.ts +++ b/projects/spectator/src/lib/dispatch-events.ts @@ -38,7 +38,7 @@ export function dispatchKeyboardEvent( node: Node, type: string, keyOrKeyCode: string | number | KeyboardEventOptions, - target?: Element + target?: Element, ): KeyboardEvent { return dispatchEvent(node, createKeyboardEvent(type, keyOrKeyCode, target)); } @@ -56,7 +56,7 @@ export function dispatchMouseEvent( type: string, x: number = 0, y: number = 0, - event: MouseEvent = createMouseEvent(type, x, y) + event: MouseEvent = createMouseEvent(type, x, y), ): MouseEvent { return dispatchEvent(node, event); } diff --git a/projects/spectator/src/lib/dom-selectors.ts b/projects/spectator/src/lib/dom-selectors.ts index 16e07eb5..653c3f33 100644 --- a/projects/spectator/src/lib/dom-selectors.ts +++ b/projects/spectator/src/lib/dom-selectors.ts @@ -6,7 +6,7 @@ import { SelectorMatcherOptions, queries as DOMQueries, getDefaultNormalizer, - ByRoleOptions + ByRoleOptions, } from '@testing-library/dom'; import { ARIARole } from 'aria-query'; @@ -22,13 +22,13 @@ export class DOMSelector { export type DOMSelectorFactory = (matcher: Matcher, options?: TOptions) => DOMSelector; export const byLabel: DOMSelectorFactory = (matcher, options) => - new DOMSelector(el => DOMQueries.queryAllByLabelText(el, matcher, options)); + new DOMSelector((el) => DOMQueries.queryAllByLabelText(el, matcher, options)); export const byPlaceholder: DOMSelectorFactory = (matcher, options) => - new DOMSelector(el => DOMQueries.queryAllByPlaceholderText(el, matcher, options)); + new DOMSelector((el) => DOMQueries.queryAllByPlaceholderText(el, matcher, options)); export const byText: DOMSelectorFactory = (matcher, options) => - new DOMSelector(el => DOMQueries.queryAllByText(el, matcher, options)); + new DOMSelector((el) => DOMQueries.queryAllByText(el, matcher, options)); export const byTextContent = (matcher: Matcher, options: MandatorySelectorMatchingOptions): DOMSelector => { let textContentMatcher: Matcher; @@ -38,11 +38,7 @@ export const byTextContent = (matcher: Matcher, options: MandatorySelectorMatchi if (typeof matcher === 'string' || typeof matcher === 'number') { textContentMatcher = (_, elem) => { if (options?.exact === false) { - return ( - getTextContent(elem) - .toLowerCase() - .indexOf(matcher.toString().toLowerCase()) >= 0 - ); + return getTextContent(elem).toLowerCase().indexOf(matcher.toString().toLowerCase()) >= 0; } return getTextContent(elem) === matcher.toString(); @@ -55,18 +51,19 @@ export const byTextContent = (matcher: Matcher, options: MandatorySelectorMatchi throw new Error(`Matcher type not supported: ${typeof matcher}`); } - return new DOMSelector(el => DOMQueries.queryAllByText(el, textContentMatcher, options)); + return new DOMSelector((el) => DOMQueries.queryAllByText(el, textContentMatcher, options)); }; export const byAltText: DOMSelectorFactory = (matcher, options) => - new DOMSelector(el => DOMQueries.queryAllByAltText(el, matcher, options)); + new DOMSelector((el) => DOMQueries.queryAllByAltText(el, matcher, options)); -export const byTitle: DOMSelectorFactory = (matcher, options) => new DOMSelector(el => DOMQueries.queryAllByTitle(el, matcher, options)); +export const byTitle: DOMSelectorFactory = (matcher, options) => new DOMSelector((el) => DOMQueries.queryAllByTitle(el, matcher, options)); -export const byTestId: DOMSelectorFactory = (matcher, options) => new DOMSelector(el => DOMQueries.queryAllByTestId(el, matcher, options)); +export const byTestId: DOMSelectorFactory = (matcher, options) => + new DOMSelector((el) => DOMQueries.queryAllByTestId(el, matcher, options)); export const byValue: DOMSelectorFactory = (matcher, options) => - new DOMSelector(el => DOMQueries.queryAllByDisplayValue(el, matcher, options)); + new DOMSelector((el) => DOMQueries.queryAllByDisplayValue(el, matcher, options)); export const byRole = (matcher: ARIARole | MatcherFunction | Omit, options?: ByRoleOptions): DOMSelector => - new DOMSelector(el => DOMQueries.queryAllByRole(el, matcher, options)); + new DOMSelector((el) => DOMQueries.queryAllByRole(el, matcher, options)); diff --git a/projects/spectator/src/lib/event-creators.ts b/projects/spectator/src/lib/event-creators.ts index 706344fb..904c92f0 100644 --- a/projects/spectator/src/lib/event-creators.ts +++ b/projects/spectator/src/lib/event-creators.ts @@ -65,7 +65,7 @@ export function createKeyboardEvent(type: string, keyOrKeyCode: string | number key /* key */, 0 /* location */, modifiersStr /* modifiersList */, - false /* repeat */ + false /* repeat */, ); } diff --git a/projects/spectator/src/lib/globals-injections.ts b/projects/spectator/src/lib/globals-injections.ts index cd1b0ef2..d25eb019 100644 --- a/projects/spectator/src/lib/globals-injections.ts +++ b/projects/spectator/src/lib/globals-injections.ts @@ -3,7 +3,7 @@ import { TestModuleMetadata } from '@angular/core/testing'; let globals: TestModuleMetadata = { providers: [], declarations: [], - imports: [] + imports: [], }; export function defineGlobalsInjections(config: TestModuleMetadata): void { diff --git a/projects/spectator/src/lib/internals/element-focus.ts b/projects/spectator/src/lib/internals/element-focus.ts index d85716a5..b3334d35 100644 --- a/projects/spectator/src/lib/internals/element-focus.ts +++ b/projects/spectator/src/lib/internals/element-focus.ts @@ -6,7 +6,6 @@ const IS_FOCUS_PATCHED_PROP = Symbol('isFocusPatched'); /** Ensures that a single set of matching focus and blur events occur when HTMLElement.focus() is called. */ class FocusEventWatcher implements EventListenerObject { - private readonly priorActiveElement: Element | null; /** Set to true when browser sends a blur event for priorActiveElement */ @@ -23,8 +22,7 @@ class FocusEventWatcher implements EventListenerObject { public handleEvent({ type }: Event): void { if (type === 'focus') { this._focused = true; - } - else if (type === 'blur') { + } else if (type === 'blur') { this._blurred = true; } } @@ -55,9 +53,8 @@ class FocusEventWatcher implements EventListenerObject { * patchElementFocus(triggerEl); */ export function patchElementFocus(element: HTMLElement): void { - // https://github.com/ngneat/spectator/issues/373 - Don't patch when using JSDOM, eg in Jest - if (!isRunningInJsDom() && (element[IS_FOCUS_PATCHED_PROP] === undefined)) { + if (!isRunningInJsDom() && element[IS_FOCUS_PATCHED_PROP] === undefined) { const originalFocus = element.focus.bind(element); element.focus = (options) => { const focusEventWatcher = new FocusEventWatcher(element); @@ -66,7 +63,7 @@ export function patchElementFocus(element: HTMLElement): void { originalFocus(options); focusEventWatcher.ensureFocusEvents(); - } + }; element.blur = () => dispatchFakeEvent(element, 'blur'); element[IS_FOCUS_PATCHED_PROP] = true; } diff --git a/projects/spectator/src/lib/internals/key-parser.ts b/projects/spectator/src/lib/internals/key-parser.ts index 53db2299..30e8cd00 100644 --- a/projects/spectator/src/lib/internals/key-parser.ts +++ b/projects/spectator/src/lib/internals/key-parser.ts @@ -27,7 +27,7 @@ export const parseKeyOptions = (keyOrKeyCode: string | number | KeyboardEventOpt return { ...parsedKey, - keyCode: keyOrKeyCode.keyCode + keyCode: keyOrKeyCode.keyCode, }; } @@ -67,7 +67,7 @@ const parseKey = (keyStr: string): KeyOptions => { throw new Error(`invalid key modifier: ${part ? part : 'undefined'}, keyStr: ${keyStr}`); } }, - { alt: false, control: false, shift: false, meta: false } + { alt: false, control: false, shift: false, meta: false }, ); return { key, keyCode: false, modifiers }; diff --git a/projects/spectator/src/lib/internals/node-by-directive.ts b/projects/spectator/src/lib/internals/node-by-directive.ts index db23f472..5919cb12 100644 --- a/projects/spectator/src/lib/internals/node-by-directive.ts +++ b/projects/spectator/src/lib/internals/node-by-directive.ts @@ -3,5 +3,5 @@ import { DebugNode, Predicate, Type } from '@angular/core'; // TODO (dirkluijk): remove after upgrading to Angular 8.2 // see: https://github.com/angular/angular/commit/10a1e1974b816ebb979dc10586b160ee07ad8356 export function nodeByDirective(type: Type): Predicate { - return debugNode => debugNode.providerTokens.includes(type); + return (debugNode) => debugNode.providerTokens.includes(type); } diff --git a/projects/spectator/src/lib/internals/query.ts b/projects/spectator/src/lib/internals/query.ts index 93cd8504..5dfbd880 100644 --- a/projects/spectator/src/lib/internals/query.ts +++ b/projects/spectator/src/lib/internals/query.ts @@ -11,7 +11,7 @@ export function getChildren(debugElementRoot: DebugElement): (directiveOrSele } const debugElements = debugElementRoot.queryAll( - isString(directiveOrSelector) ? By.css(directiveOrSelector) : By.directive(directiveOrSelector) + isString(directiveOrSelector) ? By.css(directiveOrSelector) : By.directive(directiveOrSelector), ); if (options.read) { @@ -54,7 +54,7 @@ export function setProps(componentRef: ComponentRef, keyOrKeyValues: any, v export function setHostProps( componentRef: ComponentRef, key: K, - value: V + value: V, ): T & { [KEY in K]: V }; export function setHostProps(componentRef: ComponentRef, keyValues?: KV): T & KV; export function setHostProps(componentRef: ComponentRef, keyOrKeyValues: any, value?: any): any { diff --git a/projects/spectator/src/lib/internals/rgb-to-hex.ts b/projects/spectator/src/lib/internals/rgb-to-hex.ts index b6e9470a..a52b9283 100644 --- a/projects/spectator/src/lib/internals/rgb-to-hex.ts +++ b/projects/spectator/src/lib/internals/rgb-to-hex.ts @@ -9,7 +9,7 @@ export function hex2rgb(hex: string): string { const h = hex.replace('#', ''); const matches = h.match(new RegExp('(.{' + h.length / 3 + '})', 'g'))!; - const [r, g, b] = matches.map(match => parseInt(match.length === 1 ? match + match : match, 16)); + const [r, g, b] = matches.map((match) => parseInt(match.length === 1 ? match + match : match, 16)); return `rgb(${r},${g},${b})`; } diff --git a/projects/spectator/src/lib/matchers-types.ts b/projects/spectator/src/lib/matchers-types.ts index 2ad3de34..2cb0436a 100644 --- a/projects/spectator/src/lib/matchers-types.ts +++ b/projects/spectator/src/lib/matchers-types.ts @@ -18,7 +18,7 @@ declare namespace jasmine { 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; diff --git a/projects/spectator/src/lib/matchers.ts b/projects/spectator/src/lib/matchers.ts index 4ba54d70..6106b00c 100644 --- a/projects/spectator/src/lib/matchers.ts +++ b/projects/spectator/src/lib/matchers.ts @@ -35,7 +35,7 @@ const containsProperty = (actual: string, expected: unknown): boolean => { const checkProperty = ( el: HTMLElement, prop: object, - predicate: (actual, expected) => boolean + predicate: (actual, expected) => boolean, ): { pass: boolean; message: () => string } => { let pass = false; let failing = ''; @@ -88,7 +88,7 @@ const hasSameText = ( options: { exact: boolean; trim: boolean; - } + }, ) => { if (expected && Array.isArray(expected)) { let actual: string; @@ -264,7 +264,7 @@ export const toContainProperty = comparator((el, prop, val) => { export const toHaveText = comparator((el, expected, exact = false) => hasSameText(el, expected, { exact, trim: false })); export const toHaveExactText = comparator((el, expected, options: { trim: boolean } = { trim: false }) => - hasSameText(el, expected, { exact: true, trim: options.trim }) + hasSameText(el, expected, { exact: true, trim: options.trim }), ); export const toHaveExactTrimmedText = comparator((el, expected) => hasSameText(el, expected, { exact: true, trim: true })); @@ -402,7 +402,7 @@ export const toBePartial = comparator((actual, expected) => { const pass = expectedProps.every((expectedProp) => actual[expectedProp] === expected[expectedProp]); const message = () => `Expected element${pass ? ' not' : ''} to contain properties: ${JSON.stringify(expectedPropsAndValues)}.`.concat( - ` Actual properties: ${JSON.stringify(actualPropsAndValues)}` + ` Actual properties: ${JSON.stringify(actualPropsAndValues)}`, ); return { pass, message }; diff --git a/projects/spectator/src/lib/mock.ts b/projects/spectator/src/lib/mock.ts index 52fe8ed6..35e417a5 100644 --- a/projects/spectator/src/lib/mock.ts +++ b/projects/spectator/src/lib/mock.ts @@ -28,13 +28,12 @@ export interface CompatibleSpy extends jasmine.Spy { /** * @publicApi */ -export type SpyObject = T & - { [P in keyof T]: T[P] extends Function ? T[P] & CompatibleSpy : T[P] } & { - /** - * Casts to type without readonly properties - */ - castToWritable(): Writable; - }; +export type SpyObject = T & { [P in keyof T]: T[P] extends Function ? T[P] & CompatibleSpy : T[P] } & { + /** + * Casts to type without readonly properties + */ + castToWritable(): Writable; +}; /** * @internal @@ -55,9 +54,9 @@ export function installProtoMethods(mock: any, proto: any, createSpyFn: Funct mock[key] = createSpyFn(key); } else if (descriptor.get && !mock.hasOwnProperty(key)) { Object.defineProperty(mock, key, { - set: value => (mock[`_${key}`] = value), + set: (value) => (mock[`_${key}`] = value), get: () => mock[`_${key}`], - configurable: true + configurable: true, }); } } @@ -73,10 +72,10 @@ export function installProtoMethods(mock: any, proto: any, createSpyFn: Funct export function createSpyObject(type: Type | AbstractType, template?: Partial>): SpyObject { const mock: any = { ...template } || {}; - installProtoMethods(mock, type.prototype, name => { + installProtoMethods(mock, type.prototype, (name) => { const newSpy: jasmine.Spy & Partial = jasmine.createSpy(name); newSpy.andCallFake = (fn: (...args: any[]) => any) => newSpy.and.callFake(fn); - newSpy.andReturn = val => newSpy.and.returnValue(val); + newSpy.andReturn = (val) => newSpy.and.returnValue(val); newSpy.reset = () => newSpy.calls.reset(); // revisit return null here (previously needed for rtts_assert). newSpy.and.returnValue(null); @@ -93,7 +92,7 @@ export function createSpyObject(type: Type | AbstractType, template?: P export function mockProvider(type: Type | AbstractType, properties?: Partial>): FactoryProvider { return { provide: type, - useFactory: () => createSpyObject(type, properties) + useFactory: () => createSpyObject(type, properties), }; } diff --git a/projects/spectator/src/lib/select-option.ts b/projects/spectator/src/lib/select-option.ts index d5077901..0d06e297 100644 --- a/projects/spectator/src/lib/select-option.ts +++ b/projects/spectator/src/lib/select-option.ts @@ -13,7 +13,7 @@ import { isString, isHTMLOptionElementArray, SelectOptions } from './types'; export function selectOption( options: SelectOptions, element: HTMLElement | HTMLSelectElement | Document | Window, - config: { emitEvents: boolean } + config: { emitEvents: boolean }, ): void { if (!(element instanceof HTMLSelectElement)) { return; @@ -36,9 +36,9 @@ export function selectOption( } if (isHTMLOptionElementArray(options)) { - options.forEach(option => setOptionSelected(option, element, config)); + options.forEach((option) => setOptionSelected(option, element, config)); } else { - element.querySelectorAll('option').forEach(opt => { + element.querySelectorAll('option').forEach((opt) => { if (options.includes(opt.value)) { setOptionSelected(opt, element, config); } diff --git a/projects/spectator/src/lib/spectator-directive/create-factory.ts b/projects/spectator/src/lib/spectator-directive/create-factory.ts index cf862fc8..a4b0fe03 100644 --- a/projects/spectator/src/lib/spectator-directive/create-factory.ts +++ b/projects/spectator/src/lib/spectator-directive/create-factory.ts @@ -21,7 +21,7 @@ import { SpectatorDirective } from './spectator-directive'; */ export type SpectatorDirectiveFactory = ( template: string, - overrides?: SpectatorDirectiveOverrides + overrides?: SpectatorDirectiveOverrides, ) => SpectatorDirective; /** @@ -29,7 +29,7 @@ export type SpectatorDirectiveFactory = ( */ export type PresetSpectatorDirectiveFactory = ( template?: string, - overrides?: SpectatorDirectiveOverrides + overrides?: SpectatorDirectiveOverrides, ) => SpectatorDirective; /** @@ -45,16 +45,16 @@ export interface SpectatorDirectiveOverrides extends BaseSpectatorOverrid * @publicApi */ export function createDirectiveFactory( - options: SpectatorDirectiveOptions & { template: string } + options: SpectatorDirectiveOptions & { template: string }, ): PresetSpectatorDirectiveFactory; /** * @publicApi */ export function createDirectiveFactory( - typeOrOptions: Type | SpectatorDirectiveOptions + typeOrOptions: Type | SpectatorDirectiveOptions, ): SpectatorDirectiveFactory; export function createDirectiveFactory( - typeOrOptions: Type | SpectatorDirectiveOptions + typeOrOptions: Type | SpectatorDirectiveOptions, ): SpectatorDirectiveFactory { const options = isType(typeOrOptions) ? getSpectatorDirectiveDefaultOptions({ directive: typeOrOptions }) @@ -62,16 +62,14 @@ export function createDirectiveFactory( const moduleMetadata = initialSpectatorDirectiveModule(options); - beforeEach( - waitForAsync(() => { - addMatchers(customMatchers); - TestBed.configureTestingModule(moduleMetadata); - overrideModules(options); - overrideComponents(options); - overrideDirectives(options); - overridePipes(options); - }) - ); + beforeEach(waitForAsync(() => { + addMatchers(customMatchers); + TestBed.configureTestingModule(moduleMetadata); + overrideModules(options); + overrideComponents(options); + overrideDirectives(options); + overridePipes(options); + })); return (template?: string, overrides?: SpectatorDirectiveOverrides) => { const defaults: SpectatorDirectiveOverrides = { @@ -109,7 +107,7 @@ export function createDirectiveFactory( function createSpectatorDirective( options: Required>, - hostProps?: HP + hostProps?: HP, ): SpectatorDirective { const hostFixture = TestBed.createComponent(options.host); const debugElement = hostFixture.debugElement.query(By.directive(options.directive)) || hostFixture.debugElement; diff --git a/projects/spectator/src/lib/spectator-directive/options.ts b/projects/spectator/src/lib/spectator-directive/options.ts index f043fa6f..1bf0fa2e 100644 --- a/projects/spectator/src/lib/spectator-directive/options.ts +++ b/projects/spectator/src/lib/spectator-directive/options.ts @@ -27,14 +27,14 @@ const defaultSpectatorRoutingOptions: OptionalsRequired( - overrides?: SpectatorDirectiveOptions + overrides?: SpectatorDirectiveOptions, ): Required> { return merge(defaultSpectatorRoutingOptions, overrides); } diff --git a/projects/spectator/src/lib/spectator-directive/spectator-directive.ts b/projects/spectator/src/lib/spectator-directive/spectator-directive.ts index 4eaec7b4..6f37fda8 100644 --- a/projects/spectator/src/lib/spectator-directive/spectator-directive.ts +++ b/projects/spectator/src/lib/spectator-directive/spectator-directive.ts @@ -16,7 +16,7 @@ export class SpectatorDirective extends DomSpectator { public fixture: ComponentFixture, public debugElement: DebugElement, protected instance: D, - public element: Element + public element: Element, ) { super(fixture, debugElement, instance, element); } diff --git a/projects/spectator/src/lib/spectator-host/create-factory.ts b/projects/spectator/src/lib/spectator-host/create-factory.ts index 0ad50bb2..b5bb6ada 100644 --- a/projects/spectator/src/lib/spectator-host/create-factory.ts +++ b/projects/spectator/src/lib/spectator-host/create-factory.ts @@ -27,7 +27,7 @@ import { SpectatorHost } from './spectator-host'; */ export type SpectatorHostFactory = ( template: string, - overrides?: SpectatorHostOverrides + overrides?: SpectatorHostOverrides, ) => SpectatorHost; /** @@ -35,7 +35,7 @@ export type SpectatorHostFactory = ( */ export type PresetSpectatorHostFactory = ( template?: string, - overrides?: SpectatorHostOverrides + overrides?: SpectatorHostOverrides, ) => SpectatorHost; /** @@ -50,7 +50,7 @@ export interface SpectatorHostOverrides extends BaseSpectatorOverrides { * @publicApi */ export function createHostFactory( - options: SpectatorHostOptions & { template: string } + options: SpectatorHostOptions & { template: string }, ): PresetSpectatorHostFactory; /** * @publicApi @@ -63,24 +63,22 @@ export function createHostFactory(typeOrOptions: Type | const moduleMetadata = initialSpectatorWithHostModule(options); - beforeEach( - waitForAsync(() => { - addMatchers(customMatchers); - TestBed.configureTestingModule(moduleMetadata).overrideModule(BrowserDynamicTestingModule, {}); - - overrideModules(options); - overrideComponents(options); - overrideDirectives(options); - overridePipes(options); - - overrideComponentIfProviderOverridesSpecified(options); - if (options.template) { - TestBed.overrideComponent(options.host, { - set: { template: options.template }, - }); - } - }) - ); + beforeEach(waitForAsync(() => { + addMatchers(customMatchers); + TestBed.configureTestingModule(moduleMetadata).overrideModule(BrowserDynamicTestingModule, {}); + + overrideModules(options); + overrideComponents(options); + overrideDirectives(options); + overridePipes(options); + + overrideComponentIfProviderOverridesSpecified(options); + if (options.template) { + TestBed.overrideComponent(options.host, { + set: { template: options.template }, + }); + } + })); return (template?: string, overrides?: SpectatorHostOverrides) => { const defaults: SpectatorHostOverrides = { hostProps: {} as any, detectChanges: true, providers: [] }; @@ -127,6 +125,6 @@ function createSpectatorHost(options: Required extends SpectatorOptions { const defaultSpectatorHostOptions: OptionalsRequired> = { ...getSpectatorDefaultOptions(), host: HostComponent, - template: '' + template: '', }; /** diff --git a/projects/spectator/src/lib/spectator-host/spectator-host.ts b/projects/spectator/src/lib/spectator-host/spectator-host.ts index 98d46bf8..a07efadf 100644 --- a/projects/spectator/src/lib/spectator-host/spectator-host.ts +++ b/projects/spectator/src/lib/spectator-host/spectator-host.ts @@ -21,7 +21,7 @@ export class SpectatorHost extends DomSpectator { public hostFixture: ComponentFixture, public debugElement: DebugElement, componentInstance: C, - public element: HTMLElement + public element: HTMLElement, ) { super(hostFixture, debugElement, componentInstance, element); } diff --git a/projects/spectator/src/lib/spectator-http/options.ts b/projects/spectator/src/lib/spectator-http/options.ts index 3dcd1e6c..348c835a 100644 --- a/projects/spectator/src/lib/spectator-http/options.ts +++ b/projects/spectator/src/lib/spectator-http/options.ts @@ -9,7 +9,7 @@ export interface SpectatorHttpOptions extends BaseSpectatorOptions { } const defaultHttpOptions: OptionalsRequired> = { - ...getDefaultBaseOptions() + ...getDefaultBaseOptions(), }; /** diff --git a/projects/spectator/src/lib/spectator-http/spectator-http.ts b/projects/spectator/src/lib/spectator-http/spectator-http.ts index 8ff08184..989d1f12 100644 --- a/projects/spectator/src/lib/spectator-http/spectator-http.ts +++ b/projects/spectator/src/lib/spectator-http/spectator-http.ts @@ -14,7 +14,7 @@ export enum HttpMethod { PATCH = 'PATCH', HEAD = 'HEAD', JSONP = 'JSONP', - OPTIONS = 'OPTIONS' + OPTIONS = 'OPTIONS', } export interface HttpExpect { @@ -26,7 +26,11 @@ export interface HttpExpect { * @publicApi */ export class SpectatorHttp extends BaseSpectator { - constructor(public service: S, public httpClient: HttpClient, public controller: HttpTestingController) { + constructor( + public service: S, + public httpClient: HttpClient, + public controller: HttpTestingController, + ) { super(); // small workaround to prevent issues if destructuring SpectatorHttp, which was common in Spectator 3 @@ -40,7 +44,7 @@ export class SpectatorHttp extends BaseSpectator { const req = this.controller.expectOne({ url, - method + method, }); // assert that there are no outstanding requests. @@ -53,7 +57,7 @@ export class SpectatorHttp extends BaseSpectator { const requests = expectations.map((expectation: HttpExpect) => { return this.controller.expectOne({ url: expectation.url, - method: expectation.method + method: expectation.method, }); }); diff --git a/projects/spectator/src/lib/spectator-pipe/create-factory.ts b/projects/spectator/src/lib/spectator-pipe/create-factory.ts index 3a737e33..a46140d4 100644 --- a/projects/spectator/src/lib/spectator-pipe/create-factory.ts +++ b/projects/spectator/src/lib/spectator-pipe/create-factory.ts @@ -19,7 +19,7 @@ import { SpectatorPipe } from './spectator-pipe'; */ export type SpectatorPipeFactory = ( templateOrOverrides?: string | SpectatorPipeOverrides, - overrides?: SpectatorPipeOverrides + overrides?: SpectatorPipeOverrides, ) => SpectatorPipe; /** @@ -40,14 +40,12 @@ export function createPipeFactory(typeOrOptions: Type

| const moduleMetadata = initialSpectatorPipeModule(options); - beforeEach( - waitForAsync(() => { - addMatchers(customMatchers); - TestBed.configureTestingModule(moduleMetadata); - overrideModules(options); - overridePipes(options); - }) - ); + beforeEach(waitForAsync(() => { + addMatchers(customMatchers); + TestBed.configureTestingModule(moduleMetadata); + overrideModules(options); + overridePipes(options); + })); return (templateOrOverrides?: string | SpectatorPipeOverrides, overrides?: SpectatorPipeOverrides) => { const defaults: SpectatorPipeOverrides = { diff --git a/projects/spectator/src/lib/spectator-pipe/options.ts b/projects/spectator/src/lib/spectator-pipe/options.ts index 737ce085..16103726 100644 --- a/projects/spectator/src/lib/spectator-pipe/options.ts +++ b/projects/spectator/src/lib/spectator-pipe/options.ts @@ -19,7 +19,7 @@ const defaultSpectatorPipeOptions: OptionalsRequired extends BaseSpectator { - constructor(public hostComponent: H, public fixture: ComponentFixture, public debugElement: DebugElement, public element: Element) { + constructor( + public hostComponent: H, + public fixture: ComponentFixture, + public debugElement: DebugElement, + public element: Element, + ) { super(); } diff --git a/projects/spectator/src/lib/spectator-routing/activated-route-stub.ts b/projects/spectator/src/lib/spectator-routing/activated-route-stub.ts index 0b6c3a67..dd40a551 100644 --- a/projects/spectator/src/lib/spectator-routing/activated-route-stub.ts +++ b/projects/spectator/src/lib/spectator-routing/activated-route-stub.ts @@ -53,7 +53,7 @@ export class ActivatedRouteStub extends ActivatedRoute { } public get paramMap(): Observable { - return this.paramsSubject.asObservable().pipe(map(params => convertToParamMap(params))); + return this.paramsSubject.asObservable().pipe(map((params) => convertToParamMap(params))); } public snapshot: ActivatedRouteSnapshot; diff --git a/projects/spectator/src/lib/spectator-routing/create-factory.ts b/projects/spectator/src/lib/spectator-routing/create-factory.ts index a78549d9..6d947a30 100644 --- a/projects/spectator/src/lib/spectator-routing/create-factory.ts +++ b/projects/spectator/src/lib/spectator-routing/create-factory.ts @@ -42,21 +42,19 @@ export function createRoutingFactory(typeOrOptions: Type | SpectatorRoutin const moduleMetadata = initialRoutingModule(options); - beforeEach( - waitForAsync(() => { - addMatchers(customMatchers); - TestBed.configureTestingModule(moduleMetadata); + beforeEach(waitForAsync(() => { + addMatchers(customMatchers); + TestBed.configureTestingModule(moduleMetadata); - overrideModules(options); - overrideComponents(options); - overrideDirectives(options); - overridePipes(options); + overrideModules(options); + overrideComponents(options); + overrideDirectives(options); + overridePipes(options); - overrideComponentIfProviderOverridesSpecified(options); + overrideComponentIfProviderOverridesSpecified(options); - TestBed.compileComponents(); - }) - ); + TestBed.compileComponents(); + })); return (overrides?: SpectatorRoutingOverrides) => { const defaults: SpectatorRoutingOverrides = { @@ -112,6 +110,6 @@ function createSpectatorRouting(options: Required> debugElement, component, TestBed.inject(Router), - TestBed.inject(ActivatedRoute) as SpyObject + TestBed.inject(ActivatedRoute) as SpyObject, ); } diff --git a/projects/spectator/src/lib/spectator-routing/initial-module.ts b/projects/spectator/src/lib/spectator-routing/initial-module.ts index 785cfb7f..cf138181 100644 --- a/projects/spectator/src/lib/spectator-routing/initial-module.ts +++ b/projects/spectator/src/lib/spectator-routing/initial-module.ts @@ -30,7 +30,7 @@ export function initialRoutingModule(options: Required(options: Required extends Spectator { debugElement: DebugElement, instance: C, public readonly router: Router, - public readonly activatedRouteStub?: ActivatedRouteStub + public readonly activatedRouteStub?: ActivatedRouteStub, ) { super(fixture, debugElement, instance, debugElement.nativeElement); } @@ -109,7 +109,7 @@ export class SpectatorRouting extends Spectator { // eslint-disable-next-line no-console console.warn( 'No stub for Router present. Set Spectator option "stubsEnabled" to true if you want to use this ' + - 'helper, or use Router navigation to trigger events.' + 'helper, or use Router navigation to trigger events.', ); return; @@ -128,7 +128,7 @@ export class SpectatorRouting extends Spectator { // eslint-disable-next-line no-console console.warn( 'No stub for ActivatedRoute present. Set Spectator option "stubsEnabled" to true if you want to use this ' + - 'helper, or use Router to trigger navigation.' + 'helper, or use Router to trigger navigation.', ); return false; diff --git a/projects/spectator/src/lib/spectator-service/options.ts b/projects/spectator/src/lib/spectator-service/options.ts index e204c9c4..2541c371 100644 --- a/projects/spectator/src/lib/spectator-service/options.ts +++ b/projects/spectator/src/lib/spectator-service/options.ts @@ -9,7 +9,7 @@ export interface SpectatorServiceOptions extends BaseSpectatorOptions { } const defaultServiceOptions: OptionalsRequired = { - ...getDefaultBaseOptions() + ...getDefaultBaseOptions(), }; /** diff --git a/projects/spectator/src/lib/spectator/create-factory.ts b/projects/spectator/src/lib/spectator/create-factory.ts index de77cd7b..2dda3c4a 100644 --- a/projects/spectator/src/lib/spectator/create-factory.ts +++ b/projects/spectator/src/lib/spectator/create-factory.ts @@ -124,21 +124,19 @@ export function createComponentFactory(typeOrOptions: Type | SpectatorOpti const moduleMetadata = initialSpectatorModule(options); - beforeEach( - waitForAsync(() => { - addMatchers(customMatchers); - TestBed.configureTestingModule(moduleMetadata).overrideModule(BrowserDynamicTestingModule, {}); + beforeEach(waitForAsync(() => { + addMatchers(customMatchers); + TestBed.configureTestingModule(moduleMetadata).overrideModule(BrowserDynamicTestingModule, {}); - overrideModules(options); - overrideComponents(options); - overrideDirectives(options); - overridePipes(options); + overrideModules(options); + overrideComponents(options); + overrideDirectives(options); + overridePipes(options); - overrideComponentIfProviderOverridesSpecified(options); + overrideComponentIfProviderOverridesSpecified(options); - TestBed.compileComponents(); - }) - ); + TestBed.compileComponents(); + })); return (overrides?: SpectatorOverrides) => { const defaults: SpectatorOverrides = { props: {}, detectChanges: true, providers: [] }; diff --git a/projects/spectator/src/lib/spectator/spectator.ts b/projects/spectator/src/lib/spectator/spectator.ts index a7ff69b7..e49fbbbb 100644 --- a/projects/spectator/src/lib/spectator/spectator.ts +++ b/projects/spectator/src/lib/spectator/spectator.ts @@ -11,7 +11,12 @@ import { InferInputSignal, InferInputSignals } from '../types'; * @publicApi */ export class Spectator extends DomSpectator { - constructor(public fixture: ComponentFixture, public debugElement: DebugElement, protected instance: C, public element: HTMLElement) { + constructor( + public fixture: ComponentFixture, + public debugElement: DebugElement, + protected instance: C, + public element: HTMLElement, + ) { super(fixture, debugElement, instance, element); } diff --git a/projects/spectator/test/app-routing.module.ts b/projects/spectator/test/app-routing.module.ts index d7ea4dbc..f3daf250 100644 --- a/projects/spectator/test/app-routing.module.ts +++ b/projects/spectator/test/app-routing.module.ts @@ -5,6 +5,6 @@ const routes: Routes = []; @NgModule({ imports: [RouterModule.forRoot(routes)], - exports: [RouterModule] + exports: [RouterModule], }) export class AppRoutingModule {} diff --git a/projects/spectator/test/app.module.ts b/projects/spectator/test/app.module.ts index 8e95431b..43faeec8 100644 --- a/projects/spectator/test/app.module.ts +++ b/projects/spectator/test/app.module.ts @@ -55,11 +55,11 @@ import { ZippyComponent } from './zippy/zippy.component'; ComponentWithoutOverwrittenProvidersComponent, FormInputComponent, TranslatePipe, - EventsComponent + EventsComponent, ], entryComponents: [DynamicComponent], imports: [BrowserModule, HttpClientModule, ReactiveFormsModule, IntegrationModule, ChildCustomEventModule], providers: [ChildServiceService, WidgetService, WidgetDataService], - bootstrap: [AppComponent] + bootstrap: [AppComponent], }) export class AppModule {} diff --git a/projects/spectator/test/async-input/async-input.component.ts b/projects/spectator/test/async-input/async-input.component.ts index b71937cc..2679579d 100644 --- a/projects/spectator/test/async-input/async-input.component.ts +++ b/projects/spectator/test/async-input/async-input.component.ts @@ -2,9 +2,7 @@ import { Component, Input } from '@angular/core'; @Component({ selector: 'app-async-input', - template: ` -

Hello
- ` + template: `
Hello
`, }) export class AsyncInputComponent { public show; diff --git a/projects/spectator/test/async/async.component.ts b/projects/spectator/test/async/async.component.ts index e38008e9..acfad5c1 100644 --- a/projects/spectator/test/async/async.component.ts +++ b/projects/spectator/test/async/async.component.ts @@ -4,13 +4,9 @@ import { QueryService } from '../query.service'; @Component({ selector: 'app-async', - template: ` -

- async works! -

- `, + template: `

async works!

`, changeDetection: ChangeDetectionStrategy.OnPush, - styles: [] + styles: [], }) export class AsyncComponent implements OnInit { public show$; diff --git a/projects/spectator/test/auth.service.spec.ts b/projects/spectator/test/auth.service.spec.ts index d496dd82..8e4ab8f1 100644 --- a/projects/spectator/test/auth.service.spec.ts +++ b/projects/spectator/test/auth.service.spec.ts @@ -9,7 +9,7 @@ describe('AuthService', () => { const createService = createServiceFactory({ service: AuthService, entryComponents: [DynamicComponent], - mocks: [DateService] + mocks: [DateService], }); beforeEach(() => (spectator = createService())); diff --git a/projects/spectator/test/auto-focus/auto-focus.directive.spec.ts b/projects/spectator/test/auto-focus/auto-focus.directive.spec.ts index 12352c8a..ab00e552 100644 --- a/projects/spectator/test/auto-focus/auto-focus.directive.spec.ts +++ b/projects/spectator/test/auto-focus/auto-focus.directive.spec.ts @@ -13,7 +13,7 @@ describe('DatoAutoFocusDirective', () => { const createHost = createHostFactory({ component: AutoFocusDirective, - host: CustomHostComponent + host: CustomHostComponent, }); it('should be focused', () => { @@ -47,7 +47,7 @@ describe('DatoAutoFocusDirective (createHostDirectiveFactory)', () => { const createHost = createDirectiveFactory({ directive: AutoFocusDirective, - host: CustomHostComponent + host: CustomHostComponent, }); it('should be focused', () => { diff --git a/projects/spectator/test/auto-focus/auto-focus.module.spec.ts b/projects/spectator/test/auto-focus/auto-focus.module.spec.ts index 6ccfc1b4..da329eb6 100644 --- a/projects/spectator/test/auto-focus/auto-focus.module.spec.ts +++ b/projects/spectator/test/auto-focus/auto-focus.module.spec.ts @@ -9,7 +9,7 @@ describe('AutoFocusDirectiveModule', () => { const createDirective = createDirectiveFactory({ directive: AutoFocusDirective, imports: [AutoFocusModule], - declareDirective: false + declareDirective: false, }); it('should be declare AutoFocusDirective', () => { diff --git a/projects/spectator/test/auto-focus/auto-focus.module.ts b/projects/spectator/test/auto-focus/auto-focus.module.ts index 8fbd952f..96aefd00 100644 --- a/projects/spectator/test/auto-focus/auto-focus.module.ts +++ b/projects/spectator/test/auto-focus/auto-focus.module.ts @@ -6,6 +6,6 @@ import { AutoFocusDirective } from './auto-focus.directive'; @NgModule({ imports: [CommonModule], declarations: [AutoFocusDirective], - exports: [AutoFocusDirective] + exports: [AutoFocusDirective], }) export class AutoFocusModule {} diff --git a/projects/spectator/test/button/button.component.spec.ts b/projects/spectator/test/button/button.component.spec.ts index b5b37119..0d398ece 100644 --- a/projects/spectator/test/button/button.component.spec.ts +++ b/projects/spectator/test/button/button.component.spec.ts @@ -10,7 +10,7 @@ describe('ButtonComponent', () => { const createComponent = createComponentFactory({ component: ButtonComponent, - componentProviders: [mockProvider(QueryService)] + componentProviders: [mockProvider(QueryService)], }); beforeEach(() => (spectator = createComponent())); @@ -27,7 +27,7 @@ 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'); @@ -35,7 +35,7 @@ describe('ButtonComponent', () => { 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' }); @@ -43,7 +43,7 @@ describe('ButtonComponent', () => { it('should mock the service', () => { spectator = createComponent({ - detectChanges: false + detectChanges: false, }); spectator.inject(QueryService, true).selectName.and.returnValue(of('Netanel')); spectator.detectChanges(); @@ -71,7 +71,7 @@ describe('ButtonComponent', () => { const createComponent = createComponentFactory({ component: ButtonComponent, componentProviders: [mockProvider(QueryService)], - detectChanges: false + detectChanges: false, }); beforeEach(() => (spectator = createComponent())); diff --git a/projects/spectator/test/calc-textarea/calc-textarea.component.ts b/projects/spectator/test/calc-textarea/calc-textarea.component.ts index 5c24819a..944fcedd 100644 --- a/projects/spectator/test/calc-textarea/calc-textarea.component.ts +++ b/projects/spectator/test/calc-textarea/calc-textarea.component.ts @@ -6,6 +6,6 @@ import { Component } from '@angular/core';

{{ a.value + b.value }}

- ` + `, }) export class CalcTextAreaComponent {} diff --git a/projects/spectator/test/calc/calc.component.ts b/projects/spectator/test/calc/calc.component.ts index 33dbf378..b4da67a1 100644 --- a/projects/spectator/test/calc/calc.component.ts +++ b/projects/spectator/test/calc/calc.component.ts @@ -12,6 +12,6 @@ import { Component } from '@angular/core'; b

{{ a.value + b.value }}

- ` + `, }) export class CalcComponent {} diff --git a/projects/spectator/test/child-custom-event/child-custom-event-parent.component.spec.ts b/projects/spectator/test/child-custom-event/child-custom-event-parent.component.spec.ts index 71363f8e..f679d9e7 100644 --- a/projects/spectator/test/child-custom-event/child-custom-event-parent.component.spec.ts +++ b/projects/spectator/test/child-custom-event/child-custom-event-parent.component.spec.ts @@ -10,7 +10,7 @@ describe('ChildCustomEventParentComponent', () => { const createComponent = createComponentFactory({ component: ChildCustomEventParentComponent, imports: [ChildCustomEventModule], - declareComponent: false + declareComponent: false, }); it('should trigger custom event with directive selector', () => { diff --git a/projects/spectator/test/child-custom-event/child-custom-event-parent.component.ts b/projects/spectator/test/child-custom-event/child-custom-event-parent.component.ts index 733be221..d0e3781e 100644 --- a/projects/spectator/test/child-custom-event/child-custom-event-parent.component.ts +++ b/projects/spectator/test/child-custom-event/child-custom-event-parent.component.ts @@ -5,7 +5,7 @@ import { Component } from '@angular/core'; template: `

{{ eventValue }}

- ` + `, }) export class ChildCustomEventParentComponent { public eventValue = ''; diff --git a/projects/spectator/test/child-custom-event/child-custom-event.component.ts b/projects/spectator/test/child-custom-event/child-custom-event.component.ts index 5e811817..dba8e70a 100644 --- a/projects/spectator/test/child-custom-event/child-custom-event.component.ts +++ b/projects/spectator/test/child-custom-event/child-custom-event.component.ts @@ -2,9 +2,7 @@ import { Component, Output, EventEmitter } from '@angular/core'; @Component({ selector: 'app-child-custom-event', - template: ` -

Custom child

- ` + template: `

Custom child

`, }) export class ChildCustomEventComponent { @Output() customEvent = new EventEmitter(); diff --git a/projects/spectator/test/child-custom-event/child-custom-event.module.ts b/projects/spectator/test/child-custom-event/child-custom-event.module.ts index ce0395cf..8eecec9a 100644 --- a/projects/spectator/test/child-custom-event/child-custom-event.module.ts +++ b/projects/spectator/test/child-custom-event/child-custom-event.module.ts @@ -7,6 +7,6 @@ import { ChildCustomEventComponent } from './child-custom-event.component'; @NgModule({ imports: [CommonModule], declarations: [ChildCustomEventParentComponent, ChildCustomEventComponent], - exports: [ChildCustomEventParentComponent] + exports: [ChildCustomEventParentComponent], }) export class ChildCustomEventModule {} diff --git a/projects/spectator/test/child-service.service.spec.ts b/projects/spectator/test/child-service.service.spec.ts index d0be7094..12fb0c56 100644 --- a/projects/spectator/test/child-service.service.spec.ts +++ b/projects/spectator/test/child-service.service.spec.ts @@ -5,7 +5,7 @@ import { ChildServiceService } from './child-service.service'; describe('ChildServiceService', () => { beforeEach(() => { TestBed.configureTestingModule({ - providers: [ChildServiceService] + providers: [ChildServiceService], }); }); diff --git a/projects/spectator/test/child/child.component.ts b/projects/spectator/test/child/child.component.ts index b133bae3..4257546a 100644 --- a/projects/spectator/test/child/child.component.ts +++ b/projects/spectator/test/child/child.component.ts @@ -4,12 +4,8 @@ import { ChildServiceService } from '../child-service.service'; @Component({ selector: 'app-child', - template: ` -

- child works! -

- `, - styles: [] + template: `

child works!

`, + styles: [], }) export class ChildComponent { constructor(private readonly service: ChildServiceService) {} diff --git a/projects/spectator/test/click/click.component.ts b/projects/spectator/test/click/click.component.ts index 325fc974..6078bbc6 100644 --- a/projects/spectator/test/click/click.component.ts +++ b/projects/spectator/test/click/click.component.ts @@ -7,7 +7,7 @@ import { debounce } from 'helpful-decorators';

{{ name }}

`, - styles: [] + styles: [], }) export class ClickComponent { public name = 'init'; diff --git a/projects/spectator/test/component-providers.spec.ts b/projects/spectator/test/component-providers.spec.ts index 0586e5f0..edc01020 100644 --- a/projects/spectator/test/component-providers.spec.ts +++ b/projects/spectator/test/component-providers.spec.ts @@ -19,13 +19,16 @@ class SomeViewService { selector: 'some-component', template: ``, providers: [SomeService], - viewProviders: [SomeViewService] + viewProviders: [SomeViewService], }) export class SomeComponent implements OnInit { public foo!: string; public viewFoo!: string; - constructor(private readonly someService: SomeService, private readonly someViewService: SomeViewService) {} + constructor( + private readonly someService: SomeService, + private readonly someViewService: SomeViewService, + ) {} public ngOnInit(): void { this.foo = this.someService.getFoo(); @@ -36,7 +39,7 @@ export class SomeComponent implements OnInit { describe('SomeComponent', () => { describe('without mocking', () => { const createComponent = createComponentFactory({ - component: SomeComponent + component: SomeComponent, }); it('should create', () => { @@ -65,10 +68,10 @@ describe('SomeComponent', () => { { provide: SomeService, useValue: { - getFoo: () => 'overridden' - } - } - ] + getFoo: () => 'overridden', + }, + }, + ], }); it('should create', () => { @@ -93,7 +96,7 @@ describe('SomeComponent', () => { describe('with component mocking', () => { const createComponent = createComponentFactory({ component: SomeComponent, - componentMocks: [SomeService] + componentMocks: [SomeService], }); it('should create', () => { @@ -104,7 +107,7 @@ describe('SomeComponent', () => { it('should have mocked foo', () => { const spectator = createComponent({ - detectChanges: false + detectChanges: false, }); spectator.inject(SomeService, true).getFoo.andReturn('mocked-foo'); @@ -127,10 +130,10 @@ describe('SomeComponent', () => { { provide: SomeViewService, useValue: { - getFoo: () => 'overridden' - } - } - ] + getFoo: () => 'overridden', + }, + }, + ], }); it('should create', () => { @@ -155,7 +158,7 @@ describe('SomeComponent', () => { describe('with component view mocking', () => { const createComponent = createComponentFactory({ component: SomeComponent, - componentViewProvidersMocks: [SomeViewService] + componentViewProvidersMocks: [SomeViewService], }); it('should create', () => { @@ -166,7 +169,7 @@ describe('SomeComponent', () => { it('should have mocked viewFoo', () => { const spectator = createComponent({ - detectChanges: false + detectChanges: false, }); spectator.inject(SomeViewService, true).getFoo.andReturn('mocked-view-foo'); @@ -189,18 +192,18 @@ describe('SomeComponent', () => { { provide: SomeService, useValue: { - getFoo: () => 'overridden' - } - } + getFoo: () => 'overridden', + }, + }, ], componentViewProviders: [ { provide: SomeViewService, useValue: { - getFoo: () => 'overridden' - } - } - ] + getFoo: () => 'overridden', + }, + }, + ], }); it('should have overridden foo', () => { @@ -220,7 +223,7 @@ describe('SomeComponent', () => { const createComponent = createComponentFactory({ component: SomeComponent, componentMocks: [SomeService], - componentViewProvidersMocks: [SomeViewService] + componentViewProvidersMocks: [SomeViewService], }); it('should create', () => { @@ -231,7 +234,7 @@ describe('SomeComponent', () => { it('should have mocked foo', () => { const spectator = createComponent({ - detectChanges: false + detectChanges: false, }); spectator.inject(SomeService, true).getFoo.andReturn('mocked-foo'); @@ -242,7 +245,7 @@ describe('SomeComponent', () => { it('should have mocked view foo', () => { const spectator = createComponent({ - detectChanges: false + detectChanges: false, }); spectator.inject(SomeViewService, true).getFoo.andReturn('mocked-view-foo'); @@ -255,7 +258,7 @@ describe('SomeComponent', () => { describe('when global mocking', () => { const createComponent = createComponentFactory({ component: SomeComponent, - mocks: [SomeService, SomeViewService] + mocks: [SomeService, SomeViewService], }); it('should create', () => { diff --git a/projects/spectator/test/consum-dynamic/consume-dynamic.component.spec.ts b/projects/spectator/test/consum-dynamic/consume-dynamic.component.spec.ts index c49ca191..43b1a22a 100644 --- a/projects/spectator/test/consum-dynamic/consume-dynamic.component.spec.ts +++ b/projects/spectator/test/consum-dynamic/consume-dynamic.component.spec.ts @@ -10,7 +10,7 @@ describe('ConsumeDynamicComponent', () => { const createHost = createHostFactory({ declarations: [DynamicComponent], entryComponents: [DynamicComponent], - component: ConsumeDynamicComponent + component: ConsumeDynamicComponent, }); it('should work', () => { diff --git a/projects/spectator/test/consum-dynamic/consume-dynamic.component.ts b/projects/spectator/test/consum-dynamic/consume-dynamic.component.ts index 0bb81c58..d381f76e 100644 --- a/projects/spectator/test/consum-dynamic/consume-dynamic.component.ts +++ b/projects/spectator/test/consum-dynamic/consume-dynamic.component.ts @@ -4,15 +4,14 @@ import { DynamicComponent } from '../dynamic/dynamic.component'; @Component({ selector: 'app-consume-dynamic', - template: ` -

- consume-dynamic works! -

- `, - styles: [] + template: `

consume-dynamic works!

`, + styles: [], }) export class ConsumeDynamicComponent implements OnInit { - constructor(private readonly resolver: ComponentFactoryResolver, private readonly ref: ViewContainerRef) {} + constructor( + private readonly resolver: ComponentFactoryResolver, + private readonly ref: ViewContainerRef, + ) {} public ngOnInit(): void { const factory = this.resolver.resolveComponentFactory(DynamicComponent); diff --git a/projects/spectator/test/consumer.service.spec.ts b/projects/spectator/test/consumer.service.spec.ts index 56389776..8348d235 100644 --- a/projects/spectator/test/consumer.service.spec.ts +++ b/projects/spectator/test/consumer.service.spec.ts @@ -12,9 +12,9 @@ describe('ConsumerService', () => { providers: [ mockProvider(ProviderService, { obs$: new Subject(), - method: () => randomNumber - }) - ] + method: () => randomNumber, + }), + ], }); beforeEach(() => (spectator = createService())); diff --git a/projects/spectator/test/consumer.service.ts b/projects/spectator/test/consumer.service.ts index f9cb9249..ce6e618d 100644 --- a/projects/spectator/test/consumer.service.ts +++ b/projects/spectator/test/consumer.service.ts @@ -3,13 +3,13 @@ import { Injectable } from '@angular/core'; import { ProviderService } from './provider.service'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class ConsumerService { public lastValue: any; constructor(private readonly provider: ProviderService) { - provider.obs$.subscribe(val => this.update(val)); + provider.obs$.subscribe((val) => this.update(val)); } public update(val: string): void { diff --git a/projects/spectator/test/date.service.spec.ts b/projects/spectator/test/date.service.spec.ts index 67349682..be99c99b 100644 --- a/projects/spectator/test/date.service.spec.ts +++ b/projects/spectator/test/date.service.spec.ts @@ -5,7 +5,7 @@ import { DateService } from './date.service'; describe('DateService', () => { beforeEach(() => { TestBed.configureTestingModule({ - providers: [DateService] + providers: [DateService], }); }); diff --git a/projects/spectator/test/directive-providers.directive.ts b/projects/spectator/test/directive-providers.directive.ts index b07cdeff..55c7caba 100644 --- a/projects/spectator/test/directive-providers.directive.ts +++ b/projects/spectator/test/directive-providers.directive.ts @@ -8,5 +8,8 @@ export const directiveProviderToken = new InjectionToken('DirectiveProviderToken providers: [{ provide: directiveProviderToken, useValue: 'test' }], }) export class DirectiveProviderDirective { - constructor(@Inject(directiveProviderToken) public provider: string, private fb: FormBuilder) {} + constructor( + @Inject(directiveProviderToken) public provider: string, + private fb: FormBuilder, + ) {} } diff --git a/projects/spectator/test/dom-selectors/dom-selectors.component.spec.ts b/projects/spectator/test/dom-selectors/dom-selectors.component.spec.ts index dc3e1719..da4da828 100644 --- a/projects/spectator/test/dom-selectors/dom-selectors.component.spec.ts +++ b/projects/spectator/test/dom-selectors/dom-selectors.component.spec.ts @@ -8,7 +8,7 @@ import { byValue, byRole, createComponentFactory, - Spectator + Spectator, } from '@ngneat/spectator'; import { DomSelectorsComponent, DomSelectorsNestedComponent } from './dom-selectors.component'; @@ -17,7 +17,7 @@ describe('DomSelectorsComponent', () => { let spectator: Spectator; const createComponent = createComponentFactory({ component: DomSelectorsComponent, - imports: [DomSelectorsNestedComponent] + imports: [DomSelectorsNestedComponent], }); beforeEach(() => { @@ -70,13 +70,13 @@ describe('DomSelectorsComponent', () => { element = spectator.queryAll(DomSelectorsNestedComponent, { parentSelector: '#nested-components-1' }); expect(element.length).toBe(1); }); - }) + }); describe('byTextContent', () => { describe('with string matcher', () => { [ { description: 'by default', opts: {} }, - { description: 'with `exact: true`', opts: { exact: true } } + { description: 'with `exact: true`', opts: { exact: true } }, ].forEach(({ description, opts }) => { it(`should exactly match text content ${description}`, () => { let element = spectator.query(byTextContent('deeply nested', { selector: '#text-content-root', ...opts })); @@ -102,11 +102,11 @@ 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'); }); @@ -114,11 +114,11 @@ describe('DomSelectorsComponent', () => { 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'); }); @@ -151,7 +151,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'); }); diff --git a/projects/spectator/test/dom-selectors/dom-selectors.component.ts b/projects/spectator/test/dom-selectors/dom-selectors.component.ts index 46fd766c..26be2cf1 100644 --- a/projects/spectator/test/dom-selectors/dom-selectors.component.ts +++ b/projects/spectator/test/dom-selectors/dom-selectors.component.ts @@ -54,6 +54,6 @@ export class DomSelectorsNestedComponent {} `, standalone: true, - imports: [DomSelectorsNestedComponent] + imports: [DomSelectorsNestedComponent], }) export class DomSelectorsComponent {} diff --git a/projects/spectator/test/dynamic/dynamic.component.ts b/projects/spectator/test/dynamic/dynamic.component.ts index 865a2233..478d06e6 100644 --- a/projects/spectator/test/dynamic/dynamic.component.ts +++ b/projects/spectator/test/dynamic/dynamic.component.ts @@ -2,11 +2,7 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-dynamic', - template: ` -

- dynamic works! -

- `, - styles: [] + template: `

dynamic works!

`, + styles: [], }) export class DynamicComponent {} diff --git a/projects/spectator/test/error-unknown/error-unknown-element.component.spec.ts b/projects/spectator/test/error-unknown/error-unknown-element.component.spec.ts index 76f1a665..59b0ce21 100644 --- a/projects/spectator/test/error-unknown/error-unknown-element.component.spec.ts +++ b/projects/spectator/test/error-unknown/error-unknown-element.component.spec.ts @@ -13,5 +13,4 @@ describe('ErrorUnknownElementComponent', () => { it('should throw an error when creating the component', () => { expect(() => createComponent()).toThrowError(); }); - }); diff --git a/projects/spectator/test/error-unknown/error-unknown-element.component.ts b/projects/spectator/test/error-unknown/error-unknown-element.component.ts index 81097971..2cdb04cf 100644 --- a/projects/spectator/test/error-unknown/error-unknown-element.component.ts +++ b/projects/spectator/test/error-unknown/error-unknown-element.component.ts @@ -6,6 +6,4 @@ import { Component, Input } from '@angular/core'; selector: 'app-use-unknown-element', template: ``, }) -export class ErrorUnknownElementComponent { - -} +export class ErrorUnknownElementComponent {} diff --git a/projects/spectator/test/error-unknown/error-unknown-property.component.spec.ts b/projects/spectator/test/error-unknown/error-unknown-property.component.spec.ts index e2106561..16a36062 100644 --- a/projects/spectator/test/error-unknown/error-unknown-property.component.spec.ts +++ b/projects/spectator/test/error-unknown/error-unknown-property.component.spec.ts @@ -13,5 +13,4 @@ describe('ErrorUnknownPropertyComponent', () => { it('should throw an error when creating the component', () => { expect(() => createComponent()).toThrowError(); }); - }); diff --git a/projects/spectator/test/error-unknown/error-unknown-property.component.ts b/projects/spectator/test/error-unknown/error-unknown-property.component.ts index 71ad32f9..9c1bdb04 100644 --- a/projects/spectator/test/error-unknown/error-unknown-property.component.ts +++ b/projects/spectator/test/error-unknown/error-unknown-property.component.ts @@ -6,6 +6,4 @@ import { Component, Input } from '@angular/core'; selector: 'app-use-unknown-property', template: ``, }) -export class ErrorUnknownPropertyComponent { - -} +export class ErrorUnknownPropertyComponent {} diff --git a/projects/spectator/test/events/events.component.ts b/projects/spectator/test/events/events.component.ts index ff6e7fb4..9eaca036 100644 --- a/projects/spectator/test/events/events.component.ts +++ b/projects/spectator/test/events/events.component.ts @@ -3,7 +3,7 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-events', templateUrl: './events.component.html', - styleUrls: ['./events.component.scss'] + styleUrls: ['./events.component.scss'], }) export class EventsComponent { public event = ''; diff --git a/projects/spectator/test/focus/test-focus.component.spec.ts b/projects/spectator/test/focus/test-focus.component.spec.ts index c2a6cbea..22e9bb99 100644 --- a/projects/spectator/test/focus/test-focus.component.spec.ts +++ b/projects/spectator/test/focus/test-focus.component.spec.ts @@ -2,13 +2,12 @@ import { SpectatorHost, createHostFactory } from '@ngneat/spectator'; import { TestFocusComponent } from './test-focus.component'; describe('SpectatorHost.focus() ', () => { - const createHost = createHostFactory(TestFocusComponent); let host: SpectatorHost; beforeEach(() => { host = createHost(''); - }) + }); it('sets document.activeElement', () => { host.focus('#button1'); @@ -38,5 +37,4 @@ describe('SpectatorHost.focus() ', () => { expect(host.component.focusCount('button1')).toBe(2); expect(host.component.blurCount('button1')).toBe(1); }); - }); diff --git a/projects/spectator/test/focus/test-focus.component.ts b/projects/spectator/test/focus/test-focus.component.ts index aef89dea..274d4df4 100644 --- a/projects/spectator/test/focus/test-focus.component.ts +++ b/projects/spectator/test/focus/test-focus.component.ts @@ -3,16 +3,15 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; @Component({ selector: 'app-test-focus', template: ` - `, + `, changeDetection: ChangeDetectionStrategy.OnPush, host: { '[attr.tabindex]': '0', '(focus)': 'countFocus("app-test-focus")', - '(blur)': 'countBlur("app-test-focus")' - } + '(blur)': 'countBlur("app-test-focus")', + }, }) export class TestFocusComponent { - private readonly focusCounts = new Map(); private readonly blurCounts = new Map(); @@ -31,5 +30,4 @@ export class TestFocusComponent { public blurCount(id: string): number { return this.blurCounts.get(id) ?? 0; } - } diff --git a/projects/spectator/test/form-input/form-input.component.spec.ts b/projects/spectator/test/form-input/form-input.component.spec.ts index ca7eeb6c..635df18a 100644 --- a/projects/spectator/test/form-input/form-input.component.spec.ts +++ b/projects/spectator/test/form-input/form-input.component.spec.ts @@ -42,7 +42,7 @@ describe('FormInputComponent', () => { subnetControl: group, enableSubnet: true, }, - })) + })), ); it('should work', () => { diff --git a/projects/spectator/test/form-select/form-select.component.spec.ts b/projects/spectator/test/form-select/form-select.component.spec.ts index 810da380..25056b0f 100644 --- a/projects/spectator/test/form-select/form-select.component.spec.ts +++ b/projects/spectator/test/form-select/form-select.component.spec.ts @@ -8,7 +8,7 @@ describe('FormSelectComponent', () => { const createComponent = createComponentFactory({ component: FormSelectComponent, - imports: [ReactiveFormsModule] + imports: [ReactiveFormsModule], }); beforeEach(() => (spectator = createComponent())); diff --git a/projects/spectator/test/form-select/form-select.component.ts b/projects/spectator/test/form-select/form-select.component.ts index 80f5dbbc..3eaf70f3 100644 --- a/projects/spectator/test/form-select/form-select.component.ts +++ b/projects/spectator/test/form-select/form-select.component.ts @@ -29,7 +29,7 @@ import { Component, ChangeDetectionStrategy } from '@angular/core'; `, - changeDetection: ChangeDetectionStrategy.OnPush + changeDetection: ChangeDetectionStrategy.OnPush, }) export class FormSelectComponent { /** diff --git a/projects/spectator/test/highlight.directive.spec.ts b/projects/spectator/test/highlight.directive.spec.ts index 174497d7..d53c58ef 100644 --- a/projects/spectator/test/highlight.directive.spec.ts +++ b/projects/spectator/test/highlight.directive.spec.ts @@ -13,12 +13,12 @@ describe('HighlightDirective', () => { host.dispatchMouseEvent(host.element, 'mouseover'); expect(host.element).toHaveStyle({ - backgroundColor: 'rgba(0,0,0, 0.1)' + backgroundColor: 'rgba(0,0,0, 0.1)', }); host.dispatchMouseEvent(host.element, 'mouseout'); expect(host.element).toHaveStyle({ - backgroundColor: '#fff' + backgroundColor: '#fff', }); }); }); diff --git a/projects/spectator/test/highlight.directive.ts b/projects/spectator/test/highlight.directive.ts index d2e76f3c..318556eb 100644 --- a/projects/spectator/test/highlight.directive.ts +++ b/projects/spectator/test/highlight.directive.ts @@ -1,7 +1,7 @@ import { Directive, HostBinding, HostListener } from '@angular/core'; @Directive({ - selector: '[highlight]' + selector: '[highlight]', }) export class HighlightDirective { @HostBinding('style.background-color') public backgroundColor?: string; diff --git a/projects/spectator/test/integration/integration-child.component.ts b/projects/spectator/test/integration/integration-child.component.ts index dc5909dd..27b6e698 100644 --- a/projects/spectator/test/integration/integration-child.component.ts +++ b/projects/spectator/test/integration/integration-child.component.ts @@ -2,11 +2,7 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-integration-child', - template: ` -

- integration-child works! -

- `, - styles: [] + template: `

integration-child works!

`, + styles: [], }) export class IntegrationChildComponent {} diff --git a/projects/spectator/test/integration/integration-parent.component.spec.ts b/projects/spectator/test/integration/integration-parent.component.spec.ts index d2f18992..b084295c 100644 --- a/projects/spectator/test/integration/integration-parent.component.spec.ts +++ b/projects/spectator/test/integration/integration-parent.component.spec.ts @@ -9,7 +9,7 @@ describe('IntegrationParentComponent', () => { const createComponent = createComponentFactory({ component: IntegrationParentComponent, imports: [IntegrationModule, HttpClientTestingModule], - declareComponent: false + declareComponent: false, }); it('should exist', () => { diff --git a/projects/spectator/test/integration/integration-parent.component.ts b/projects/spectator/test/integration/integration-parent.component.ts index 021d3bff..bce96107 100644 --- a/projects/spectator/test/integration/integration-parent.component.ts +++ b/projects/spectator/test/integration/integration-parent.component.ts @@ -4,10 +4,8 @@ import { WidgetService } from '../widget.service'; @Component({ selector: 'app-integration-parent', - template: ` - - `, - styles: [] + template: ` `, + styles: [], }) export class IntegrationParentComponent { constructor(public widgetService: WidgetService) {} diff --git a/projects/spectator/test/integration/integration.module.ts b/projects/spectator/test/integration/integration.module.ts index 06f5c75c..80643003 100644 --- a/projects/spectator/test/integration/integration.module.ts +++ b/projects/spectator/test/integration/integration.module.ts @@ -11,6 +11,6 @@ import { IntegrationChildComponent } from './integration-child.component'; imports: [CommonModule], providers: [WidgetService, WidgetDataService], declarations: [IntegrationParentComponent, IntegrationChildComponent], - exports: [IntegrationParentComponent] + exports: [IntegrationParentComponent], }) export class IntegrationModule {} diff --git a/projects/spectator/test/matchers/matcher-enhancements.component.spec.ts b/projects/spectator/test/matchers/matcher-enhancements.component.spec.ts index 9ad51661..19936883 100644 --- a/projects/spectator/test/matchers/matcher-enhancements.component.spec.ts +++ b/projects/spectator/test/matchers/matcher-enhancements.component.spec.ts @@ -5,10 +5,10 @@ import { MatcherEnhancementsComponent } from './matcher-enhancements.component'; describe('Matcher enhancements', () => { let spectator: Spectator; const createComponent = createComponentFactory({ - component: MatcherEnhancementsComponent + component: MatcherEnhancementsComponent, }); - beforeEach(() => spectator = createComponent()); + beforeEach(() => (spectator = createComponent())); describe('Text', () => { it('should match multiple elements with different text', () => { @@ -16,7 +16,7 @@ describe('Matcher enhancements', () => { expect(el).toHaveText(['It should', 'different text', 'another']); expect(el).toContainText(['It should', 'different text', 'another']); expect(el).toHaveExactText(['It should have', 'Some different text', ' And another one ']); - expect(el).toHaveExactText(['It should have', 'Some different text', 'And another one'], {trim: true}); + expect(el).toHaveExactText(['It should have', 'Some different text', 'And another one'], { trim: true }); expect(el).toHaveExactTrimmedText(['It should have', 'Some different text', 'And another one']); }); }); @@ -76,7 +76,7 @@ describe('Matcher enhancements', () => { }); it('should return true when expected is same as actual', () => { - expect(spectator.component.dummyValue).toBePartial({...spectator.component.dummyValue}); + expect(spectator.component.dummyValue).toBePartial({ ...spectator.component.dummyValue }); }); it('should return false when expected is not partial of actual', () => { @@ -94,5 +94,5 @@ describe('Matcher enhancements', () => { it('should match checkbox indeterminate state', () => { expect(spectator.query('.checkbox-indeterminate')).toBeIndeterminate(); }); - }) + }); }); diff --git a/projects/spectator/test/matchers/matcher-enhancements.component.ts b/projects/spectator/test/matchers/matcher-enhancements.component.ts index 7e3c592d..2fc1893f 100644 --- a/projects/spectator/test/matchers/matcher-enhancements.component.ts +++ b/projects/spectator/test/matchers/matcher-enhancements.component.ts @@ -10,9 +10,7 @@ export interface Dummy { template: `
It should have
Some different text
-
- And another one -
+
And another one
@@ -20,7 +18,7 @@ export interface Dummy {
- ` + `, }) export class MatcherEnhancementsComponent { public dummyValue: Dummy = { label: 'this is a dummy value', active: true }; diff --git a/projects/spectator/test/mocks.spec.ts b/projects/spectator/test/mocks.spec.ts index e94d9c7b..2752c57f 100644 --- a/projects/spectator/test/mocks.spec.ts +++ b/projects/spectator/test/mocks.spec.ts @@ -5,12 +5,12 @@ import { WidgetService } from './widget.service'; describe('mockProvider', () => { it('should not modify the object passed in 2nd argument when running the mock factory', () => { const customPropertiesAndMethods: Partial> = { - testingProperty: 'overriden' + testingProperty: 'overriden', }; const { useFactory: factory } = mockProvider(WidgetService, customPropertiesAndMethods); factory(); expect(customPropertiesAndMethods).toEqual({ - testingProperty: 'overriden' + testingProperty: 'overriden', }); }); }); diff --git a/projects/spectator/test/ng-on-destroy.service.spec.ts b/projects/spectator/test/ng-on-destroy.service.spec.ts index ea03d3ea..937f5f25 100644 --- a/projects/spectator/test/ng-on-destroy.service.spec.ts +++ b/projects/spectator/test/ng-on-destroy.service.spec.ts @@ -10,9 +10,9 @@ describe('NgOnDestroyService', () => { service: NgOnDestroyService, providers: [ mockProvider(SubjectService, { - subject: subjectAcrossMultipleTests$ - }) - ] + subject: subjectAcrossMultipleTests$, + }), + ], }); it('should subscribe to subject during', () => { diff --git a/projects/spectator/test/no-overwritten-providers/no-overwritten-providers.component.spec.ts b/projects/spectator/test/no-overwritten-providers/no-overwritten-providers.component.spec.ts index 08234f8b..3b803c44 100644 --- a/projects/spectator/test/no-overwritten-providers/no-overwritten-providers.component.spec.ts +++ b/projects/spectator/test/no-overwritten-providers/no-overwritten-providers.component.spec.ts @@ -7,7 +7,7 @@ describe('ComponentWithoutOverwrittenProvidersComponent', () => { describe('with options', () => { const createHost = createHostFactory({ component: ComponentWithoutOverwrittenProvidersComponent, - componentProviders: [mockProvider(DummyService)] + componentProviders: [mockProvider(DummyService)], }); it('should not overwrite components providers and work using createHostFactory', () => { diff --git a/projects/spectator/test/no-overwritten-providers/no-overwritten-providers.component.ts b/projects/spectator/test/no-overwritten-providers/no-overwritten-providers.component.ts index 6657e102..98dd3d14 100644 --- a/projects/spectator/test/no-overwritten-providers/no-overwritten-providers.component.ts +++ b/projects/spectator/test/no-overwritten-providers/no-overwritten-providers.component.ts @@ -10,9 +10,9 @@ import { DummyService } from './dummy.service'; providers: [ { provide: DummyService, - useValue: new DummyService() - } - ] + useValue: new DummyService(), + }, + ], }) export class ComponentWithoutOverwrittenProvidersComponent { constructor(public dummy: DummyService) {} diff --git a/projects/spectator/test/overlay-custom-event/overlay-container.component.spec.ts b/projects/spectator/test/overlay-custom-event/overlay-container.component.spec.ts index fd6c51f5..5ae0743e 100644 --- a/projects/spectator/test/overlay-custom-event/overlay-container.component.spec.ts +++ b/projects/spectator/test/overlay-custom-event/overlay-container.component.spec.ts @@ -14,9 +14,9 @@ describe('Overlay container custom event', () => { const createComponent = createComponentFactory({ component: Component({ selector: 'test-host', - template: '
' + template: '
', })(class {}), - imports: [OverlayContainerModule] + imports: [OverlayContainerModule], }); it('should trigger custom event on a component inside an overlay', () => { diff --git a/projects/spectator/test/overlay-custom-event/overlay-container.component.ts b/projects/spectator/test/overlay-custom-event/overlay-container.component.ts index 9f8ea94f..47ecbf57 100644 --- a/projects/spectator/test/overlay-custom-event/overlay-container.component.ts +++ b/projects/spectator/test/overlay-custom-event/overlay-container.component.ts @@ -5,7 +5,7 @@ import { Component } from '@angular/core'; template: `

{{ eventValue }}

- ` + `, }) export class OverlayContainerComponent { public eventValue = ''; diff --git a/projects/spectator/test/overlay-custom-event/overlay-container.module.ts b/projects/spectator/test/overlay-custom-event/overlay-container.module.ts index 9bc5da0a..fb56a814 100644 --- a/projects/spectator/test/overlay-custom-event/overlay-container.module.ts +++ b/projects/spectator/test/overlay-custom-event/overlay-container.module.ts @@ -8,6 +8,6 @@ import { OverlayContentComponent } from './overlay-content.component'; @NgModule({ imports: [CommonModule, OverlayModule], declarations: [OverlayContainerComponent, OverlayContentComponent], - exports: [OverlayContainerComponent] + exports: [OverlayContainerComponent], }) export class OverlayContainerModule {} diff --git a/projects/spectator/test/overlay-custom-event/overlay-content.component.ts b/projects/spectator/test/overlay-custom-event/overlay-content.component.ts index 6d2ba7a4..7828bab2 100644 --- a/projects/spectator/test/overlay-custom-event/overlay-content.component.ts +++ b/projects/spectator/test/overlay-custom-event/overlay-content.component.ts @@ -2,9 +2,7 @@ import { Component, Output, EventEmitter } from '@angular/core'; @Component({ selector: 'app-overlay-content', - template: ` -

Overlay Content

- ` + template: `

Overlay Content

`, }) export class OverlayContentComponent { @Output() customEvent = new EventEmitter(); diff --git a/projects/spectator/test/override-component.spec.ts b/projects/spectator/test/override-component.spec.ts index 77e4f162..3bab8a88 100644 --- a/projects/spectator/test/override-component.spec.ts +++ b/projects/spectator/test/override-component.spec.ts @@ -1,7 +1,7 @@ import { createComponentFactory, createHostFactory, Spectator, SpectatorHost } from '@ngneat/spectator'; import { Component } from '@angular/core'; -import { QueryService } from "./query.service"; -import { overrideComponents } from "../src/lib/spectator/create-factory"; +import { QueryService } from './query.service'; +import { overrideComponents } from '../src/lib/spectator/create-factory'; // Created only for testing purpose @Component({ @@ -16,7 +16,7 @@ export class StandaloneComponentWithDependency { @Component({ selector: `app-standalone-with-import`, template: `
Standalone component with import!
- `, + `, imports: [StandaloneComponentWithDependency], standalone: true, }) @@ -52,7 +52,7 @@ describe('Override Component', () => { }, ], ], - } as any) + } as any), ).toThrowError('Can not override non standalone component'); }); diff --git a/projects/spectator/test/override-directive.spec.ts b/projects/spectator/test/override-directive.spec.ts index 707992dc..6e7d5359 100644 --- a/projects/spectator/test/override-directive.spec.ts +++ b/projects/spectator/test/override-directive.spec.ts @@ -1,9 +1,6 @@ -import { - createDirectiveFactory, - SpectatorDirective, -} from '@ngneat/spectator'; +import { createDirectiveFactory, SpectatorDirective } from '@ngneat/spectator'; import { Directive, Inject, InjectionToken } from '@angular/core'; -import { overrideDirectives } from "../src/lib/spectator/create-factory"; +import { overrideDirectives } from '../src/lib/spectator/create-factory'; // Created only for testing purpose export const directiveProviderToken = new InjectionToken('DirectiveProviderToken'); @@ -36,7 +33,7 @@ describe('Override Directive', () => { }, ], ], - } as any) + } as any), ).toThrowError('Can not override non standalone directive'); }); @@ -54,7 +51,7 @@ describe('Override Directive', () => { }, ], ], - template: `
Testing Directive Providers
` + template: `
Testing Directive Providers
`, }); beforeEach(() => { diff --git a/projects/spectator/test/override-module.spec.ts b/projects/spectator/test/override-module.spec.ts index b3578589..3d4bfb20 100644 --- a/projects/spectator/test/override-module.spec.ts +++ b/projects/spectator/test/override-module.spec.ts @@ -5,7 +5,7 @@ import { createHostFactory, Spectator, SpectatorDirective, - SpectatorHost + SpectatorHost, } from '@ngneat/spectator'; import { AveragePipe } from './pipe/average.pipe'; @@ -28,7 +28,7 @@ describe('Override Module With Component Factory', () => { const createComponent = createComponentFactory({ component: TestComponent, imports: [SomeModule], - overrideModules: [[SomeModule, { set: { declarations: [AveragePipe], exports: [AveragePipe] } }]] + overrideModules: [[SomeModule, { set: { declarations: [AveragePipe], exports: [AveragePipe] } }]], }); beforeEach(() => { @@ -47,7 +47,7 @@ describe('Override Module With Directive Factory', () => { directive: SomeDirective, host: TestComponent, imports: [SomeModule], - overrideModules: [[SomeModule, { set: { declarations: [AveragePipe], exports: [AveragePipe] } }]] + overrideModules: [[SomeModule, { set: { declarations: [AveragePipe], exports: [AveragePipe] } }]], }); beforeEach(() => { @@ -65,7 +65,7 @@ describe('Override Module With Host Factory', () => { const createHost = createHostFactory({ component: TestComponent, imports: [SomeModule], - overrideModules: [[SomeModule, { set: { declarations: [AveragePipe], exports: [AveragePipe] } }]] + overrideModules: [[SomeModule, { set: { declarations: [AveragePipe], exports: [AveragePipe] } }]], }); beforeEach(() => { diff --git a/projects/spectator/test/override-pipe.spec.ts b/projects/spectator/test/override-pipe.spec.ts index 03a6c56c..e0a8ab26 100644 --- a/projects/spectator/test/override-pipe.spec.ts +++ b/projects/spectator/test/override-pipe.spec.ts @@ -1,12 +1,12 @@ import { Pipe, PipeTransform } from '@angular/core'; -import { overridePipes } from "../src/lib/spectator/create-factory"; -import { createPipeFactory, SpectatorPipe } from "@ngneat/spectator"; +import { overridePipes } from '../src/lib/spectator/create-factory'; +import { createPipeFactory, SpectatorPipe } from '@ngneat/spectator'; // Created only for testing purpose @Pipe({ name: `standalonePipe`, standalone: true, - pure: false + pure: false, }) export class StandalonePipe implements PipeTransform { public transform(value: number[]): number[] { @@ -34,7 +34,7 @@ describe('Override Pipe', () => { }, ], ], - } as any) + } as any), ).toThrowError('Can not override non standalone pipe'); }); @@ -59,8 +59,8 @@ describe('Override Pipe', () => { }); it('should render a StandaloneWithImportsComponent', () => { - expect(spectator).toBeTruthy() - expect(spectator.element).toHaveText('1,2,3') + expect(spectator).toBeTruthy(); + expect(spectator.element).toHaveText('1,2,3'); }); }); }); diff --git a/projects/spectator/test/pipe/alternating-sum.pipe.ts b/projects/spectator/test/pipe/alternating-sum.pipe.ts index 64fe6972..8857be0b 100644 --- a/projects/spectator/test/pipe/alternating-sum.pipe.ts +++ b/projects/spectator/test/pipe/alternating-sum.pipe.ts @@ -3,7 +3,7 @@ import { Pipe, PipeTransform } from '@angular/core'; import { StatsService } from './stats.service'; @Pipe({ - name: 'alternatingSum' + name: 'alternatingSum', }) export class AlternatingSumPipe implements PipeTransform { constructor(private readonly statsService: StatsService) {} diff --git a/projects/spectator/test/pipe/stats.service.ts b/projects/spectator/test/pipe/stats.service.ts index 8a24a010..80aff4dc 100644 --- a/projects/spectator/test/pipe/stats.service.ts +++ b/projects/spectator/test/pipe/stats.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class StatsService { public alternatingSum(input: number[]): number { diff --git a/projects/spectator/test/pipe/sum.pipe.spec.ts b/projects/spectator/test/pipe/sum.pipe.spec.ts index 10345512..718e0aa4 100644 --- a/projects/spectator/test/pipe/sum.pipe.spec.ts +++ b/projects/spectator/test/pipe/sum.pipe.spec.ts @@ -15,8 +15,8 @@ describe('SumPipe', () => { it('should sum up the given list of numbers (prop)', () => { spectator = createPipe(`{{ prop | sum }}`, { hostProps: { - prop: [1, 2, 3] - } + prop: [1, 2, 3], + }, }); expect(spectator.element).toHaveText('6'); }); @@ -26,9 +26,9 @@ describe('SumPipe', () => { const provider = { provide: StatsService, useValue: { sum } }; spectator = createPipe(`{{ prop | sum }}`, { hostProps: { - prop: [2, 40] + prop: [2, 40], }, - providers: [provider] + providers: [provider], }); expect(spectator.element).toHaveText('42'); }); diff --git a/projects/spectator/test/pipe/sum.pipe.ts b/projects/spectator/test/pipe/sum.pipe.ts index fb3ed208..6922d77b 100644 --- a/projects/spectator/test/pipe/sum.pipe.ts +++ b/projects/spectator/test/pipe/sum.pipe.ts @@ -3,7 +3,7 @@ import { Pipe, PipeTransform } from '@angular/core'; import { StatsService } from './stats.service'; @Pipe({ - name: 'sum' + name: 'sum', }) export class SumPipe implements PipeTransform { constructor(private readonly statsService: StatsService) {} diff --git a/projects/spectator/test/provider.service.ts b/projects/spectator/test/provider.service.ts index b4a64958..95b54c47 100644 --- a/projects/spectator/test/provider.service.ts +++ b/projects/spectator/test/provider.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { Subject } from 'rxjs'; @Injectable({ - providedIn: 'root' + providedIn: 'root', }) export class ProviderService { public obs$ = new Subject(); diff --git a/projects/spectator/test/set-input/set-input.component.spec.ts b/projects/spectator/test/set-input/set-input.component.spec.ts index 7747f5ce..159cda36 100644 --- a/projects/spectator/test/set-input/set-input.component.spec.ts +++ b/projects/spectator/test/set-input/set-input.component.spec.ts @@ -8,7 +8,7 @@ describe('SetInputComponent', () => { const createComponent = createComponentFactory({ component: SetInputComponent, - imports: [CommonModule] + imports: [CommonModule], }); beforeEach(() => { diff --git a/projects/spectator/test/signal-input/signal-input.component.ts b/projects/spectator/test/signal-input/signal-input.component.ts index fe4401ae..726b0950 100644 --- a/projects/spectator/test/signal-input/signal-input.component.ts +++ b/projects/spectator/test/signal-input/signal-input.component.ts @@ -3,8 +3,8 @@ import { Component, input, ɵINPUT_SIGNAL_BRAND_WRITE_TYPE } from '@angular/core @Component({ selector: 'app-signal-input', template: ` - @if(show()) { -
Hello
+ @if (show()) { +
Hello
} `, standalone: true, diff --git a/projects/spectator/test/simple-changes/simple-changes.component.spec.ts b/projects/spectator/test/simple-changes/simple-changes.component.spec.ts index bed88c32..fb8c2b76 100644 --- a/projects/spectator/test/simple-changes/simple-changes.component.spec.ts +++ b/projects/spectator/test/simple-changes/simple-changes.component.spec.ts @@ -8,12 +8,12 @@ describe('SimpleChangesComponent', () => { const createComponent = createComponentFactory({ component: SimpleChangesComponent, - imports: [CommonModule] + imports: [CommonModule], }); it('should be sequence of calls is correct', () => { spectator = createComponent({ - props: { value: '1' } + props: { value: '1' }, }); const { hooks } = spectator.component; diff --git a/projects/spectator/test/spectator-routing/activated-route-stub.spec.ts b/projects/spectator/test/spectator-routing/activated-route-stub.spec.ts index dc3e3e38..5d7a746d 100644 --- a/projects/spectator/test/spectator-routing/activated-route-stub.spec.ts +++ b/projects/spectator/test/spectator-routing/activated-route-stub.spec.ts @@ -21,16 +21,16 @@ describe('ActivatedRouteStub', () => { const routeOptions: RouteOptions = { params: { - test: 'test' + test: 'test', }, queryParams: { - test: 'test' + test: 'test', }, data: { - test: 'test' + test: 'test', }, fragment: 'test', - url: [urlSegment] + url: [urlSegment], }; const activatedRouteStub = new ActivatedRouteStub(routeOptions); @@ -38,13 +38,13 @@ describe('ActivatedRouteStub', () => { const { params, queryParams, data, fragment, url } = activatedRouteStub.snapshot; expect(params).toEqual({ - test: 'test' + test: 'test', }); expect(queryParams).toEqual({ - test: 'test' + test: 'test', }); expect(data).toEqual({ - test: 'test' + test: 'test', }); expect(fragment).toEqual('test'); expect(url).toContain(urlSegment); @@ -54,7 +54,7 @@ describe('ActivatedRouteStub', () => { const activatedRouteStub = new ActivatedRouteStub(); activatedRouteStub.setParams({ - test: 'test' + test: 'test', }); expect(activatedRouteStub.snapshot).not.toBeNull(); @@ -62,7 +62,7 @@ describe('ActivatedRouteStub', () => { const { params } = activatedRouteStub.snapshot; expect(params).toEqual({ - test: 'test' + test: 'test', }); }); @@ -76,7 +76,7 @@ describe('ActivatedRouteStub', () => { const { params } = activatedRouteStub.snapshot; expect(params).toEqual({ - test: 'test' + test: 'test', }); }); @@ -84,7 +84,7 @@ describe('ActivatedRouteStub', () => { const activatedRouteStub = new ActivatedRouteStub(); activatedRouteStub.setQueryParams({ - test: 'test' + test: 'test', }); expect(activatedRouteStub.snapshot).not.toBeNull(); @@ -92,7 +92,7 @@ describe('ActivatedRouteStub', () => { const { queryParams } = activatedRouteStub.snapshot; expect(queryParams).toEqual({ - test: 'test' + test: 'test', }); }); @@ -106,7 +106,7 @@ describe('ActivatedRouteStub', () => { const { queryParams } = activatedRouteStub.snapshot; expect(queryParams).toEqual({ - test: 'test' + test: 'test', }); }); @@ -114,7 +114,7 @@ describe('ActivatedRouteStub', () => { const activatedRouteStub = new ActivatedRouteStub(); activatedRouteStub.setAllData({ - test: 'test' + test: 'test', }); expect(activatedRouteStub.snapshot).not.toBeNull(); @@ -122,7 +122,7 @@ describe('ActivatedRouteStub', () => { const { data } = activatedRouteStub.snapshot; expect(data).toEqual({ - test: 'test' + test: 'test', }); }); @@ -136,14 +136,14 @@ describe('ActivatedRouteStub', () => { const { data } = activatedRouteStub.snapshot; expect(data).toEqual({ - test: 'test' + test: 'test', }); }); it('should update data in snapshot with any type of value', () => { const activatedRouteStub = new ActivatedRouteStub(); - activatedRouteStub.setData('movieName', 'Avengers') + activatedRouteStub.setData('movieName', 'Avengers'); activatedRouteStub.setData('countries', ['USA', 'Canada']); activatedRouteStub.setData('animal', { type: 'dog' }); @@ -155,10 +155,10 @@ describe('ActivatedRouteStub', () => { movieName: 'Avengers', countries: ['USA', 'Canada'], animal: { - type: 'dog' - } + type: 'dog', + }, }); - }) + }); it('should update fragment in snapshot when set', () => { const activatedRouteStub = new ActivatedRouteStub(); diff --git a/projects/spectator/test/todos-data.service.spec.ts b/projects/spectator/test/todos-data.service.spec.ts index ad77151d..37340108 100644 --- a/projects/spectator/test/todos-data.service.spec.ts +++ b/projects/spectator/test/todos-data.service.spec.ts @@ -7,7 +7,7 @@ import { TodosDataService, UserService } from './todos-data.service'; describe('HttpClient testing', () => { const http = createHttpFactory({ service: TodosDataService, - mocks: [UserService] + mocks: [UserService], }); it('can test HttpClient.get', () => { @@ -39,10 +39,10 @@ describe('HttpClient testing', () => { const spectatorHttp = http(); spectatorHttp.service.concurrentRequests().subscribe(); - const reqs = spectatorHttp.expectConcurrent(['one', 'two', 'three'].map(url => ({ url, method: HttpMethod.POST }))); + const reqs = spectatorHttp.expectConcurrent(['one', 'two', 'three'].map((url) => ({ url, method: HttpMethod.POST }))); spectatorHttp.flushAll( reqs, - Array.from({ length: 3 }, _ => ({})) + Array.from({ length: 3 }, (_) => ({})), ); }); diff --git a/projects/spectator/test/todos-data.service.ts b/projects/spectator/test/todos-data.service.ts index fd1d90f5..43269853 100644 --- a/projects/spectator/test/todos-data.service.ts +++ b/projects/spectator/test/todos-data.service.ts @@ -11,7 +11,10 @@ export class UserService { @Injectable() export class TodosDataService { - constructor(private readonly http: HttpClient, private readonly userService: UserService) {} + constructor( + private readonly http: HttpClient, + private readonly userService: UserService, + ) {} public get(): Observable { return this.http.get('url'); @@ -25,7 +28,7 @@ export class TodosDataService { return this.http.post('one', {}).pipe( concatMap(() => { return this.http.get('two'); - }) + }), ); } @@ -37,7 +40,7 @@ export class TodosDataService { return this.userService.getUser().pipe( concatMap(() => { return this.http.get('two'); - }) + }), ); } } diff --git a/projects/spectator/test/translate.pipe.ts b/projects/spectator/test/translate.pipe.ts index 017d4bdd..347f6bd6 100644 --- a/projects/spectator/test/translate.pipe.ts +++ b/projects/spectator/test/translate.pipe.ts @@ -3,7 +3,7 @@ import { Pipe, PipeTransform } from '@angular/core'; import { TranslateService } from './translate.service'; @Pipe({ - name: 'translate' + name: 'translate', }) export class TranslatePipe implements PipeTransform { constructor(private readonly translateService: TranslateService) {} diff --git a/projects/spectator/test/unless/unless.component.ts b/projects/spectator/test/unless/unless.component.ts index 6f116042..72a64349 100644 --- a/projects/spectator/test/unless/unless.component.ts +++ b/projects/spectator/test/unless/unless.component.ts @@ -2,7 +2,10 @@ import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core'; @Directive({ selector: '[appUnless]' }) export class AppUnlessDirective { - constructor(private readonly templateRef: TemplateRef, private readonly viewContainer: ViewContainerRef) {} + constructor( + private readonly templateRef: TemplateRef, + private readonly viewContainer: ViewContainerRef, + ) {} @Input() public set appUnless(condition: boolean) { if (!condition) { diff --git a/projects/spectator/test/view-children/view-children.component.spec.ts b/projects/spectator/test/view-children/view-children.component.spec.ts index cf63a204..8646c9dd 100644 --- a/projects/spectator/test/view-children/view-children.component.spec.ts +++ b/projects/spectator/test/view-children/view-children.component.spec.ts @@ -11,7 +11,7 @@ describe('ViewChildrenComponent', () => { const createComponent = createComponentFactory({ component: ViewChildrenComponent, providers: [ChildServiceService], - declarations: [ChildComponent] + declarations: [ChildComponent], }); beforeEach(() => (spectator = createComponent())); @@ -25,7 +25,7 @@ describe('ViewChildrenComponent', () => { const div = spectator.query('div'); const component = spectator.query(ChildComponent); spectator.query(ChildComponent, { - read: ElementRef + read: ElementRef, }); const button = spectator.query('button'); @@ -53,7 +53,7 @@ describe('ContentChild', () => { const createHost = createHostFactory({ component: ViewChildrenComponent, providers: [ChildServiceService], - declarations: [ChildComponent] + declarations: [ChildComponent], }); it('should get also the content childs', () => { diff --git a/projects/spectator/test/view-children/view-children.component.ts b/projects/spectator/test/view-children/view-children.component.ts index 61ca4563..1f16f920 100644 --- a/projects/spectator/test/view-children/view-children.component.ts +++ b/projects/spectator/test/view-children/view-children.component.ts @@ -21,8 +21,8 @@ import { ChildComponent } from '../child/child.component'; :host { display: inline-block; } - ` - ] + `, + ], }) export class ViewChildrenComponent implements OnInit { @ViewChild(ChildComponent, { static: true }) public child!: ChildComponent; diff --git a/projects/spectator/test/widget.service.spec.ts b/projects/spectator/test/widget.service.spec.ts index 5df3f8d1..a8aefdcf 100644 --- a/projects/spectator/test/widget.service.spec.ts +++ b/projects/spectator/test/widget.service.spec.ts @@ -7,7 +7,7 @@ describe('WidgetService', () => { let spectator: SpectatorService; const createService = createServiceFactory({ service: WidgetService, - mocks: [WidgetDataService] + mocks: [WidgetDataService], }); it('should be defined', () => { diff --git a/projects/spectator/test/widget/widget.component.spec.ts b/projects/spectator/test/widget/widget.component.spec.ts index a5490485..84658dc9 100644 --- a/projects/spectator/test/widget/widget.component.spec.ts +++ b/projects/spectator/test/widget/widget.component.spec.ts @@ -9,7 +9,7 @@ describe('WidgetComponent', () => { const createHost = createHostFactory({ component: WidgetComponent, - mocks: [WidgetService] + mocks: [WidgetService], }); it('should work', () => { diff --git a/projects/spectator/test/widget/widget.component.ts b/projects/spectator/test/widget/widget.component.ts index 5c931027..066ca964 100644 --- a/projects/spectator/test/widget/widget.component.ts +++ b/projects/spectator/test/widget/widget.component.ts @@ -4,10 +4,8 @@ import { WidgetService } from '../widget.service'; @Component({ selector: 'app-widget', - template: ` - - `, - styles: [] + template: ` `, + styles: [], }) export class WidgetComponent implements OnInit { constructor(public widgetService: WidgetService) {} diff --git a/projects/spectator/test/with-routing/my-page.component.ts b/projects/spectator/test/with-routing/my-page.component.ts index 5fc49350..9db01396 100644 --- a/projects/spectator/test/with-routing/my-page.component.ts +++ b/projects/spectator/test/with-routing/my-page.component.ts @@ -43,7 +43,10 @@ export class MyPageComponent implements OnInit { public children?: ActivatedRoute[]; public firstChild!: ActivatedRoute | null; - constructor(private readonly route: ActivatedRoute, private readonly router: Router) {} + constructor( + private readonly route: ActivatedRoute, + private readonly router: Router, + ) {} public ngOnInit(): void { this.title = this.route.snapshot.data.title; diff --git a/projects/spectator/test/zippy/zippy.component.ts b/projects/spectator/test/zippy/zippy.component.ts index d6037088..403f3525 100644 --- a/projects/spectator/test/zippy/zippy.component.ts +++ b/projects/spectator/test/zippy/zippy.component.ts @@ -10,7 +10,7 @@ import { QueryService } from '../query.service'; :host { display: block; } - ` + `, ], template: `
@@ -23,17 +23,20 @@ import { QueryService } from '../query.service';
{{ options.color }}
- ` + `, }) export class ZippyComponent { @Input() public title; @Input() public options = { - color: 'red' + color: 'red', }; public visible = false; public updatedAsync = false; - constructor(private readonly queryService: QueryService, private titleService: Title) {} + constructor( + private readonly queryService: QueryService, + private titleService: Title, + ) {} @HostListener('keyup.esc') public onEsc(): void { this.toggle(); diff --git a/yarn.lock b/yarn.lock index 36661075..f74de913 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10132,10 +10132,10 @@ prelude-ls@~1.1.2: resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz" integrity "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==" -prettier@2.3.2: - version "2.3.2" - resolved "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz" - integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ== +prettier@3.2.5: + version "3.2.5" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.5.tgz#e52bc3090586e824964a8813b09aba6233b28368" + integrity sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A== pretty-bytes@^5.3.0: version "5.6.0"