-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
68 additions
and
4 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,62 @@ | ||
|
||
import { vi, beforeEach, expect, test, afterAll } from 'vitest' | ||
import { enableAutoUnmount, mount } from '@vue/test-utils' | ||
import App from '../../src/App.vue' | ||
import Main from '../../src/screens/Main.vue' | ||
import Wait from '../../src/screens/Wait.vue' | ||
import Commands from '../../src/screens/Commands.vue' | ||
import PromptAnywhere from '../../src/screens/PromptAnywhere.vue' | ||
import defaults from '../../defaults/settings.json' | ||
|
||
enableAutoUnmount(afterAll) | ||
|
||
window.api = { | ||
config: { | ||
load: vi.fn(() => defaults), | ||
}, | ||
commands: { | ||
load: vi.fn(() => []), | ||
}, | ||
prompts: { | ||
load: vi.fn(() => []), | ||
}, | ||
history: { | ||
load: vi.fn(() => []), | ||
}, | ||
on: vi.fn(), | ||
} | ||
|
||
test('Renders correctly', () => { | ||
window.location = new URL('http://localhost/') | ||
mount(App) | ||
}) | ||
|
||
test('Renders Main', () => { | ||
window.location = new URL('http://localhost/') | ||
const wrapper = mount(App) | ||
expect(wrapper.findComponent(Main).exists()).toBe(true) | ||
}) | ||
|
||
test('Renders Wait', () => { | ||
window.location = new URL('http://localhost/#/wait') | ||
const wrapper = mount(App) | ||
expect(wrapper.findComponent(Wait).exists()).toBe(true) | ||
}) | ||
|
||
test('Renders Commands', () => { | ||
window.location = new URL('http://localhost/#/command') | ||
const wrapper = mount(App) | ||
expect(wrapper.findComponent(Commands).exists()).toBe(true) | ||
}) | ||
|
||
test('Renders PromptAnywhere', () => { | ||
window.location = new URL('http://localhost/#/prompt') | ||
const wrapper = mount(App) | ||
expect(wrapper.findComponent(PromptAnywhere).exists()).toBe(true) | ||
}) | ||
|
||
test('Transmits query params', () => { | ||
window.location = new URL('http://localhost/?textId=6#/command') | ||
const wrapper = mount(App) | ||
expect(wrapper.findComponent(Commands).props().extra.textId).toBe('6') | ||
}) |