Skip to content

Commit

Permalink
test: add component test for UUIDTag
Browse files Browse the repository at this point in the history
  • Loading branch information
yunchipang committed Oct 29, 2024
1 parent c40c5ab commit d200917
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/components/common/UUIDTag.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import UUIDTag from './UUIDTag';

describe('UUIDTag', () => {
beforeEach(() => {
cy.viewport(500, 500);
});

it('renders correctly with a valid UUID string', () => {
const testId = '12345678';
cy.mount(<UUIDTag uuid={testId} />);
cy.contains('1234...5678').should('exist');
});

it('handles non-string UUID values gracefully', () => {
const testIdNonString = 12345678;
cy.mount(<UUIDTag uuid={testIdNonString} />);
cy.contains('1234...5678').should('exist');
});

it('displays a fallback for undefined UUID', () => {
cy.mount(<UUIDTag uuid={undefined} />);
cy.contains('...').should('exist');
});
});

0 comments on commit d200917

Please sign in to comment.