-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(entities-shared): fix tag max width, add test
- Loading branch information
Showing
2 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
packages/entities/entities-shared/src/components/common/TableTags.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import TableTags from './TableTags.vue' | ||
|
||
const tagsArray = ['tag1', 'tag2', 'tag3'] | ||
const tagsString = JSON.stringify(tagsArray) | ||
|
||
const emptyArray = [] as string[] | ||
const emptyString = '[]' | ||
const nullString = 'null' | ||
|
||
describe('<TableTags />', () => { | ||
it('renders normal array correctly', () => { | ||
cy.mount(TableTags, { | ||
props: { | ||
tags: tagsArray, | ||
}, | ||
}) | ||
|
||
cy.get('.k-truncate').should('exist') | ||
cy.get('.k-badge').should('have.length', tagsArray.length) | ||
}) | ||
|
||
it('renders JSON string correctly', () => { | ||
cy.mount(TableTags, { | ||
props: { | ||
tags: tagsString, | ||
}, | ||
}) | ||
|
||
cy.get('.k-truncate').should('exist') | ||
cy.get('.k-badge').should('have.length', tagsArray.length) | ||
}) | ||
|
||
it('renders empty array correctly', () => { | ||
cy.mount(TableTags, { | ||
props: { | ||
tags: emptyArray, | ||
}, | ||
}) | ||
|
||
cy.get('.k-truncate').should('not.exist') | ||
cy.get('.k-badge').should('not.exist') | ||
cy.get('span').should('have.text', '-') | ||
}) | ||
|
||
it('renders empty string correctly', () => { | ||
cy.mount(TableTags, { | ||
props: { | ||
tags: emptyString, | ||
}, | ||
}) | ||
|
||
cy.get('.k-truncate').should('not.exist') | ||
cy.get('.k-badge').should('not.exist') | ||
cy.get('span').should('have.text', '-') | ||
}) | ||
|
||
it('renders null string correctly', () => { | ||
cy.mount(TableTags, { | ||
props: { | ||
tags: nullString, | ||
}, | ||
}) | ||
|
||
cy.get('.k-truncate').should('not.exist') | ||
cy.get('.k-badge').should('not.exist') | ||
cy.get('span').should('have.text', '-') | ||
}) | ||
|
||
it('renders tag max width correctly', () => { | ||
cy.mount(TableTags, { | ||
props: { | ||
tags: tagsArray, | ||
tagMaxWidth: '100', | ||
}, | ||
}) | ||
|
||
cy.get('.k-truncate').should('exist') | ||
cy.get('.badge-content-wrapper').should('have.css', 'max-width', '100px') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters