Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Jul 13, 2020
1 parent 30a27c1 commit 371f3df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Endpoint/Endpoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class Endpoint extends React.Component<EndpointProps, EndpointState> {
style={{ marginRight: '-25px' }}
/>
</EndpointInfo>
<ServersOverlay expanded={expanded}>
<ServersOverlay expanded={expanded} aria-hidden={!expanded}>
{operation.servers.map(server => {
const normalizedUrl = options.expandDefaultServerVariables
? expandDefaultServerVariables(server.url, server.variables)
Expand Down
3 changes: 2 additions & 1 deletion src/components/Endpoint/styled.elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export const ServersOverlay = styled.div<{ expanded: boolean }>`
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
transition: all 0.25s ease;
${props => (props.expanded ? '' : 'transform: translateY(-50%) scaleY(0);')}
visibility: hidden;
${props => (props.expanded ? 'visibility: visible;' : 'transform: translateY(-50%) scaleY(0);')}
`;

export const ServerItem = styled.div`
Expand Down
6 changes: 3 additions & 3 deletions src/components/__tests__/JsonViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ describe('Components', () => {

test('should collapse/uncollapse', () => {
expect(component.html()).not.toContain('class="hoverable"'); // all are collapsed by default
const expandAll = component.find('div > span[children=" Expand all "]');
const expandAll = component.find('div > button[children=" Expand all "]');
expandAll.simulate('click');
expect(component.html()).toContain('class="hoverable"'); // all are collapsed

const collapseAll = component.find('div > span[children=" Collapse all "]');
const collapseAll = component.find('div > button[children=" Collapse all "]');
collapseAll.simulate('click');
expect(component.html()).not.toContain('class="hoverable"'); // all are collapsed
});

test('should collapse/uncollapse', () => {
ClipboardService.copySelected = jest.fn();

const copy = component.find('span[onClick]').first();
const copy = component.find('button[onClick]').first();
copy.simulate('click');

expect(ClipboardService.copySelected as jest.Mock).toHaveBeenCalled();
Expand Down

0 comments on commit 371f3df

Please sign in to comment.