Replace toBeDefined()/typeof checks with assertions that verify actual behavior and output content. Key changes: - locators: assert actual CSS selector values instead of existence - logger-integration: test run()/getContext()/withRequestContext() behavior - logger: verify winstonCalls content (level, message, metadata) - config-manager: test default values, singleton, and getConfig() throws - erp-auth: remove empty Class Structure block (covered by behavior tests) - audit-logger: spy on auditLogger.info to verify JSONL entry content - extractor: remove Math.ceil tests, verify error result structure Net: -209 lines of hollow/redundant test code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
29 lines
970 B
TypeScript
29 lines
970 B
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { ErpAuthService } from '../../src/main/services/erp/erp-auth'
|
|
import type { ErpConfig } from '../../src/main/types/erp.types'
|
|
|
|
const testConfig: ErpConfig = {
|
|
url: 'https://test.example.com',
|
|
username: 'testuser',
|
|
password: 'testpass'
|
|
}
|
|
|
|
describe('ERP Authentication Service (Unit)', () => {
|
|
describe('Initial State', () => {
|
|
it('should report inactive status before login', () => {
|
|
const service = new ErpAuthService(testConfig)
|
|
expect(service.isActive()).toBe(false)
|
|
})
|
|
|
|
it('should throw error when getting session before login', () => {
|
|
const service = new ErpAuthService(testConfig)
|
|
expect(() => service.getSession()).toThrow('Not logged in. Call login() first.')
|
|
})
|
|
|
|
it('should handle close when no session exists', async () => {
|
|
const service = new ErpAuthService(testConfig)
|
|
await expect(service.close()).resolves.toBeUndefined()
|
|
})
|
|
})
|
|
})
|