From ce0968ec31b60e48554e47f954257973a4018137 Mon Sep 17 00:00:00 2001 From: u013235949 Date: Wed, 4 Sep 2024 17:05:00 +0800 Subject: [PATCH] Wed Sep 4 17:05:00 CST 2024 inscode --- .inscode | 8 ++++++-- babel.config.js | 3 +++ index.js | 7 ++++++- index.test.js | 6 ++++++ package.json | 18 ++++++++++++------ sum.js | 3 +++ 6 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 babel.config.js create mode 100644 index.test.js create mode 100644 sum.js diff --git a/.inscode b/.inscode index ecc8bdd..c569fd6 100644 --- a/.inscode +++ b/.inscode @@ -1,6 +1,10 @@ -run = "npm i && npm run dev" +run = "npm i && npm run test" +language = "node" [env] PATH = "/root/${PROJECT_DIR}/.config/npm/node_global/bin:/root/${PROJECT_DIR}/node_modules/.bin:${PATH}" XDG_CONFIG_HOME = "/root/.config" -npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" \ No newline at end of file +npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" + +[debugger] +program = "main.js" diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..32b35df --- /dev/null +++ b/babel.config.js @@ -0,0 +1,3 @@ +module.exports = { + presets: [['@babel/preset-env', {targets: {node: 'current'}}]], +}; \ No newline at end of file diff --git a/index.js b/index.js index 2d7e683..c420ef8 100644 --- a/index.js +++ b/index.js @@ -1 +1,6 @@ -console.log("欢迎来到 InsCode"); \ No newline at end of file + +import {round} from 'lodash-es' + +export function fixed(a) { + return round(a) +} diff --git a/index.test.js b/index.test.js new file mode 100644 index 0000000..7cc7592 --- /dev/null +++ b/index.test.js @@ -0,0 +1,6 @@ +// const sum = require('./index') +import { fixed } from './index' + +test('fixed 2', () => { + expect(fixed(2)).toBe(2.00); +}); \ No newline at end of file diff --git a/package.json b/package.json index 72caa17..5811c7b 100644 --- a/package.json +++ b/package.json @@ -4,15 +4,21 @@ "description": "", "main": "index.js", "scripts": { - "dev": "node index.js", - "test": "echo \"Error: no test specified\" && exit 1" + "dev": "node index.js", + "test": "jest" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { - "@types/node": "^18.0.6", - "node-fetch": "^3.2.6" + "@types/node": "^18.0.6", + "lodash-es": "^4.17.21", + "node-fetch": "^3.2.6" + }, + "devDependencies": { + "@babel/core": "^7.25.2", + "@babel/preset-env": "^7.25.4", + "babel-jest": "^29.7.0", + "jest": "^29.7.0" } - } - \ No newline at end of file +} diff --git a/sum.js b/sum.js new file mode 100644 index 0000000..28e61dd --- /dev/null +++ b/sum.js @@ -0,0 +1,3 @@ +export const sum = (a, b) => { + return a + b +} \ No newline at end of file -- GitLab