From dc0e9b49a4015f70d65a528d5c22cc987e15fdc4 Mon Sep 17 00:00:00 2001 From: Jairo Chaves Date: Thu, 12 Mar 2026 10:49:15 -0300 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20corrige=20tempo=20de=20notifica?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/notification/component/notification.component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/projects/ion/src/lib/notification/component/notification.component.ts b/projects/ion/src/lib/notification/component/notification.component.ts index 4ca550fbe..f0864daf0 100644 --- a/projects/ion/src/lib/notification/component/notification.component.ts +++ b/projects/ion/src/lib/notification/component/notification.component.ts @@ -92,7 +92,7 @@ export class IonNotificationComponent implements OnInit, OnDestroy { if (this.fixed() || !this.pauseOnHover() || this.isClosing) { return; } - const timeToClose = this.timeByWords(this.message()); + const timeToClose = this.timeByWords(this._getMessageToCheck()); this.autoCloseTimer = setTimeout(() => { this.closeNotification(); }, timeToClose); @@ -100,13 +100,17 @@ export class IonNotificationComponent implements OnInit, OnDestroy { ngOnInit(): void { if (!this.fixed()) { - const timeToClose = this.timeByWords(this.message()); + const timeToClose = this.timeByWords(this._getMessageToCheck()); this.autoCloseTimer = setTimeout(() => { this.closeNotification(); }, timeToClose); } } + private _getMessageToCheck(): string { + return `${this.title()} ${this.message()}`; + } + ngOnDestroy(): void { clearTimeout(this.autoCloseTimer); clearTimeout(this.closeAnimationTimer); From 22b3303efdc384b1fef31d6c33f649f5ec606f70 Mon Sep 17 00:00:00 2001 From: Jairo Chaves Date: Thu, 12 Mar 2026 13:34:19 -0300 Subject: [PATCH 2/3] fix: desconsidera o titulo --- .../notification/component/notification.component.spec.ts | 1 + .../lib/notification/component/notification.component.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/projects/ion/src/lib/notification/component/notification.component.spec.ts b/projects/ion/src/lib/notification/component/notification.component.spec.ts index c9ce86aa3..7d37b6902 100644 --- a/projects/ion/src/lib/notification/component/notification.component.spec.ts +++ b/projects/ion/src/lib/notification/component/notification.component.spec.ts @@ -151,6 +151,7 @@ describe('Time by words', () => { ...defaultNotification, // "word" -> 1 word. 1/3 = 0.33. + 1 = 1.33s -> 1000ms. message: 'word', + title: '', fixed: false, }, on: { diff --git a/projects/ion/src/lib/notification/component/notification.component.ts b/projects/ion/src/lib/notification/component/notification.component.ts index f0864daf0..71588f76c 100644 --- a/projects/ion/src/lib/notification/component/notification.component.ts +++ b/projects/ion/src/lib/notification/component/notification.component.ts @@ -108,6 +108,13 @@ export class IonNotificationComponent implements OnInit, OnDestroy { } private _getMessageToCheck(): string { + if (!this.title()) { + return this.message(); + } + if (!this.message()) { + return this.title(); + } + return `${this.title()} ${this.message()}`; } From 531baea788c05f5d1520e9185969f187fa726820 Mon Sep 17 00:00:00 2001 From: Jairo Chaves Date: Thu, 12 Mar 2026 13:47:21 -0300 Subject: [PATCH 3/3] feat: adiciona casos de testes para titulo --- .../component/notification.component.spec.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/projects/ion/src/lib/notification/component/notification.component.spec.ts b/projects/ion/src/lib/notification/component/notification.component.spec.ts index 7d37b6902..c14345872 100644 --- a/projects/ion/src/lib/notification/component/notification.component.spec.ts +++ b/projects/ion/src/lib/notification/component/notification.component.spec.ts @@ -162,6 +162,42 @@ describe('Time by words', () => { jest.advanceTimersByTime(2500); // 1000ms delay + 1000ms animation + buffer expect(ionOnCloseSpy).toHaveBeenCalled(); }); + + it('should emit close event when only title is passed', async () => { + const ionOnCloseSpy = jest.fn(); + await render(IonNotificationComponent, { + componentInputs: { + title: 'Notification Title', + message: '', + fixed: false, + }, + on: { + ionOnClose: ionOnCloseSpy, + }, + }); + + // "Notification Title" -> 2 words. 2/3 = 0.66. + 1 = 1.66s -> 2000ms. + jest.advanceTimersByTime(3500); // 2000ms delay + 1000ms animation + buffer + expect(ionOnCloseSpy).toHaveBeenCalled(); + }); + + it('should emit close event when title and message are passed', async () => { + const ionOnCloseSpy = jest.fn(); + await render(IonNotificationComponent, { + componentInputs: { + title: 'Title', + message: 'This is a message', + fixed: false, + }, + on: { + ionOnClose: ionOnCloseSpy, + }, + }); + + // "Title This is a message" -> 5 words. 5/3 = 1.66. + 1 = 2.66s -> 3000ms. + jest.advanceTimersByTime(4500); // 3000ms delay + 1000ms animation + buffer + expect(ionOnCloseSpy).toHaveBeenCalled(); + }); }); describe('Pause on hover', () => {