claude-flow-depth
Version:
DEPTH Methodology Installer - Ousterhout-First Development for Claude Code
94 lines (74 loc) • 3.56 kB
JavaScript
/**
* Application Core Tests
*
* DEPTH Testing Strategy:
* - Test interface behavior, not implementation details
* - Focus on information hiding validation
* - Ensure deep module functionality works correctly
*/
import { test } from 'node:test';
import assert from 'node:assert';
import { createApp } from '../src/core/app.js';
test('Application Creation and Initialization', async (t) => {
await t.test('should create app instance with simple interface', async () => {
const app = await createApp();
// Test interface simplicity - only expected methods exposed
assert.ok(typeof app.start === 'function', 'start method should be available');
assert.ok(typeof app.getStatus === 'function', 'getStatus method should be available');
// Test information hiding - implementation details not exposed
assert.ok(!app.hasOwnProperty('appState'), 'internal state should be hidden');
assert.ok(!app.hasOwnProperty('config'), 'internal config should be hidden');
});
await t.test('should initialize application successfully', async () => {
const app = await createApp();
// Test initial status
let status = app.getStatus();
assert.strictEqual(status.initialized, false, 'should start uninitialized');
// Test initialization
await app.start();
// Test post-initialization status
status = app.getStatus();
assert.strictEqual(status.initialized, true, 'should be initialized after start');
});
await t.test('should prevent double initialization', async () => {
const app = await createApp();
await app.start();
// Test error handling for double initialization
await assert.rejects(
() => app.start(),
{ message: 'Application already initialized' },
'should throw error on double initialization'
);
});
await t.test('should maintain simple interface contract', async () => {
const app = await createApp();
// Test that interface methods return expected types
const status = app.getStatus();
assert.ok(typeof status === 'object', 'getStatus should return object');
assert.ok(typeof status.initialized === 'boolean', 'initialized should be boolean');
assert.ok(typeof status.serviceCount === 'number', 'serviceCount should be number');
});
});
test('DEPTH Principles Validation', async (t) => {
await t.test('should demonstrate deep module pattern', async () => {
const app = await createApp();
// Test that complex functionality is accessible through simple interface
await app.start();
const status = app.getStatus();
// Simple interface call should hide complex service management
assert.ok(status.serviceCount >= 0, 'should manage services behind simple interface');
});
await t.test('should hide implementation complexity', async () => {
const app = await createApp();
// Test that internal implementation is not accessible
const appProperties = Object.getOwnPropertyNames(app);
const expectedInterface = ['start', 'getStatus'];
expectedInterface.forEach(method => {
assert.ok(appProperties.includes(method), `${method} should be in interface`);
});
// Should not expose internal implementation details
assert.ok(!appProperties.includes('appState'), 'internal state should be hidden');
assert.ok(!appProperties.includes('services'), 'internal services should be hidden');
assert.ok(!appProperties.includes('config'), 'internal config should be hidden');
});
});