-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev: added tests for AircraftModelFilter component
- Loading branch information
1 parent
1919510
commit 75f1ec3
Showing
3 changed files
with
91 additions
and
15 deletions.
There are no files selected for viewing
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
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,58 @@ | ||
import { describe, it, expect } from 'vitest' | ||
import { mount } from '@vue/test-utils' | ||
import AircraftModelFilter from '../AircraftModelFilter.vue' | ||
|
||
const models = { | ||
AlexanderSchleicher: { | ||
models: { | ||
glider: ['ASW 15', 'ASW 17', 'ASW 19', 'ASW 20'], | ||
tmg: ['ASK 14', 'ASK 16'] | ||
} | ||
}, | ||
Antonov: { | ||
models: { | ||
airplane: ['An-2', 'An-225 Mriya'] | ||
} | ||
} | ||
} | ||
|
||
const mockRouter = { | ||
push: function () {} | ||
} | ||
const mockRoute = { | ||
path: '/' | ||
} | ||
|
||
function mocksWithPath(path) { | ||
mockRoute.path = path | ||
return { | ||
mocks: { | ||
$route: mockRoute, | ||
$router: mockRouter | ||
} | ||
} | ||
} | ||
|
||
describe('AircraftModelFilter', () => { | ||
it('should list all categories for homepage', () => { | ||
const wrapper = mount(AircraftModelFilter, { | ||
props: { models: models }, | ||
global: mocksWithPath('/') | ||
}) | ||
|
||
expect(wrapper.text()) | ||
.toContain('AlexanderSchleicher', 'ASW 15', 'ASK 16') // both glider and tmg | ||
.toContain('Antonov', 'An-2', 'An-225 Mriya') // airplanes | ||
}) | ||
|
||
it('should list only gliders on /glider', () => { | ||
const wrapper = mount(AircraftModelFilter, { | ||
props: { models: models }, | ||
global: mocksWithPath('/glider') | ||
}) | ||
|
||
expect(wrapper.text()) | ||
.toContain('AlexanderSchleicher', 'ASW 15') | ||
.not.toContain('ASK 16', 'Antonov', 'An-2', 'An-225 Mriya') | ||
}) | ||
}) |
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