-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ffb1d9
commit 7120e06
Showing
5 changed files
with
216 additions
and
1 deletion.
There are no files selected for viewing
Binary file added
BIN
+10 KB
cypress-visual-screenshots/baseline/Dropdown.cy.tsx-default-dropdown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10 KB
cypress-visual-screenshots/baseline/Dropdown.cy.tsx-default-md-dropdown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.81 KB
cypress-visual-screenshots/baseline/Dropdown.cy.tsx-default-xs-dropdown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,215 @@ | ||
import '../../../src/global.css'; | ||
import React from 'react'; | ||
import { Dropdown, MassaLogo, MassaToken } from '../../../src/components'; | ||
import { compareSnapshot } from '../../compareSnapshot'; | ||
|
||
describe('Component | Integration | Dropdown', function () { | ||
describe('Dropdown', () => { | ||
describe('default dropdown', () => { | ||
beforeEach(() => { | ||
cy.mount( | ||
<Dropdown | ||
options={[ | ||
{ | ||
icon: ( | ||
<MassaToken size={32} className="bg-c-default rounded-full" /> | ||
), | ||
item: 'account 1 name', | ||
onClick: () => console.log('option 1'), | ||
}, | ||
{ | ||
icon: <MassaLogo size={32} />, | ||
item: 'account 2 name with a biiiiig content', | ||
}, | ||
{ icon: <MassaLogo size={32} />, item: 'account 3 name' }, | ||
{ icon: <MassaLogo size={32} />, item: 'account 4 name' }, | ||
{ icon: <MassaLogo size={32} />, item: 'account 5 name' }, | ||
{ icon: <MassaLogo size={32} />, item: 'account 6 name' }, | ||
]} | ||
/>, | ||
); | ||
}); | ||
it('should render', () => { | ||
cy.get('[data-testid="dropdown"]').should('exist'); | ||
}); | ||
|
||
it('should match snapshot', () => { | ||
cy.mount( | ||
<Dropdown | ||
options={[ | ||
{ | ||
icon: ( | ||
<MassaToken size={32} className="bg-c-default rounded-full" /> | ||
), | ||
item: 'account 1 name', | ||
onClick: () => console.log('option 1'), | ||
}, | ||
{ | ||
icon: <MassaLogo size={32} />, | ||
item: 'account 2 name with a biiiiig content', | ||
}, | ||
{ icon: <MassaLogo size={32} />, item: 'account 3 name' }, | ||
{ icon: <MassaLogo size={32} />, item: 'account 4 name' }, | ||
{ icon: <MassaLogo size={32} />, item: 'account 5 name' }, | ||
{ icon: <MassaLogo size={32} />, item: 'account 6 name' }, | ||
]} | ||
/>, | ||
); | ||
|
||
compareSnapshot(cy, 'default-dropdown'); | ||
}); | ||
}); | ||
|
||
describe('default xs dropdown', () => { | ||
beforeEach(() => { | ||
cy.mount( | ||
<Dropdown | ||
size={'xs'} | ||
options={[ | ||
{ | ||
icon: ( | ||
<MassaToken size={32} className="bg-c-default rounded-full" /> | ||
), | ||
item: 'account 1 name', | ||
onClick: () => console.log('option 1'), | ||
}, | ||
{ | ||
icon: <MassaLogo size={32} />, | ||
item: 'account 2 name with a biiiiig content', | ||
}, | ||
{ icon: <MassaLogo size={32} />, item: 'account 3 name' }, | ||
{ icon: <MassaLogo size={32} />, item: 'account 4 name' }, | ||
{ icon: <MassaLogo size={32} />, item: 'account 5 name' }, | ||
{ icon: <MassaLogo size={32} />, item: 'account 6 name' }, | ||
]} | ||
/>, | ||
); | ||
}); | ||
it('should render', () => { | ||
cy.get('[data-testid="dropdown"]').should('exist'); | ||
}); | ||
|
||
it('should match snapshot', () => { | ||
compareSnapshot(cy, 'default-xs-dropdown'); | ||
}); | ||
}); | ||
|
||
describe('default md dropdown', () => { | ||
beforeEach(() => { | ||
cy.mount( | ||
<Dropdown | ||
size={'md'} | ||
options={[ | ||
{ | ||
icon: ( | ||
<MassaToken size={32} className="bg-c-default rounded-full" /> | ||
), | ||
item: 'account 1 name', | ||
onClick: () => console.log('option 1'), | ||
}, | ||
{ | ||
icon: <MassaLogo size={32} />, | ||
item: 'account 2 name with a biiiiig content', | ||
}, | ||
{ icon: <MassaLogo size={32} />, item: 'account 3 name' }, | ||
{ icon: <MassaLogo size={32} />, item: 'account 4 name' }, | ||
{ icon: <MassaLogo size={32} />, item: 'account 5 name' }, | ||
{ icon: <MassaLogo size={32} />, item: 'account 6 name' }, | ||
]} | ||
/>, | ||
); | ||
}); | ||
|
||
it('should render', () => { | ||
cy.get('[data-testid="dropdown"]').should('exist'); | ||
}); | ||
|
||
it('should match snapshot', () => { | ||
compareSnapshot(cy, 'default-md-dropdown'); | ||
}); | ||
}); | ||
|
||
describe('default dropdown flow', () => { | ||
beforeEach(() => { | ||
cy.mount( | ||
<Dropdown | ||
options={[ | ||
{ | ||
icon: ( | ||
<MassaToken | ||
data-testid="dropdown-option-1" | ||
size={32} | ||
className="bg-c-default rounded-full" | ||
/> | ||
), | ||
item: 'account 1 name', | ||
onClick: () => console.log('option 1'), | ||
}, | ||
{ | ||
icon: <MassaLogo data-testid="dropdown-option-2" size={32} />, | ||
item: 'account 2 name with a biiiiig content', | ||
}, | ||
{ | ||
icon: <MassaLogo data-testid="dropdown-option-3" size={32} />, | ||
item: 'account 3 name', | ||
}, | ||
{ | ||
icon: <MassaLogo data-testid="dropdown-option-4" size={32} />, | ||
item: 'account 4 name', | ||
}, | ||
{ | ||
icon: <MassaLogo data-testid="dropdown-option-5" size={32} />, | ||
item: 'account 5 name', | ||
}, | ||
{ | ||
icon: <MassaLogo data-testid="dropdown-option-6" size={32} />, | ||
item: 'account 6 name', | ||
}, | ||
]} | ||
/>, | ||
); | ||
}); | ||
|
||
it('should render', () => { | ||
cy.get('[data-testid="dropdown"]').should('exist'); | ||
}); | ||
|
||
// init state | ||
it('should open and close when clicked', () => { | ||
cy.get('[data-testid="dropdown"]').should('exist'); | ||
|
||
for (let i = 1; i <= 6; i++) { | ||
cy.get(`[data-testid="dropdown-option-${i}"]`).should('exist'); | ||
} | ||
|
||
cy.get('[data-testid="dropdown-option-1"]').should('be.visible'); | ||
for (let i = 2; i <= 6; i++) { | ||
cy.get(`[data-testid="dropdown-option-${i}"]`).should( | ||
'not.be.visible', | ||
); | ||
} | ||
|
||
// open | ||
cy.get('[data-testid="dropdown-button"]').should('exist').click(); | ||
|
||
for (let i = 1; i <= 6; i++) { | ||
cy.get(`[data-testid="dropdown-option-${i}"]`).should('be.visible'); | ||
} | ||
|
||
// close | ||
cy.get('[data-testid="dropdown-button"]').should('exist').click(); | ||
|
||
cy.get('[data-testid="dropdown-option-1"]').should('be.visible'); | ||
for (let i = 2; i <= 6; i++) { | ||
cy.get(`[data-testid="dropdown-option-${i}"]`).should( | ||
'not.be.visible', | ||
); | ||
} | ||
}); | ||
|
||
it('should match snapshot', () => { | ||
compareSnapshot(cy, 'default-dropdown'); | ||
}); | ||
}); | ||
}); | ||
}); |
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