Lines 106-146javascript
106 assert.ok(!genRequired.includes('n'), 'n must be optional');
107 // model is an enum with the two tiers
108 const modelEnum = gen.inputSchema.properties.model.enum;
109 assert.deepEqual(modelEnum, ['dailey-fast', 'dailey-pro'], 'model enum must be the two tiers');
116// ── Layer 2: in-process registration checks ────────────────────────────────
118describe('dailey images tools — registration', { concurrency: false }, () => {
119 test('registers all three tools with the right shapes', async () => {
120 const registrations = [];
122 tool(name, description, schema, handler) {
123 registrations.push({ name, description, schema, handler });
127 const mod = await import(join(__dirname, '..', 'dist', 'tools', 'dailey-images.js'));
128 mod.registerDaileyImagesTools(stubServer);
MediumDynamic Require
Package source references dynamic require/import behavior.
tests/dailey-images.test.mjsView on unpkg · L126 130 const byName = Object.fromEntries(registrations.map((r) => [r.name, r]));
132 const gen = byName['dailey_images_generate'];
133 assert.ok(gen, 'dailey_images_generate must be registered');
134 assert.ok(typeof gen.handler === 'function', 'generate handler must be a function');
135 assert.ok(gen.schema?.project && gen.schema?.prompt, 'generate must have project + prompt');
136 // metered cost is called out in the description
137 assert.match(gen.description, /2¢/, 'generate description must mention 2¢ (fast)');
138 assert.match(gen.description, /10¢/, 'generate description must mention 10¢ (pro)');
139 assert.match(gen.description, /prepaid credits/i, 'generate description must mention prepaid credits');
140 // prompt required, model optional
141 const promptOptional = gen.schema.prompt?._def?.typeName === 'ZodOptional'
142 || (typeof gen.schema.prompt?.isOptional === 'function' && gen.schema.prompt.isOptional());
143 assert.ok(!promptOptional, 'prompt must NOT be optional');
144 const modelOptional = gen.schema.model?._def?.typeName === 'ZodOptional'
145 || (typeof gen.schema.model?.isOptional === 'function' && gen.schema.model.isOptional());
146 assert.ok(modelOptional, 'model must be optional');