From 57b6746af787a0899bee4f7ebbbaf28560e7a8d7 Mon Sep 17 00:00:00 2001 From: leejooy96 Date: Thu, 5 Dec 2024 09:47:00 +0900 Subject: [PATCH] test: add test files and fix test --- .gitignore | 1 + package.json | 4 ++-- test/index.js | 3 --- test/src/index.js | 17 +++++++++++++++++ test/test.js | 6 ------ 5 files changed, 20 insertions(+), 11 deletions(-) delete mode 100644 test/index.js create mode 100644 test/src/index.js delete mode 100644 test/test.js diff --git a/.gitignore b/.gitignore index 6ca072b..c7b9b07 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,4 @@ $RECYCLE.BIN/ # Project files dist/ +test/result/ diff --git a/package.json b/package.json index deaa276..62a9b2a 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,9 @@ ".": "./dist/index.js" }, "scripts": { - "test": "npm run build && node dist/index.js", + "test": "npm run build && node dist/index.js 'test/src/**/*.js' -o test/result/ --debug", "build": "npm run format:fix && tsc && npm run minify", - "minify": "terser dist/index.js --config-file .terserrc -o dist/index.js", + "minify": "terser dist/index.js --config-file terser.config.json -o dist/index.js", "format": "prettier .", "format:fix": "prettier . --write" }, diff --git a/test/index.js b/test/index.js deleted file mode 100644 index 46e96e2..0000000 --- a/test/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export default function abc() { - return 2; -} diff --git a/test/src/index.js b/test/src/index.js new file mode 100644 index 0000000..315a0af --- /dev/null +++ b/test/src/index.js @@ -0,0 +1,17 @@ +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type +function arrShuffle(array) { + if (array.length === 1) { + return array[0]; + } + + const newArray = array; + + for (let i = array.length - 1; i > 0; i -= 1) { + const j = Math.floor(Math.random() * (i + 1)); + [newArray[i], newArray[j]] = [array[j], array[i]]; + } + + return newArray; +} + +export default arrShuffle; diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 84f81c4..0000000 --- a/test/test.js +++ /dev/null @@ -1,6 +0,0 @@ -export default function def(c) { - const a = 1; - const b = c; - - return a + b; -}