Skip to content

Commit

Permalink
Merge pull request #39 from kloudsoft91/unit-test-fix
Browse files Browse the repository at this point in the history
fixed selected tag tests
  • Loading branch information
AdamN2424 authored Sep 25, 2023
2 parents 5206995 + 3948036 commit 9028f47
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Index', () => {
{ id: 3, common_names: 'Mushroom 3', tags: ['edible'] },
];

wrapper.vm.selectedTags = ['edible'];
wrapper.vm.selectedTag = 'edible';

const filteredMushrooms = wrapper.vm.filterByTags(mockMushrooms);

Expand All @@ -27,29 +27,15 @@ describe('Index', () => {
expect(filteredMushrooms[1].common_names).toBe('Mushroom 3');
})

it('should filter based on multiple selected tags', () => {
const mockMushrooms = [
{ id: 1, common_names: 'Mushroom 1', tags: ['edible', 'gourmet'] },
{ id: 2, common_names: 'Mushroom 2', tags: ['poisonous'] },
{ id: 3, common_names: 'Mushroom 3', tags: ['edible'] },
];

wrapper.vm.selectedTags = ['edible', 'gourmet'];

const filteredMushrooms = wrapper.vm.filterByTags(mockMushrooms);

expect(filteredMushrooms).toHaveLength(1);
expect(filteredMushrooms[0].common_names).toBe('Mushroom 1');
})

it('should display all mushrooms when no tags are selected', () => {

it('should display all mushrooms when no tag is selected', () => {
const mockMushrooms = [
{ id: 1, common_names: 'Mushroom 1', tags: ['edible'] },
{ id: 2, common_names: 'Mushroom 2', tags: ['poisonous'] },
{ id: 3, common_names: 'Mushroom 3', tags: ['edible'] },
];

wrapper.vm.selectedTags = [];
wrapper.vm.selectedTag = '';

const filteredMushrooms = wrapper.vm.filterByTags(mockMushrooms);

Expand Down

0 comments on commit 9028f47

Please sign in to comment.