Skip to content

Commit

Permalink
test options
Browse files Browse the repository at this point in the history
  • Loading branch information
jwkaterina committed Apr 17, 2024
1 parent 72cc23c commit 3752449
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/app/analysis/components/serach/food-list.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe('food-list', () => {
}

const { container } = render(<FoodList {...props} />);
screen.logTestingPlaygroundURL();

it('should render food list in caloreis ascending order', () => {
const cards = container.querySelectorAll('.card');
Expand Down
37 changes: 37 additions & 0 deletions src/app/analysis/components/serach/options.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { render, screen, within } from '@testing-library/react';
import '@testing-library/jest-dom';
import Options from './options';

describe('options', () => {

it('should render default options', () => {
const props = {
queryOptions: null,
onclick: jest.fn()
}

render(<Options {...props} />);

const lis = screen.getAllByRole('listitem');
expect(lis).toHaveLength(3);
expect(lis[0]).toHaveTextContent(/apple/i);
expect(lis[1]).toHaveTextContent(/rice/i);
expect(lis[2]).toHaveTextContent(/broccoli/i);
});

it('should render given options', () => {
const props = {
queryOptions: ['wine', 'banana', 'chocolate'],
onclick: jest.fn()
}

render(<Options {...props} />);

const lis = screen.getAllByRole('listitem');
expect(lis).toHaveLength(3);
expect(lis[0]).toHaveTextContent(/wine/i);
expect(lis[1]).toHaveTextContent(/banana/i);
expect(lis[2]).toHaveTextContent(/chocolate/i);
});

});

0 comments on commit 3752449

Please sign in to comment.