Initial commit, project structure and domain models
This commit is contained in:
1
src/admin/tests/__mocks__/fileMock.js
Normal file
1
src/admin/tests/__mocks__/fileMock.js
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = 'test-file-stub';
|
||||
1
src/admin/tests/__mocks__/styleMock.js
Normal file
1
src/admin/tests/__mocks__/styleMock.js
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = {};
|
||||
21
src/admin/tests/setup.ts
Normal file
21
src/admin/tests/setup.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { config } from '@vue/test-utils';
|
||||
import { createVuetify } from 'vuetify';
|
||||
import * as components from 'vuetify/components';
|
||||
import * as directives from 'vuetify/directives';
|
||||
|
||||
// Stub ResizeObserver which jsdom doesn't implement
|
||||
global.ResizeObserver = class ResizeObserver {
|
||||
observe() {}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
};
|
||||
|
||||
// Stub CSS.supports
|
||||
Object.defineProperty(window, 'CSS', {
|
||||
value: { supports: () => false },
|
||||
writable: true,
|
||||
});
|
||||
|
||||
const vuetify = createVuetify({ components, directives });
|
||||
|
||||
config.global.plugins = [vuetify];
|
||||
68
src/admin/tests/unit/AppHeader.spec.ts
Normal file
68
src/admin/tests/unit/AppHeader.spec.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { describe, it, expect, beforeEach } from '@jest/globals';
|
||||
import { mount, VueWrapper } from '@vue/test-utils';
|
||||
import { createRouter, createMemoryHistory } from 'vue-router';
|
||||
import AppHeader from '@/components/AppHeader.vue';
|
||||
|
||||
function makeRouter() {
|
||||
return createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [
|
||||
{ path: '/', component: { template: '<div />' } },
|
||||
{ path: '/features', component: { template: '<div />' } },
|
||||
{ path: '/environments', component: { template: '<div />' } },
|
||||
{ path: '/projects', component: { template: '<div />' } },
|
||||
{ path: '/profile', component: { template: '<div />' } },
|
||||
{ path: '/settings', component: { template: '<div />' } },
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
describe('AppHeader', () => {
|
||||
let wrapper: VueWrapper;
|
||||
|
||||
beforeEach(async () => {
|
||||
const router = makeRouter();
|
||||
await router.push('/');
|
||||
|
||||
// v-app-bar requires a v-app layout context — wrap the component under test
|
||||
wrapper = mount(
|
||||
{ template: '<v-app><AppHeader /></v-app>', components: { AppHeader } },
|
||||
{ global: { plugins: [router] } },
|
||||
);
|
||||
});
|
||||
|
||||
it('renders the Features navigation link', () => {
|
||||
const link = wrapper.find('[data-testid="nav-link-features"]');
|
||||
expect(link.exists()).toBe(true);
|
||||
expect(link.text()).toBe('Features');
|
||||
});
|
||||
|
||||
it('renders the Environments navigation link', () => {
|
||||
const link = wrapper.find('[data-testid="nav-link-environments"]');
|
||||
expect(link.exists()).toBe(true);
|
||||
expect(link.text()).toBe('Environments');
|
||||
});
|
||||
|
||||
it('renders the Projects navigation link', () => {
|
||||
const link = wrapper.find('[data-testid="nav-link-projects"]');
|
||||
expect(link.exists()).toBe(true);
|
||||
expect(link.text()).toBe('Projects');
|
||||
});
|
||||
|
||||
it('renders the SVG microphone logo image', () => {
|
||||
const logo = wrapper.find('[data-testid="app-logo"]');
|
||||
expect(logo.exists()).toBe(true);
|
||||
expect(logo.attributes('alt')).toBe('MicCheck logo');
|
||||
});
|
||||
|
||||
it('renders the profile link with John Doe text', () => {
|
||||
const link = wrapper.find('[data-testid="profile-link"]');
|
||||
expect(link.exists()).toBe(true);
|
||||
expect(link.text()).toContain('John Doe');
|
||||
});
|
||||
|
||||
it('renders the settings gear icon link', () => {
|
||||
const link = wrapper.find('[data-testid="settings-link"]');
|
||||
expect(link.exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user