From 9d50a6709db2dd35808257eb08e9e2518cea00bc Mon Sep 17 00:00:00 2001 From: Zack Braksa Date: Fri, 11 Oct 2024 00:20:15 +0100 Subject: [PATCH] Update test script, export getGitDiff, and add unit test for it in test.js. --- package.json | 2 +- src/index.js | 2 ++ test/test.js | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/test.js diff --git a/package.json b/package.json index e490c18..96251f8 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "gitai": "./bin/gitai.js" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", + "test": "node --test", "lint": "standard --fix 'src/*.js'", "version": "git add -A", "prerelease": "npm run lint", diff --git a/src/index.js b/src/index.js index bb7f6b8..c814b65 100644 --- a/src/index.js +++ b/src/index.js @@ -58,3 +58,5 @@ program }) program.parse() + +module.exports = { getGitDiff } diff --git a/test/test.js b/test/test.js new file mode 100644 index 0000000..cde6e08 --- /dev/null +++ b/test/test.js @@ -0,0 +1,10 @@ +const assert = require('node:assert') +const test = require('node:test') +const { getGitDiff } = require('../src/index.js') + +test('getGitDiff', async (t) => { + await t.test('should return a string', () => { + const diff = getGitDiff() + assert.strictEqual(typeof diff, 'string') + }) +})