Skip to content

Commit

Permalink
Convert test files to TS (#78)
Browse files Browse the repository at this point in the history
* Install Jest TS Requirements

* index.test.ts working

* Convert all tests to typescript

* Implemented legrandgrand changes

* Install Jest TS Requirements

* index.test.ts working

* Convert all tests to typescript

* Implemented legrandgrand changes

* Update package.json with main
  • Loading branch information
EwanLyon authored Oct 21, 2021
1 parent ca03ea4 commit c265491
Show file tree
Hide file tree
Showing 34 changed files with 27,693 additions and 187 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"node": "current"
}
}
]
],
"@babel/preset-typescript"
]
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stubbedRender } from '@/testUtils';
import ProfileHeader from './ProfileHeader';
import ProfileHeader from './ProfileHeader.vue';

describe('<ProfileHeader />', () => {
it('should render without crashing', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stubbedRender } from '@/testUtils';
import UserActivity from './UserActivity';
import UserActivity from './UserActivity.vue';

describe('<UserActivity />', () => {
it('should render without crashing', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stubbedRender } from '@/testUtils';
import SiteFooter from './SiteFooter';
import SiteFooter from './SiteFooter.vue';

describe('<SiteFooter />', () => {
it('should render without crashing', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stubbedRender } from '@/testUtils';
import SiteNavbar from './SiteNavbar';
import SiteNavbar from './SiteNavbar.vue';

/* Need to mock the `window.matchMedia` method here, because it has not
* yet been implemented by JSDOM. Hopefully this will be fixed soon.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stubbedRender } from '@/testUtils';
import ButtonLink from './ButtonLink';
import ButtonLink from './ButtonLink.vue';

describe('<ButtonLink />', () => {
const defaultAttrs = { class: 'custom-link' };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fireEvent, stubbedRender } from '@/testUtils';
import FollowButton from './FollowButton';
import FollowButton from './FollowButton.vue';

describe('<FollowButton />', () => {
/*
Expand Down Expand Up @@ -32,7 +32,7 @@ describe('<FollowButton />', () => {
it('should call the default onSubmit methd', async () => {
const { container } = stubbedRender(FollowButton);

await fireEvent.click(container.firstChild);
fireEvent.click(<HTMLElement>container.firstChild);

expect(spyConsoleLog).toHaveBeenCalled();
});
Expand All @@ -43,7 +43,7 @@ describe('<FollowButton />', () => {
props: defaultProps,
});

await fireEvent.click(container.firstChild);
fireEvent.click(<HTMLElement>container.firstChild);

expect(mockOnClick).toHaveBeenCalled();
});
Expand All @@ -53,7 +53,7 @@ describe('<FollowButton />', () => {
props: defaultProps,
});

await fireEvent.type(container.firstChild, '{enter}');
fireEvent.type(<HTMLElement>container.firstChild, '{enter}');

expect(mockOnClick).toHaveBeenCalled();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stubbedRender } from '@/testUtils';
import LoginButton from './LoginButton';
import LoginButton from './LoginButton.vue';

describe('<LoginButton />', () => {
it('should render without crashing', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stubbedRender } from '@/testUtils';
import NavLink from './NavLink';
import NavLink from './NavLink.vue';

describe('<NavLink />', () => {
const defaultAttrs = { class: 'custom-link' };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stubbedRender } from '@/testUtils';
import NavLinks from './NavLinks';
import NavLinks from './NavLinks.vue';

describe('<NavLinks />', () => {
const defaultProps = {
Expand Down Expand Up @@ -31,7 +31,7 @@ describe('<NavLinks />', () => {
props: defaultProps,
});

expect(container.firstChild.childNodes.length).toEqual(
expect(container.firstChild?.childNodes.length).toEqual(
defaultProps.navLinks.length,
);
defaultProps.navLinks.forEach((navLink) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fireEvent, stubbedRender } from '@/testUtils';
import SearchBar from './SearchBar';
import SearchBar from './SearchBar.vue';

describe('<SearchBar />', () => {
const mockOnSubmit = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stubbedRender } from '@/testUtils';
import SignUpButton from './SignUpButton';
import SignUpButton from './SignUpButton.vue';

describe('<SignUpButton />', () => {
it('should render without crashing', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stubbedRender } from '@/testUtils';
import SocialButtons from './SocialButtons';
import SocialButtons from './SocialButtons.vue';

describe('<SocialButtons />', () => {
const defaultProps = {
Expand Down Expand Up @@ -43,7 +43,7 @@ describe('<SocialButtons />', () => {
props: defaultProps,
});

expect(container.firstChild.childNodes.length).toEqual(
expect(container.firstChild?.childNodes.length).toEqual(
defaultProps.socials.length,
);
defaultProps.socials.forEach((social) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stubbedRender } from '@/testUtils';
import UserBadges from './UserBadges';
import UserBadges from './UserBadges.vue';

describe('<ProfileHeader />', () => {
it('should render without crashing', () => {
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
'^vue$': 'vue/dist/vue.common.js',
'^~/(.*)$': '<rootDir>/$1',
},
preset: 'ts-jest',
setupFilesAfterEnv: ['./jest.setup.js'],
snapshotSerializers: ['jest-serializer-vue'],
testEnvironment: 'jsdom',
Expand Down
Loading

0 comments on commit c265491

Please sign in to comment.