Skip to content

Commit

Permalink
fix tab add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
acao committed Mar 22, 2022
1 parent 929d526 commit 0e2683b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"lint-staged": {
"*.{js,ts,jsx,tsx}": [
"eslint --fix",
"prettier --write"
"prettier --write",
"jest"
],
"*.{md,html,json,css}": [
"prettier --write"
Expand Down
10 changes: 5 additions & 5 deletions packages/graphiql/src/components/__tests__/GraphiQL.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -576,22 +576,22 @@ describe('GraphiQL', () => {
it('open multiple tabs', () => {
const { container } = render(<GraphiQL fetcher={noOpFetcher} tabs />);
expect(container.querySelectorAll('.tabs .tab')).toHaveLength(1);
fireEvent.click(container.querySelector('.toolbar-button.tab-add'));
fireEvent.click(container.querySelector('.tab-add'));
expect(container.querySelectorAll('.tabs .tab')).toHaveLength(2);
fireEvent.click(container.querySelector('.toolbar-button.tab-add'));
fireEvent.click(container.querySelector('.tab-add'));
expect(container.querySelectorAll('.tabs .tab')).toHaveLength(3);
});
it('each tab has a close button when multiple tabs are open', () => {
const { container } = render(<GraphiQL fetcher={noOpFetcher} tabs />);
expect(container.querySelectorAll('.tab .close')).toHaveLength(0);
fireEvent.click(container.querySelector('.toolbar-button.tab-add'));
fireEvent.click(container.querySelector('.tab-add'));
expect(container.querySelectorAll('.tab .close')).toHaveLength(2);
fireEvent.click(container.querySelector('.toolbar-button.tab-add'));
fireEvent.click(container.querySelector('.tab-add'));
expect(container.querySelectorAll('.tab .close')).toHaveLength(3);
});
it('close button removes a tab', () => {
const { container } = render(<GraphiQL fetcher={noOpFetcher} tabs />);
fireEvent.click(container.querySelector('.toolbar-button.tab-add'));
fireEvent.click(container.querySelector('.tab-add'));
expect(container.querySelectorAll('.tab .close')).toHaveLength(2);
fireEvent.click(container.querySelector('.tab .close'));
expect(container.querySelectorAll('.tabs .tab')).toHaveLength(1);
Expand Down

0 comments on commit 0e2683b

Please sign in to comment.