|
| 1 | +/** |
| 2 | + * MGW — Placeholder test suite |
| 3 | + * |
| 4 | + * This file establishes the test directory and a minimal smoke test. |
| 5 | + * Future contributors should add tests here for: |
| 6 | + * |
| 7 | + * - CLI argument parsing (bin/mgw.cjs) |
| 8 | + * - State file read/write (lib/state.cjs) |
| 9 | + * - Template loading (lib/template-loader.cjs) |
| 10 | + * - Output formatting (lib/output.cjs) |
| 11 | + * - GitHub helpers (lib/github.cjs) |
| 12 | + * |
| 13 | + * Run with: npm test |
| 14 | + * |
| 15 | + * The test uses Node's built-in assert module and test runner (node:test) |
| 16 | + * which requires Node.js >= 18. No additional test dependencies needed. |
| 17 | + */ |
| 18 | + |
| 19 | +const { describe, it } = require('node:test'); |
| 20 | +const assert = require('node:assert/strict'); |
| 21 | +const { existsSync } = require('node:fs'); |
| 22 | +const { resolve } = require('node:path'); |
| 23 | + |
| 24 | +describe('mgw', () => { |
| 25 | + it('package.json exists and has required fields', () => { |
| 26 | + const pkgPath = resolve(__dirname, '..', 'package.json'); |
| 27 | + assert.ok(existsSync(pkgPath), 'package.json should exist'); |
| 28 | + |
| 29 | + const pkg = require(pkgPath); |
| 30 | + assert.ok(pkg.name, 'package.json should have a name'); |
| 31 | + assert.ok(pkg.version, 'package.json should have a version'); |
| 32 | + assert.ok(pkg.bin, 'package.json should have a bin field'); |
| 33 | + assert.ok(pkg.main, 'package.json should have a main field'); |
| 34 | + }); |
| 35 | + |
| 36 | + it('CLI entry point exists', () => { |
| 37 | + const binPath = resolve(__dirname, '..', 'bin', 'mgw.cjs'); |
| 38 | + assert.ok(existsSync(binPath), 'bin/mgw.cjs should exist'); |
| 39 | + }); |
| 40 | + |
| 41 | + it('lib modules exist', () => { |
| 42 | + const libDir = resolve(__dirname, '..', 'lib'); |
| 43 | + const expectedModules = [ |
| 44 | + 'index.cjs', |
| 45 | + 'state.cjs', |
| 46 | + 'github.cjs', |
| 47 | + 'output.cjs', |
| 48 | + 'gsd.cjs', |
| 49 | + 'claude.cjs', |
| 50 | + 'template-loader.cjs', |
| 51 | + 'templates.cjs', |
| 52 | + ]; |
| 53 | + |
| 54 | + for (const mod of expectedModules) { |
| 55 | + const modPath = resolve(libDir, mod); |
| 56 | + assert.ok(existsSync(modPath), `lib/${mod} should exist`); |
| 57 | + } |
| 58 | + }); |
| 59 | + |
| 60 | + it('commands directory has expected slash commands', () => { |
| 61 | + const cmdDir = resolve(__dirname, '..', 'commands'); |
| 62 | + const expectedCommands = [ |
| 63 | + 'run.md', |
| 64 | + 'issue.md', |
| 65 | + 'init.md', |
| 66 | + 'status.md', |
| 67 | + 'sync.md', |
| 68 | + ]; |
| 69 | + |
| 70 | + for (const cmd of expectedCommands) { |
| 71 | + const cmdPath = resolve(cmdDir, cmd); |
| 72 | + assert.ok(existsSync(cmdPath), `commands/${cmd} should exist`); |
| 73 | + } |
| 74 | + }); |
| 75 | +}); |
0 commit comments