|
1 | 1 | import { test } from '@japa/runner' |
2 | 2 | import { readFile } from 'node:fs/promises' |
3 | | -import CreateTenant from '../../../src/commands/create_tenant.js' |
4 | 3 |
|
| 4 | +/** |
| 5 | + * Metadata-only spec. We intentionally do NOT import |
| 6 | + * `src/commands/create_tenant.ts`: its module graph reaches |
| 7 | + * `jobs/install_tenant.ts`, which eagerly imports |
| 8 | + * `@adonisjs/core/services/logger`. That logger module top-level |
| 9 | + * `await`s `app.booted(...)`, which throws when evaluated outside an |
| 10 | + * Ignitor (i.e. the unit suite). Reading the same contract from |
| 11 | + * `commands.json` + the barrel keeps the assertion meaningful while |
| 12 | + * staying side-effect-free. |
| 13 | + */ |
5 | 14 | test.group('tenant:create — command metadata', () => { |
6 | | - test('exports a command with the canonical name', ({ assert }) => { |
7 | | - assert.equal(CreateTenant.commandName, 'tenant:create') |
8 | | - }) |
9 | | - |
10 | | - test('description names the contract clearly', ({ assert }) => { |
11 | | - assert.match(CreateTenant.description, /create a new tenant/i) |
12 | | - }) |
13 | | - |
14 | | - test('starts the app (needs the container booted to resolve the repo)', ({ assert }) => { |
15 | | - assert.equal(CreateTenant.options?.startApp, true) |
16 | | - }) |
17 | | - |
18 | | - test('is registered in commands.json with name + email args', async ({ assert }) => { |
| 15 | + test('is registered in commands.json with the canonical contract', async ({ assert }) => { |
19 | 16 | const json = JSON.parse( |
20 | 17 | await readFile(new URL('../../../src/commands/commands.json', import.meta.url), 'utf-8') |
21 | 18 | ) |
22 | 19 | const entry = json.commands.find((c: any) => c.commandName === 'tenant:create') |
23 | 20 | assert.exists(entry, 'tenant:create missing from commands.json') |
24 | 21 | assert.equal(entry.filePath, 'create_tenant.js') |
| 22 | + assert.match(entry.description, /create a new tenant/i) |
| 23 | + assert.equal(entry.options?.startApp, true, 'must start the app to resolve the repo') |
25 | 24 |
|
26 | 25 | const argNames = entry.args.map((a: any) => a.argumentName) |
27 | 26 | assert.deepEqual(argNames, ['name', 'email']) |
|
0 commit comments