Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mv __tests__/*.test.tsx to src/ #448

Merged
merged 3 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ overrides:
node: true
- files:
- '__mocks__/*'
- '__tests__/*'
- '*.test.ts{,x}'
plugins:
- '@typescript-eslint'
- react
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

## Others

- [#448](https://github.com/epaew/react-liff/pull/448)
- mv `__tests__/*.test.tsx` to `src/`.

# 1.5.1

## Features
Expand Down
16 changes: 0 additions & 16 deletions __tests__/tsconfig.json

This file was deleted.

11 changes: 5 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module.exports = {
collectCoverageFrom: ['<rootDir>/src/**/*.ts{,x}'],
collectCoverageFrom: [
'<rootDir>/src/**/*.ts{,x}',
'!<rootDir>/src/**/*.test.ts{,x}',
],
globals: {
'ts-jest': {
tsconfig: '__tests__/tsconfig.json',
tsconfig: 'tsconfig.test.json',
},
},
moduleNameMapper: {
'^#/(.+)': '<rootDir>/src/$1',
},
preset: 'ts-jest',
testEnvironment: 'jsdom',
testMatch: ['<rootDir>/__tests__/**/*.test.ts{,x}'],
};
2 changes: 1 addition & 1 deletion src/Context.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as PropTypes from 'prop-types';
import { Consumer, Context, createContext, FC, ReactNode, useContext, useEffect, useState } from 'react';

import { useLoginStateManager } from './hooks';
import { liffStub as stub } from './liff-stub';
import { Liff, LiffConfig, Loginable } from './types';
import { useLoginStateManager } from './use-login-state-manager';

interface InitLiffProps<T> extends LiffConfig {
stubEnabled?: boolean | Partial<T>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { default as liffMock } from '@line/liff';
import { fireEvent, render, waitFor } from '@testing-library/react';
import { FC } from 'react';

import { useLoginStateManager } from '#/use-login-state-manager';
import { useLoginStateManager } from './use-login-state-manager';

jest.mock('@line/liff');

Expand Down
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { useLoginStateManager } from './use-login-state-manager';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';

import { Loginable } from './types';
import { Loginable } from '../types';

export const useLoginStateManager = <T extends Loginable>(liff?: T): [boolean, T] => {
const { isLoggedIn = () => false, login = () => {}, logout = () => {}, ...rest } = liff ?? {};
Expand Down
5 changes: 3 additions & 2 deletions __tests__/index.test.tsx → src/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { default as liff } from '@line/liff';
import { render, waitFor } from '@testing-library/react';
import { FC } from 'react';

import { LiffProvider, useLiff } from '#/index';
import { Liff } from '#/types';
import { Liff } from './types';

import { LiffProvider, useLiff } from '.';

jest.mock('@line/liff');

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": [
"src"
"src/index.ts"
]
}
10 changes: 10 additions & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"jsx": "react-jsxdev",
"noEmit": true
},
"include": [
"src/**/*.test.*"
]
}