Skip to content

Commit

Permalink
Test/nullable (#74)
Browse files Browse the repository at this point in the history
* test: test코드 수정 및 codecov 테스트

* test: types coverage 제거

* fix: env & test env
  • Loading branch information
ssi02014 authored Apr 28, 2024
1 parent 19aa4b1 commit 1193b38
Show file tree
Hide file tree
Showing 22 changed files with 47 additions and 54 deletions.
7 changes: 7 additions & 0 deletions .changeset/blue-windows-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@modern-kit/react': patch
'@modern-kit/types': patch
'@modern-kit/utils': patch
---

fix: test & build env
5 changes: 1 addition & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ nvm install
nvm use
```

- 작업 후 Pull Request 생성 전에 `test` `typecheck`를 진행해주세요.
- 작업 후 Pull Request 생성 전에 `test` 를 진행해주세요.

```shell
yarn test
```
```shell
yarn typecheck
```

<br />

Expand Down
23 changes: 0 additions & 23 deletions .pnp.cjs

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

6 changes: 1 addition & 5 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,4 @@ component_management:
- component_id: utils
name: '@modern-kit/utils'
paths:
- packages/utils/**
- component_id: types
name: '@modern-kit/types'
paths:
- packages/types/**
- packages/utils/**
4 changes: 3 additions & 1 deletion packages/react/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ rollup.config.mjs
# test
coverage
vite.config.ts
vite.setup.ts
vite.setup.ts
*.spec.d.ts
*.spec.d.tsx
2 changes: 1 addition & 1 deletion packages/react/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
esbuild(),
typescript({
tsconfig: './tsconfig.json',
exclude: ['**/*.spec.tsx'],
exclude: ['**/*.spec.tsx', '**/*.spec.ts'],
}),
terser(),
],
Expand Down
6 changes: 6 additions & 0 deletions packages/react/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export default defineConfig({
setupFiles: './vitest.setup.ts',
coverage: {
provider: 'istanbul',
exclude: [
'src/index.ts',
'src/global.d.ts',
'src/components/index.ts',
'src/hooks/index.ts',
],
},
},
});
3 changes: 2 additions & 1 deletion packages/types/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ rollup.config.mjs
# test
coverage
vite.config.ts
vite.setup.ts
vite.setup.ts
*.spec.d.ts
3 changes: 1 addition & 2 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"scripts": {
"test": "vitest --typecheck",
"test:run": "vitest run --coverage --typecheck",
"test:run": "vitest run --typecheck",
"typecheck": "tsc",
"build": "rm -rf dist && yarn typecheck"
},
Expand All @@ -25,7 +25,6 @@
"access": "public"
},
"devDependencies": {
"@vitest/coverage-istanbul": "^1.5.2",
"tslib": "^2.6.2",
"typescript": "^5.1.6",
"vitest": "^1.5.0"
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/Arrayable/Arrayable.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { describe, expectTypeOf, it } from 'vitest';
import { Arrayable } from '.';

describe('Nullable', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/ExcludeNullish/ExcludeNullish.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { describe, expectTypeOf, it } from 'vitest';
import { ExcludeNullish } from '.';

describe('ExcludeNullish', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { describe, expectTypeOf, it } from 'vitest';
import { ExtendOmittedProperties } from '.';

describe('ExcludeNullish', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/IndexSignature/IndexSignature.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { describe, expectTypeOf, it } from 'vitest';
import { IndexSignature } from '.';

describe('IndexSignature', () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/types/src/Nullable/Nullable.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { describe, expectTypeOf, it } from 'vitest';
import { Nullable } from '.';

describe('Nullable', () => {
it('제네릭 타입으로 넣어준 타입과 더불어 null과 undefined를 허용합니다.', () => {
it('제네릭 타입으로 넣어준 타입과 더불어 null을 허용합니다.', () => {
const test = '123' as Nullable<string>;

expectTypeOf(test).toEqualTypeOf<string | null | undefined>();
expectTypeOf(test).toEqualTypeOf<string | null>();
});

it('조건식으로 타입을 좁히면 제네릭 타입으로 좁혀집니다.', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/ObjectEntries/ObjectEntries.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { describe, expectTypeOf, it } from 'vitest';
import { ObjectEntries } from '.';

describe('ObjectKeys', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/ObjectKeys/ObjectKeys.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { describe, expectTypeOf, it } from 'vitest';
import { ObjectKeys } from '.';

describe('ObjectKeys', () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@
"skipLibCheck": true,
"emitDeclarationOnly": true
},
"exclude": [
"**/*.spec.ts" // 모든 .test.ts 파일을 제외
]
}
3 changes: 0 additions & 3 deletions packages/types/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ export default defineConfig({
name: packageJson.name,
dir: './src',
globals: true,
coverage: {
provider: 'istanbul',
},
},
});
3 changes: 2 additions & 1 deletion packages/utils/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ rollup.config.mjs
# test
coverage
vite.config.ts
vite.setup.ts
vite.setup.ts
*.spec.d.ts
13 changes: 13 additions & 0 deletions packages/utils/src/common/abRandom/abRandom.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { abRandom } from '.';

describe('abRandom', () => {
it('should return 0 if Math.random() is less than 0.5', () => {
vi.spyOn(Math, 'random').mockReturnValue(0.3);
expect(abRandom()).toBe(0);
});

it('should return 1 if Math.random() is 0.5 or greater', () => {
vi.spyOn(Math, 'random').mockReturnValue(0.7);
expect(abRandom()).toBe(1);
});
});
8 changes: 8 additions & 0 deletions packages/utils/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ export default defineConfig({
globals: true,
coverage: {
provider: 'istanbul',
exclude: [
'src/index.ts',
'src/common/index.ts',
'src/device/index.ts',
'src/string/index.ts',
'src/object/index.ts',
'src/storage',
],
},
},
});
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4340,7 +4340,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@modern-kit/types@workspace:packages/types"
dependencies:
"@vitest/coverage-istanbul": "npm:^1.5.2"
tslib: "npm:^2.6.2"
typescript: "npm:^5.1.6"
vitest: "npm:^1.5.0"
Expand Down

0 comments on commit 1193b38

Please sign in to comment.