Skip to content

Commit

Permalink
add more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams committed Jan 13, 2023
1 parent 7864ae2 commit 23f21ec
Show file tree
Hide file tree
Showing 21 changed files with 1,620 additions and 424 deletions.
31 changes: 30 additions & 1 deletion src/__fixtures__/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
MDXPage,
SingleMDXPage,
SingleMDXDocPage,
SiteMetaData
} from '../types';

Expand Down Expand Up @@ -52,4 +53,32 @@ export const createSingleMDXData = (): {
}
}
}
});
});

export const createMDXDocsData = (toc): {
mdx: SingleMDXDocPage;
} => ({
mdx: {
id: 'mdx-1',
fields: {
slug: '/mdx/mdx-page-title',
},
frontmatter: {
title: 'MDX Doc Page title',
authors: 'pmc, pmc2',
toc: toc ? true : false
},
tableOfContents: {
items: [
{
url: '#section1',
title: 'Section 1'
},
{
url: '#section2',
title: 'Section 2'
}
],
}
}
});
7 changes: 1 addition & 6 deletions src/components/LanguageSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ const LanguageSelector = (): JSX.Element => {
eventKey={lng}
onClick={(e) => {
e.preventDefault();
if (location.pathname.includes('index')) {
let newPath = location.pathname.split("/index")[0].slice(3)
changeLanguage(lng, newPath);
} else {
changeLanguage(lng);
}
changeLanguage(lng);
}}
>
<Flag code={ISO3166(lng)} width='35' />
Expand Down
28 changes: 28 additions & 0 deletions src/components/NavBar/__tests__/NavBar.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import { render } from '@testing-library/react';
import { describe, it, expect } from "vitest"
import NavBar from '..';

describe('NavBar component', () => {
it('navbar renders correctly', () => {
const { container } = render(
<NavBar/>
);
expect(container).toMatchSnapshot();
});

it('blog navbar renders correctly', () => {
global.window = Object.create(window);
const url = 'https://adoptium.net/blog';
Object.defineProperty(window, 'location', {
value: {
href: url
}
});

const { container } = render(
<NavBar/>
);
expect(container).toMatchSnapshot();
});
});
14 changes: 0 additions & 14 deletions src/components/NavBar/__tests__/NavBar.tests.tsx

This file was deleted.

Loading

0 comments on commit 23f21ec

Please sign in to comment.