From 7610ff643023cc9ec5262eea4df02b0b780ec31d Mon Sep 17 00:00:00 2001 From: Deborah Date: Tue, 21 May 2024 16:58:19 +0100 Subject: [PATCH 1/3] fix editor unit test --- src/app/components/editor/editor.spec.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/app/components/editor/editor.spec.ts b/src/app/components/editor/editor.spec.ts index 43f4210bc0c..bd16731a8d7 100755 --- a/src/app/components/editor/editor.spec.ts +++ b/src/app/components/editor/editor.spec.ts @@ -1,13 +1,13 @@ -import { TestBed, ComponentFixture } from '@angular/core/testing'; +import { TestBed, ComponentFixture, waitForAsync } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { Editor } from './editor'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -describe('Editor', () => { +fdescribe('Editor', () => { let editor: Editor; let fixture: ComponentFixture; - beforeEach(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [NoopAnimationsModule], declarations: [Editor] @@ -15,7 +15,7 @@ describe('Editor', () => { fixture = TestBed.createComponent(Editor); editor = fixture.componentInstance; - }); + })); it('should display by default', () => { fixture.detectChanges(); @@ -25,9 +25,7 @@ describe('Editor', () => { }); it('should show value', () => { - editor.value = 'V'; - fixture.detectChanges(); - + editor.writeValue('V'); fixture.detectChanges(); const paragraphEl = fixture.debugElement.query(By.css('.p-editor-content')).nativeElement.children[0].children[0]; From e2f9d484db3848afda561c5966d887362a399d8a Mon Sep 17 00:00:00 2001 From: Deborah Date: Tue, 21 May 2024 17:05:20 +0100 Subject: [PATCH 2/3] remove fdescribe --- src/app/components/editor/editor.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/editor/editor.spec.ts b/src/app/components/editor/editor.spec.ts index bd16731a8d7..d293bcf0347 100755 --- a/src/app/components/editor/editor.spec.ts +++ b/src/app/components/editor/editor.spec.ts @@ -3,7 +3,7 @@ import { By } from '@angular/platform-browser'; import { Editor } from './editor'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -fdescribe('Editor', () => { +describe('Editor', () => { let editor: Editor; let fixture: ComponentFixture; From 68698a8ff64c0a6d2c3d9edd46cc7ddf42e7ef35 Mon Sep 17 00:00:00 2001 From: Deborah Date: Tue, 21 May 2024 18:02:45 +0100 Subject: [PATCH 3/3] fix table unit test --- src/app/components/table/table.spec.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/components/table/table.spec.ts b/src/app/components/table/table.spec.ts index 797aa12e639..15ddd9f3032 100755 --- a/src/app/components/table/table.spec.ts +++ b/src/app/components/table/table.spec.ts @@ -1238,9 +1238,9 @@ describe('Table', () => { fixture.detectChanges(); expect(onColumnResizeEndSpy).toHaveBeenCalled(); - expect(resizerEls[0].parentElement.clientWidth).toEqual(firstWidth - 30); - expect(resizerEls[0].parentElement.clientWidth).not.toEqual(firstWidth); - expect(defaultWidth).toEqual(resizerEls[0].parentElement.parentElement.clientWidth); + expect(resizerEls[0]?.parentElement?.clientWidth).toEqual(firstWidth - 30); + expect(resizerEls[0]?.parentElement?.clientWidth).not.toEqual(firstWidth); + expect(defaultWidth).toEqual(resizerEls[0]!.parentElement!.parentElement!.clientWidth); }); it('should call resize and resizeColGroup with scrollableTable (fit)', () => { @@ -1249,13 +1249,13 @@ describe('Table', () => { fixture.detectChanges(); let resizerEls = document.getElementsByClassName('p-column-resizer'); - let defaultWidth = resizerEls[0].parentElement.parentElement.clientWidth; + let defaultWidth = resizerEls[0]?.parentElement?.parentElement?.clientWidth; const onColumnResizeBeginSpy = spyOn(colResizeTable, 'onColumnResizeBegin').and.callThrough(); const event: any = document.createEvent('CustomEvent'); event.pageX = 450; event.which = 1; event.initEvent('mousedown'); - let firstWidth = resizerEls[0].parentElement.clientWidth; + let firstWidth = resizerEls[0]?.parentElement?.clientWidth; resizerEls[0].dispatchEvent(event as MouseEvent); fixture.detectChanges(); @@ -1443,7 +1443,7 @@ describe('Table', () => { it('should open contextMenu and select row', () => { fixture.detectChanges(); - const contextMenu = fixture.debugElement.query(By.css('.p-contextmenu')).componentInstance as ContextMenu; + const contextMenu = fixture.debugElement.query(By.directive(ContextMenu)).componentInstance; const showSpy = spyOn(contextMenu, 'show').and.callThrough(); const contextMenuTableEl = fixture.debugElement.query(By.css('.contextMenuTable')); const rowEls = contextMenuTableEl.queryAll(By.css('tr')); @@ -1465,7 +1465,7 @@ describe('Table', () => { contextMenuTable.contextMenuSelectionMode = 'joint'; fixture.detectChanges(); - const contextMenu = fixture.debugElement.query(By.css('.p-contextmenu')).componentInstance as ContextMenu; + const contextMenu = fixture.debugElement.query(By.directive(ContextMenu)).componentInstance; const showSpy = spyOn(contextMenu, 'show').and.callThrough(); const contextMenuTableEl = fixture.debugElement.query(By.css('.contextMenuTable')); const rowEls = contextMenuTableEl.queryAll(By.css('tr')); @@ -1487,7 +1487,7 @@ describe('Table', () => { contextMenuTable.contextMenuSelectionMode = 'joint'; fixture.detectChanges(); - const contextMenu = fixture.debugElement.query(By.css('.p-contextmenu')).componentInstance as ContextMenu; + const contextMenu = fixture.debugElement.query(By.directive(ContextMenu)).componentInstance; const showSpy = spyOn(contextMenu, 'show').and.callThrough(); const contextMenuTableEl = fixture.debugElement.query(By.css('.contextMenuTable')); const rowEls = contextMenuTableEl.queryAll(By.css('tr'));