Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
gromdimon committed Aug 25, 2023
1 parent 50e411c commit 22d1e85
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 21 deletions.
13 changes: 12 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 39 additions & 20 deletions frontend/tests/components/HeaderDetailPage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,62 @@
import { beforeEach, describe, it, expect, vi } from 'vitest'
import { useRouter } from 'vue-router'
import { describe, expect, it, vi } from 'vitest'
import { createTestingPinia } from '@pinia/testing'
import { mount } from '@vue/test-utils'
import { RouterLinkStub, mount } from '@vue/test-utils'

Check warning on line 3 in frontend/tests/components/HeaderDetailPage.spec.ts

View workflow job for this annotation

GitHub Actions / Frontend-Lint

'RouterLinkStub' is defined but never used
import HeaderDetailPage from '@/components/HeaderDetailPage.vue'
import { useGeneInfoStore } from '@/stores/geneInfo'

Check warning on line 5 in frontend/tests/components/HeaderDetailPage.spec.ts

View workflow job for this annotation

GitHub Actions / Frontend-Lint

'useGeneInfoStore' is defined but never used
import { before, beforeEach } from 'node:test'

Check warning on line 6 in frontend/tests/components/HeaderDetailPage.spec.ts

View workflow job for this annotation

GitHub Actions / Frontend-Lint

'before' is defined but never used

const makeWrapper = () => {
let router;

const makeWrapper = (geneData = {}) => {
return mount(HeaderDetailPage, {
shallow: true,
global: {
plugins: [
createTestingPinia({
initialState: { searchTerm: '', genomeRelease: 'grch37' },
createSpy: vi.fn,
})
]
initialState: { data: geneData },
createSpy: vi.fn(),
}),
router,
],
},
});
})
}

describe('HeaderDetailPage.vue', () => {
describe('HeaderDetailPage', async () => {
const geneData = {
geneSymbol: 'BRCA1',
geneInfo: {
symbol: 'BRCA1',
name: 'Test Gene',
hgncId: '12345',
ensemblId: 'ENSG00000000000001',
entrezId: '12345',
},
}

beforeEach(() => {
vi.resetAllMocks();
router = createRouter({
history: createWebHistory(),
routes: routes,
})

router.push = vi.fn()
await router.isReady()
})

it('renders the logo and title', () => {
const wrapper = makeWrapper();
expect(wrapper.exists()).toBeTruthy();
it('renders the gene symbol', () => {
const wrapper = makeWrapper(geneData)

const logo = wrapper.find('#logo')
const title = wrapper.find('router-link')
expect(logo.exists()).toBe(true)
expect(title.text()).toMatch('Explanation and Evaluation of Variants')
})

it('renders the navigation links', () => {
const wrapper = makeWrapper();
const aboutLink = wrapper.find('v-btn[to="/about"]')
const contactLink = wrapper.find('v-btn[to="/contact"]')
expect(aboutLink.exists()).toBe(true)
expect(contactLink.exists()).toBe(true)
})

it('redirects if gene data is null', () => {
const wrapper = makeWrapper()

Check warning on line 59 in frontend/tests/components/HeaderDetailPage.spec.ts

View workflow job for this annotation

GitHub Actions / Frontend-Lint

'wrapper' is assigned a value but never used
expect(router.push).toHaveBeenCalledWith('/')
})
})

0 comments on commit 22d1e85

Please sign in to comment.