-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from alkrauss48/issue-23/feat/looping
Implements front-end looping via query param
- Loading branch information
Showing
7 changed files
with
145 additions
and
7 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
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
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,53 @@ | ||
import { mount, VueWrapper } from '@vue/test-utils' | ||
|
||
import SlideView from '@/Components/SlideView.vue' | ||
import Keys from '@/constants/keys.ts'; | ||
import ProgressType from '@/enums/progressType.ts' | ||
import dataStore from '@/store/dataStore.ts' | ||
import slideStore from '@/store/slideStore.ts' | ||
|
||
// Incrementors | ||
|
||
const mountWrapper = () : VueWrapper<any> => { | ||
dataStore.data = ['foo', 'bar', 'baz', 'foo', 'bar', 'baz', 'foo', 'bar']; | ||
slideStore.index = 1; | ||
slideStore.loop = 5; | ||
slideStore.progress = ProgressType.Bar; | ||
|
||
return mount(SlideView); | ||
}; | ||
|
||
test('loopInterval is not null with valid loop set', async () => { | ||
const wrapper = mountWrapper(); | ||
|
||
expect(wrapper.vm.loopInterval).not.toBe(null); | ||
}); | ||
|
||
test('loopInterval is cleared with valid loop set', async () => { | ||
const wrapper = mountWrapper(); | ||
const spy = vi.spyOn(global, 'clearInterval'); | ||
|
||
wrapper.vm.checkAndClearLoopInterval(); | ||
|
||
expect(spy).toHaveBeenCalledTimes(1); | ||
expect(spy.mock.lastCall?.[0]).toBe(Number(wrapper.vm.loopInterval)); | ||
}); | ||
|
||
test('loopInterval is cleared on valid key press', async () => { | ||
const wrapper = mountWrapper(); | ||
const spy = vi.spyOn(global, 'clearInterval'); | ||
|
||
wrapper.vm.bindKeyDown({ key: Keys.ENTER }); | ||
|
||
expect(spy).toHaveBeenCalledTimes(1); | ||
expect(spy.mock.lastCall?.[0]).toBe(Number(wrapper.vm.loopInterval)); | ||
}); | ||
|
||
test('loopInterval is not cleared on invalid key press', async () => { | ||
const wrapper = mountWrapper(); | ||
const spy = vi.spyOn(global, 'clearInterval'); | ||
|
||
wrapper.vm.bindKeyDown({ key: 'x' }); | ||
|
||
expect(spy).toHaveBeenCalledTimes(0); | ||
}); |
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