diff --git a/libs/composables/attribute/src/attribute.composable.spec.ts b/libs/composables/attribute/src/attribute.composable.spec.ts index fd1506f..e2aebc9 100644 --- a/libs/composables/attribute/src/attribute.composable.spec.ts +++ b/libs/composables/attribute/src/attribute.composable.spec.ts @@ -19,9 +19,7 @@ describe('attribute.composable.ts', () => { provide: ElementRef, useValue: { nativeElement: { - getAttributeNS: jest - .fn() - .mockImplementation(() => initialAssignedValue) + getAttributeNS: jest.fn().mockImplementation(() => initialAssignedValue) } } }, @@ -37,10 +35,7 @@ describe('attribute.composable.ts', () => { it('should call bindAttribute with the correct arguments', () => { TestBed.runInInjectionContext(() => { // Arrange - const bindAttributeSpy = jest.spyOn( - attributeModule, - 'bindAttribute' - ); + const bindAttributeSpy = jest.spyOn(attributeModule, 'bindAttribute'); // Act const value = useAttribute('name', { @@ -50,15 +45,11 @@ describe('attribute.composable.ts', () => { }); // Assert - expect(bindAttributeSpy).toHaveBeenCalledWith( - 'name', - value, - { - defaultValue: 'bar', - namespace: 'my', - target: inject(ElementRef).nativeElement - } - ); + expect(bindAttributeSpy).toHaveBeenCalledWith('name', value, { + defaultValue: 'bar', + namespace: 'my', + target: inject(ElementRef).nativeElement + }); bindAttributeSpy.mockRestore(); }); @@ -89,19 +80,17 @@ describe('attribute.composable.ts', () => { }); it('the defaultValue, if initialValue is `null`', () => { - TestBed.runInInjectionContext(() => { - // Act - const result = useAttribute('name', { - initialValue: null, - defaultValue: 'bar' - }); - - // Assert - expect(result()).toEqual('bar'); + TestBed.runInInjectionContext(() => { + // Act + const result = useAttribute('name', { + initialValue: null, + defaultValue: 'bar' }); - } - ); + // Assert + expect(result()).toEqual('bar'); + }); + }); it('the initial assigned value in the DOM if no initialValue has been defined', () => { TestBed.runInInjectionContext(() => { @@ -147,6 +136,7 @@ describe('attribute.composable.ts', () => { } @Component({ + imports: [TestButtonComponent], template: ` @@ -165,7 +155,7 @@ describe('attribute.composable.ts', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ ParentComponent, TestButtonComponent ] + imports: [ParentComponent, TestButtonComponent] }).compileComponents(); fixture = TestBed.createComponent(ParentComponent); @@ -181,9 +171,7 @@ describe('attribute.composable.ts', () => { it('should fall back to default value, when the value is set to `undefined`', () => { // Arrange - const buttonADebug = fixture.debugElement.queryAll( - By.directive(TestButtonComponent) - )[0]; + const buttonADebug = fixture.debugElement.queryAll(By.directive(TestButtonComponent))[0]; // Act component.buttonA.type.set(undefined); @@ -195,9 +183,7 @@ describe('attribute.composable.ts', () => { it('should not fall back to default value, when the value is set to `null`', () => { // Arrange - const buttonADebug = fixture.debugElement.queryAll( - By.directive(TestButtonComponent) - )[0]; + const buttonADebug = fixture.debugElement.queryAll(By.directive(TestButtonComponent))[0]; // Act component.buttonA.type.set(null); @@ -217,18 +203,14 @@ describe('attribute.composable.ts', () => { describe('when a namespace has been defined', () => { it('should set the attribute with the namespace', () => { // Arrange - const buttonADebug = fixture.debugElement.queryAll( - By.directive(TestButtonComponent) - )[0]; + const buttonADebug = fixture.debugElement.queryAll(By.directive(TestButtonComponent))[0]; // Act component.buttonA.label.set('Button A'); fixture.detectChanges(); // Assert - expect(buttonADebug.attributes['bx:label']).toEqual( - 'Button A' - ); + expect(buttonADebug.attributes['bx:label']).toEqual('Button A'); }); }); }); @@ -287,7 +269,7 @@ describe('attribute.composable.ts', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ TestComponent ] + imports: [TestComponent] }).compileComponents(); fixture = TestBed.createComponent(TestComponent); @@ -305,32 +287,26 @@ describe('attribute.composable.ts', () => { }); it('should set a namespaced attribute correctly', () => { - expect(fixture.debugElement.attributes['my:title']).toEqual( - 'Hello' - ); + expect(fixture.debugElement.attributes['my:title']).toEqual('Hello'); }); - it.each([ null, undefined ])( - 'should remove the attribute, when setting the signal\'s value to %s', + it.each([null, undefined])( + "should remove the attribute, when setting the signal's value to %s", (value) => { component.name.set(value); fixture.detectChanges(); - expect( - fixture.debugElement.attributes['name'] - ).toBeUndefined(); + expect(fixture.debugElement.attributes['name']).toBeUndefined(); } ); - it('should change the attribute, when the signal\'s value changes', () => { + it("should change the attribute, when the signal's value changes", () => { component.role.set('button'); fixture.detectChanges(); - expect(fixture.debugElement.attributes['role']).toEqual( - 'button' - ); + expect(fixture.debugElement.attributes['role']).toEqual('button'); }); it('should bind the attribute on the custom target', () => { diff --git a/libs/composables/attribute/src/boolean-attribute.composable.spec.ts b/libs/composables/attribute/src/boolean-attribute.composable.spec.ts index 5541e06..773499b 100644 --- a/libs/composables/attribute/src/boolean-attribute.composable.spec.ts +++ b/libs/composables/attribute/src/boolean-attribute.composable.spec.ts @@ -22,7 +22,7 @@ describe('useBooleanAttribute', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ TestComponent ] + imports: [TestComponent] }).compileComponents(); fixture = TestBed.createComponent(TestComponent); @@ -51,7 +51,7 @@ describe('useBooleanAttribute', () => { expect(fixture.debugElement.attributes['my:editable']).toEqual(''); }); - it('should remove the attribute, when setting the signal\'s value to `false`', () => { + it("should remove the attribute, when setting the signal's value to `false`", () => { component.loading.set(false); fixture.detectChanges(); @@ -59,7 +59,7 @@ describe('useBooleanAttribute', () => { expect(fixture.debugElement.attributes['loading']).toBeUndefined(); }); - it('should set the attribute, when setting the signal\'s value to `true`', () => { + it("should set the attribute, when setting the signal's value to `true`", () => { component.disabled.set(true); fixture.detectChanges(); diff --git a/libs/composables/class/src/class.composable.spec.ts b/libs/composables/class/src/class.composable.spec.ts index a3167bf..ca174a8 100644 --- a/libs/composables/class/src/class.composable.spec.ts +++ b/libs/composables/class/src/class.composable.spec.ts @@ -17,7 +17,7 @@ describe('useClass', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ TestComponent ] + imports: [TestComponent] }).compileComponents(); fixture = TestBed.createComponent(TestComponent); @@ -34,7 +34,7 @@ describe('useClass', () => { expect(fixture.debugElement.classes['highlighted']).toBeTruthy(); }); - it('should add the class, when setting the signal\'s value to `true`', () => { + it("should add the class, when setting the signal's value to `true`", () => { component.test.set(false); fixture.detectChanges(); @@ -42,7 +42,7 @@ describe('useClass', () => { expect(fixture.debugElement.classes['test']).toBeFalsy(); }); - it('should remove the class, when setting the signal\'s value to `false`', () => { + it("should remove the class, when setting the signal's value to `false`", () => { component.highlighted.set(false); fixture.detectChanges(); diff --git a/libs/composables/class/src/classes.composable.spec.ts b/libs/composables/class/src/classes.composable.spec.ts index 58cd194..aa6755d 100644 --- a/libs/composables/class/src/classes.composable.spec.ts +++ b/libs/composables/class/src/classes.composable.spec.ts @@ -7,7 +7,7 @@ import { useClasses } from './classes.composable'; template: '' }) class TestComponent { - readonly classes = useClasses([ 'test', 'test2' ]); + readonly classes = useClasses(['test', 'test2']); } describe('useClasses', () => { @@ -16,7 +16,7 @@ describe('useClasses', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ TestComponent ] + imports: [TestComponent] }).compileComponents(); fixture = TestBed.createComponent(TestComponent); @@ -36,8 +36,8 @@ describe('useClasses', () => { }); }); - it('should remove the previous classes and add new classes, when changing the signal\'s value', () => { - component.classes.set([ 'foo', 'bar' ]); + it("should remove the previous classes and add new classes, when changing the signal's value", () => { + component.classes.set(['foo', 'bar']); fixture.detectChanges(); diff --git a/libs/composables/class/src/modifier-group.composable.spec.ts b/libs/composables/class/src/modifier-group.composable.spec.ts index 60ab4d1..842c38c 100644 --- a/libs/composables/class/src/modifier-group.composable.spec.ts +++ b/libs/composables/class/src/modifier-group.composable.spec.ts @@ -7,7 +7,7 @@ import { provideBaseClass } from './provide-base-class'; @Component({ template: '', - providers: [ provideBaseClass('c-test') ] + providers: [provideBaseClass('c-test')] }) class TestComponent { readonly color = useModifierGroup<'primary' | 'secondary' | null | undefined>('primary'); @@ -20,7 +20,7 @@ describe('useModifierGroup', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ TestComponent ] + imports: [TestComponent] }).compileComponents(); fixture = TestBed.createComponent(TestComponent); @@ -47,7 +47,7 @@ describe('useModifierGroup', () => { }); }); - it('should remove the previous modifier class and add a new modifier class, when changing the signal\'s value', () => { + it("should remove the previous modifier class and add a new modifier class, when changing the signal's value", () => { component.color.set('secondary'); fixture.detectChanges(); @@ -58,16 +58,13 @@ describe('useModifierGroup', () => { }); }); - it.each([ null, undefined ])( - 'should remove the previous modifier class the signal\'s value is set to %s', - (value) => { - component.color.set(value); + it.each([null, undefined])("should remove the previous modifier class the signal's value is set to %s", (value) => { + component.color.set(value); - fixture.detectChanges(); + fixture.detectChanges(); - expect(fixture.debugElement.classes).toEqual({ - 'c-test': true - }); - } - ); + expect(fixture.debugElement.classes).toEqual({ + 'c-test': true + }); + }); }); diff --git a/libs/composables/class/src/modifier.composable.spec.ts b/libs/composables/class/src/modifier.composable.spec.ts index 4d681d8..95afcd2 100644 --- a/libs/composables/class/src/modifier.composable.spec.ts +++ b/libs/composables/class/src/modifier.composable.spec.ts @@ -7,7 +7,7 @@ import { provideBaseClass } from './provide-base-class'; @Component({ template: '', - providers: [ provideBaseClass('c-test') ] + providers: [provideBaseClass('c-test')] }) class TestComponent { readonly disabled = useModifier('disabled', { initialValue: false }); @@ -20,7 +20,7 @@ describe('useModifier', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ TestComponent ] + imports: [TestComponent] }).compileComponents(); fixture = TestBed.createComponent(TestComponent); @@ -40,7 +40,7 @@ describe('useModifier', () => { }); }); - it('should remove the attribute, when setting the signal\'s value to `false`', () => { + it("should remove the attribute, when setting the signal's value to `false`", () => { component.loading.set(false); fixture.detectChanges(); @@ -50,7 +50,7 @@ describe('useModifier', () => { }); }); - it('should set the attribute, when setting the signal\'s value to `true`', () => { + it("should set the attribute, when setting the signal's value to `true`", () => { component.disabled.set(true); fixture.detectChanges(); diff --git a/libs/composables/class/src/utils/class.utils.spec.ts b/libs/composables/class/src/utils/class.utils.spec.ts index 5ba5e15..62314e7 100644 --- a/libs/composables/class/src/utils/class.utils.spec.ts +++ b/libs/composables/class/src/utils/class.utils.spec.ts @@ -3,26 +3,18 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { addClass, splitClasses } from './class.utils'; describe('class utils', () => { - describe('splitClasses', () => { - describe('when the input is not a string', () => { - - it.each([ - [ 'class1', 'class2', 'class3' ], - null, - undefined - ])('should return the input', (input) => { + it.each([['class1', 'class2', 'class3'], null, undefined])('should return the input', (input) => { const result = splitClasses(input); expect(result).toBe(input); }); }); describe('when the input is a string', () => { - it('should split the string into an array of classes based on whitespace', () => { const result = splitClasses('class1 class2 class3'); - expect(result).toEqual([ 'class1', 'class2', 'class3' ]); + expect(result).toEqual(['class1', 'class2', 'class3']); }); it('should return an empty array when the string is empty ', () => { @@ -33,7 +25,6 @@ describe('class utils', () => { }); describe('addClass', () => { - @Component({ template: '' }) @@ -47,7 +38,7 @@ describe('class utils', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ TestComponent ] + imports: [TestComponent] }).compileComponents(); fixture = TestBed.createComponent(TestComponent); @@ -63,5 +54,4 @@ describe('class utils', () => { expect(fixture.debugElement.classes['test']).toBeTruthy(); }); }); - }); diff --git a/libs/composables/observer/src/breakpoint.composable.spec.ts b/libs/composables/observer/src/breakpoint.composable.spec.ts index 59a7abb..59cdd41 100644 --- a/libs/composables/observer/src/breakpoint.composable.spec.ts +++ b/libs/composables/observer/src/breakpoint.composable.spec.ts @@ -21,21 +21,13 @@ describe('useBreakpoint', () => { isMatchedSubject = new BehaviorSubject(true); await TestBed.configureTestingModule({ - declarations: [ TestComponent ], + imports: [TestComponent], providers: [ { provide: BreakpointObserver, useValue: { - isMatched: jest - .fn() - .mockImplementation(() => isMatchedSubject.value), - observe: jest - .fn() - .mockReturnValue( - isMatchedSubject.pipe( - map((matches) => ({ matches })) - ) - ) + isMatched: jest.fn().mockImplementation(() => isMatchedSubject.value), + observe: jest.fn().mockReturnValue(isMatchedSubject.pipe(map((matches) => ({ matches })))) } } ] diff --git a/libs/composables/observer/src/color-scheme.composable.spec.ts b/libs/composables/observer/src/color-scheme.composable.spec.ts index 239198e..ef5a38c 100644 --- a/libs/composables/observer/src/color-scheme.composable.spec.ts +++ b/libs/composables/observer/src/color-scheme.composable.spec.ts @@ -28,7 +28,7 @@ describe('color-scheme.composable.ts', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [TestComponent] + imports: [TestComponent] }).compileComponents(); fixture = TestBed.createComponent(TestComponent); diff --git a/libs/composables/observer/src/directionality.composable.spec.ts b/libs/composables/observer/src/directionality.composable.spec.ts index 4ccab1e..296763b 100644 --- a/libs/composables/observer/src/directionality.composable.spec.ts +++ b/libs/composables/observer/src/directionality.composable.spec.ts @@ -21,7 +21,7 @@ describe('useDirectionality', () => { directionSubject = new BehaviorSubject('ltr'); await TestBed.configureTestingModule({ - declarations: [ TestComponent ], + imports: [TestComponent], providers: [ { provide: Directionality, diff --git a/libs/composables/observer/src/event.composable.spec.ts b/libs/composables/observer/src/event.composable.spec.ts index 29ee180..b36d971 100644 --- a/libs/composables/observer/src/event.composable.spec.ts +++ b/libs/composables/observer/src/event.composable.spec.ts @@ -167,7 +167,7 @@ describe('useEvent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [TestComponent] + imports: [TestComponent] }).compileComponents(); fixture = TestBed.createComponent(TestComponent); diff --git a/libs/composables/storage/src/bind-storage.composable.spec.ts b/libs/composables/storage/src/bind-storage.composable.spec.ts index d3418e1..a02b0ea 100644 --- a/libs/composables/storage/src/bind-storage.composable.spec.ts +++ b/libs/composables/storage/src/bind-storage.composable.spec.ts @@ -4,9 +4,7 @@ import { bindStorage, IBindStorageOptions } from './bind-storage.composable'; import * as readFromStorageModule from './read-from-storage.composable'; import * as writeToStorageModule from './write-to-storage.composable'; - describe('bindStorage', () => { - it('should be a function', () => { expect(typeof bindStorage).toEqual('function'); }); @@ -40,7 +38,6 @@ describe('bindStorage', () => { }); describe('integration', () => { - @Component({ template: '' }) @@ -58,7 +55,7 @@ describe('bindStorage', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ TestComponent ] + imports: [TestComponent] }).compileComponents(); fixture = TestBed.createComponent(TestComponent); diff --git a/libs/composables/storage/src/use-storage.composable.spec.ts b/libs/composables/storage/src/use-storage.composable.spec.ts index 680cf8b..dcd4432 100644 --- a/libs/composables/storage/src/use-storage.composable.spec.ts +++ b/libs/composables/storage/src/use-storage.composable.spec.ts @@ -4,7 +4,6 @@ import { useStorage } from './use-storage.composable'; import * as bindStorageModule from './bind-storage.composable'; describe('useStorage', () => { - it('should be a function', () => { expect(typeof useStorage).toEqual('function'); }); @@ -31,7 +30,6 @@ describe('useStorage', () => { }); describe('integration', () => { - @Component({ template: '' }) @@ -44,7 +42,7 @@ describe('useStorage', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ TestComponent ] + imports: [TestComponent] }).compileComponents(); fixture = TestBed.createComponent(TestComponent); diff --git a/libs/composables/storage/src/write-to-storage.composable.spec.ts b/libs/composables/storage/src/write-to-storage.composable.spec.ts index 59113c6..e3827a0 100644 --- a/libs/composables/storage/src/write-to-storage.composable.spec.ts +++ b/libs/composables/storage/src/write-to-storage.composable.spec.ts @@ -3,7 +3,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { writeToStorage } from './write-to-storage.composable'; describe('writeToStorage', () => { - @Component({ template: '' }) @@ -22,7 +21,7 @@ describe('writeToStorage', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ TestComponent ] + imports: [TestComponent] }).compileComponents(); fixture = TestBed.createComponent(TestComponent); @@ -47,10 +46,7 @@ describe('writeToStorage', () => { expect(localStorage.getItem('test')).toEqual('bar'); }); - it.each([ - null, - undefined - ])('should remove the value from storage, if it is nil', (nextValue) => { + it.each([null, undefined])('should remove the value from storage, if it is nil', (nextValue) => { component.value.set(nextValue); fixture.detectChanges();