Skip to content

Commit

Permalink
Convert tests to Typescript (#182)
Browse files Browse the repository at this point in the history
* Convert tests to Typescript

* Convert test utils to Typescript
  • Loading branch information
rkuykendall authored Jun 29, 2019
1 parent f6cca0e commit 14fbac6
Show file tree
Hide file tree
Showing 26 changed files with 46 additions and 9 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@typescript-eslint/interface-name-prefix": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-unused-vars": 0,
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["setupTests.ts", "**/*spec.tsx"]}],
"import/no-unresolved": 0,
"prettier/prettier": ["error", { "singleQuote": true }],
"react/destructuring-assignment": 0,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions __tests__/Element-spec.js → __tests__/Element-spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import sinon from 'sinon';
import { mount } from 'enzyme';

import Formsy, { withFormsy } from './..';
import Formsy, { withFormsy } from '..';
import immediate from '../__test_utils__/immediate';
import TestInput, { InputFactory } from '../__test_utils__/TestInput';

Expand Down Expand Up @@ -49,7 +49,7 @@ describe('Element', () => {
it('should set back to pristine value when running reset', () => {
let reset = null;
const Input = InputFactory({
componentDidMount: function() {
componentDidMount() {
reset = this.props.resetValue;
},
});
Expand All @@ -68,7 +68,7 @@ describe('Element', () => {
it('should return error message passed when calling getErrorMessage()', () => {
let errorMessage = null;
const Input = InputFactory({
componentDidMount: function() {
componentDidMount() {
errorMessage = this.props.errorMessage;
},
});
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('Element', () => {
it('should return true or false when calling isRequired() depending on passed required attribute', () => {
const isRequireds = [];
const Input = InputFactory({
componentDidMount: function() {
componentDidMount() {
isRequireds.push(this.props.isRequired);
},
});
Expand All @@ -123,7 +123,7 @@ describe('Element', () => {
it('should return true or false when calling showRequired() depending on input being empty and required is passed, or not', () => {
const showRequireds = [];
const Input = InputFactory({
componentDidMount: function() {
componentDidMount() {
showRequireds.push(this.props.showRequired);
},
});
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { mount } from 'enzyme';

import Formsy from './..';
import Formsy from '..';
import { InputFactory } from '../__test_utils__/TestInput';

const TestInput = InputFactory({
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('Validation', () => {
it('should be able to use provided validate function', () => {
let isValid = false;
const CustomInput = InputFactory({
componentDidMount: function() {
componentDidMount() {
isValid = this.props.isValid;
},
});
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest"
},
"setupFilesAfterEnv": [
"./setupTests.js"
"./setupTests.ts"
]
},
"license": "MIT",
Expand All @@ -50,7 +50,7 @@
"build:types": "tsc --emitDeclarationOnly",
"changelog": "auto-changelog",
"deploy": "np",
"format": "prettier --write \"**/*.{js,ts}\"",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx}\"",
"lint": "eslint src/**/*",
"preversion": "npm run lint",
"test": "jest",
Expand All @@ -68,6 +68,9 @@
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@types/enzyme": "^3.9.4",
"@types/jasmine": "^3.3.13",
"@types/jest": "^24.0.15",
"@types/prop-types": "^15.7.1",
"@types/react": "^16.8.22",
"@types/react-dom": "^16.8.4",
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
"jsx": "react",
"lib": ["dom", "es5", "es6", "es7", "es2017.object"],
"outDir": "dist",
"sourceMap": true
Expand Down
32 changes: 32 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,21 @@
dependencies:
"@babel/types" "^7.3.0"

"@types/cheerio@*":
version "0.22.11"
resolved "https://registry.yarnpkg.com/@types/cheerio/-/cheerio-0.22.11.tgz#61c0facf9636d14ba5f77fc65ed8913aa845d717"
integrity sha512-x0X3kPbholdJZng9wDMhb2swvUi3UYRNAuWAmIPIWlfgAJZp//cql/qblE7181Mg7SjWVwq6ldCPCLn5AY/e7w==
dependencies:
"@types/node" "*"

"@types/enzyme@^3.9.4":
version "3.9.4"
resolved "https://registry.yarnpkg.com/@types/enzyme/-/enzyme-3.9.4.tgz#08f3ebfa24aa881021693a0fe615d6d2720c07ad"
integrity sha512-bQcwt5gcKnekrbci4hcapfE2J6rkkFbHM1l4VobLtSl4ogOfj0lvSxrdS6FftCakmJqqPBqdQCwb5KnlivL6SQ==
dependencies:
"@types/cheerio" "*"
"@types/react" "*"

"@types/eslint-visitor-keys@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
Expand Down Expand Up @@ -1047,6 +1062,23 @@
"@types/istanbul-lib-coverage" "*"
"@types/istanbul-lib-report" "*"

"@types/jasmine@^3.3.13":
version "3.3.13"
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-3.3.13.tgz#d5daabb0af47bcddee40597acf6e804433bab439"
integrity sha512-iczmLoIiVymaD1TIr2UctxjFkNEslVE/QtNAUmpDsD71cZfZBAsPCUv1Y+8AwsfA8bLx2ccr7d95T9w/UAirlQ==

"@types/jest-diff@*":
version "20.0.1"
resolved "https://registry.yarnpkg.com/@types/jest-diff/-/jest-diff-20.0.1.tgz#35cc15b9c4f30a18ef21852e255fdb02f6d59b89"
integrity sha512-yALhelO3i0hqZwhjtcr6dYyaLoCHbAMshwtj6cGxTvHZAKXHsYGdff6E8EPw3xLKY0ELUTQ69Q1rQiJENnccMA==

"@types/jest@^24.0.15":
version "24.0.15"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.0.15.tgz#6c42d5af7fe3b44ffff7cc65de7bf741e8fa427f"
integrity sha512-MU1HIvWUme74stAoc3mgAi+aMlgKOudgEvQDIm1v4RkrDudBh1T+NFp5sftpBAdXdx1J0PbdpJ+M2EsSOi1djA==
dependencies:
"@types/jest-diff" "*"

"@types/minimatch@*":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
Expand Down

0 comments on commit 14fbac6

Please sign in to comment.