diff options
Diffstat (limited to 'archived/projt-launcher/ci/github-script/test')
| -rw-r--r-- | archived/projt-launcher/ci/github-script/test/commits.test.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/archived/projt-launcher/ci/github-script/test/commits.test.js b/archived/projt-launcher/ci/github-script/test/commits.test.js new file mode 100644 index 0000000000..ed1be49682 --- /dev/null +++ b/archived/projt-launcher/ci/github-script/test/commits.test.js @@ -0,0 +1,42 @@ +#!/usr/bin/env node +'use strict' + +process.env.COMMIT_TYPES = 'customtype' + +const assert = require('node:assert/strict') +const commits = require('../commits.js') + +const { validateCommitMessage, normalizeCommitType } = commits + +const validMessages = [ + 'feat(ui): add redesigned settings panel', + 'refactor: drop deprecated launcher flag support', + 'chore(ci): refresh workflows configuration', + '11.feat: support legacy numbered commit type format', + '23.deps(deps): bump dependency pins', + 'release: publish stable build artifacts', + 'customtype: allow env commit type overrides', +] + +for (const message of validMessages) { + const result = validateCommitMessage(message) + assert.equal( + result.valid, + true, + `Expected commit "${message}" to be valid, got: ${result.message}` + ) +} + +const invalidType = validateCommitMessage('unknown(scope): add feature that is real enough') +assert.equal(invalidType.valid, false, 'Expected invalid type to be rejected') +assert.match(invalidType.message, /Unknown commit type/i) + +const shortDescription = validateCommitMessage('feat: short') +assert.equal(shortDescription.valid, false, 'Expected short description to fail validation') +assert.match(shortDescription.message, /too short/i) + +assert.equal(normalizeCommitType('11.feat'), 'feat') +assert.equal(normalizeCommitType('23.deps'), 'deps') +assert.equal(normalizeCommitType('chore'), 'chore') + +console.log('commits.js tests passed') |
