diff --git a/projects/ion/src/lib/smart-table/smart-table.component.html b/projects/ion/src/lib/smart-table/smart-table.component.html index 87b38d154..934144c44 100644 --- a/projects/ion/src/lib/smart-table/smart-table.component.html +++ b/projects/ion/src/lib/smart-table/smart-table.component.html @@ -246,7 +246,7 @@ [circularButton]="true" (ionOnClick)="handleEvent(row, action)" [disabled]=" - action.disabled ? !disableAction(row, action) : false + action.disabled ? disableAction(row, action) : false " > diff --git a/projects/ion/src/lib/smart-table/smart-table.component.spec.ts b/projects/ion/src/lib/smart-table/smart-table.component.spec.ts index 964d0d163..cf8221544 100644 --- a/projects/ion/src/lib/smart-table/smart-table.component.spec.ts +++ b/projects/ion/src/lib/smart-table/smart-table.component.spec.ts @@ -345,13 +345,27 @@ describe('Table > Actions', () => { ); }); - it('should render trash button disabled when he caracther is less than 160cm', async () => { + it('should render trash button enable when he character is less than 160cm', async () => { const tableItemDeleted = { ...tableWithActions, } as IonSmartTableProps; tableItemDeleted.config.data = [{ height: 96, name: 'RS-D2', mass: 96 }]; + await sut(tableItemDeleted); + expect(screen.getByTestId('row-0-Desabilitar')).toHaveAttribute( + 'ng-reflect-disabled', + 'false' + ); + }); + + it('should render trash button disabled when he character is taller than 160cm', async () => { + const tableItemDeleted = { + ...tableWithActions, + } as IonSmartTableProps; + + tableItemDeleted.config.data = [{ height: 196, name: 'RS-D2', mass: 96 }]; + await sut(tableItemDeleted); expect(screen.getByTestId('row-0-Desabilitar')).toHaveAttribute( 'ng-reflect-disabled', diff --git a/projects/ion/src/lib/table/table.component.html b/projects/ion/src/lib/table/table.component.html index cbec8bf55..f1dd05b1c 100644 --- a/projects/ion/src/lib/table/table.component.html +++ b/projects/ion/src/lib/table/table.component.html @@ -171,7 +171,7 @@ [circularButton]="true" (ionOnClick)="handleEvent(row, action)" [disabled]=" - action.disabled ? !disableAction(row, action) : false + action.disabled ? disableAction(row, action) : false " > diff --git a/projects/ion/src/lib/table/table.component.spec.ts b/projects/ion/src/lib/table/table.component.spec.ts index 5d63d0d9a..aeaf02106 100644 --- a/projects/ion/src/lib/table/table.component.spec.ts +++ b/projects/ion/src/lib/table/table.component.spec.ts @@ -282,7 +282,7 @@ describe('Table > Actions', () => { label: 'Desabilitar', icon: 'block', disabled: (row: SafeAny): boolean => { - return !row.deleted; + return row.deleted; }, }, { @@ -337,6 +337,22 @@ describe('Table > Actions', () => { expect(within(rowAction).getByRole('button')).toHaveClass('danger'); }); + it('should render trash button enabled when the item is not deleted', async () => { + const tableItemDeleted = { + ...tableWithActions, + } as IonTableProps; + + tableItemDeleted.config.data = [ + { id: 1, name: 'Item Deleted', deleted: false }, + ]; + + await sut(tableItemDeleted); + expect(screen.getByTestId('row-0-Desabilitar')).toHaveAttribute( + 'ng-reflect-disabled', + 'false' + ); + }); + it('should render trash button disabled when the item is deleted', async () => { const tableItemDeleted = { ...tableWithActions,