renote-server 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Mock CONFIG before importing AuthManager
4
+ jest.mock('../config', () => ({
5
+ CONFIG: {
6
+ port: 8080,
7
+ authToken: '',
8
+ claudeHome: '/home/user/.claude',
9
+ maxFileSize: 10485760,
10
+ searchTimeout: 5000,
11
+ logLevel: 'info',
12
+ }
13
+ }));
14
+ const auth_1 = require("../websocket/auth");
15
+ const config_1 = require("../config");
16
+ describe('AuthManager', () => {
17
+ let authManager;
18
+ beforeEach(() => {
19
+ authManager = new auth_1.AuthManager();
20
+ });
21
+ describe('validateToken', () => {
22
+ it('should return true for valid token', () => {
23
+ config_1.CONFIG.authToken = 'test-token';
24
+ const result = authManager.validateToken('test-token');
25
+ expect(result).toBe(true);
26
+ });
27
+ it('should return false for invalid token', () => {
28
+ config_1.CONFIG.authToken = 'test-token';
29
+ const result = authManager.validateToken('wrong-token');
30
+ expect(result).toBe(false);
31
+ });
32
+ it('should return true when no token configured', () => {
33
+ config_1.CONFIG.authToken = '';
34
+ const result = authManager.validateToken('any-token');
35
+ expect(result).toBe(true);
36
+ });
37
+ });
38
+ describe('generateClientId', () => {
39
+ it('should generate unique client IDs', () => {
40
+ const id1 = authManager.generateClientId();
41
+ const id2 = authManager.generateClientId();
42
+ expect(id1).not.toBe(id2);
43
+ });
44
+ it('should generate IDs with correct format', () => {
45
+ const id = authManager.generateClientId();
46
+ expect(id).toMatch(/^client_\d+_[a-z0-9]+$/);
47
+ });
48
+ });
49
+ });
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const events_1 = require("events");
4
+ // Mock chokidar before importing ClaudeWatcher
5
+ jest.mock('chokidar', () => ({
6
+ default: {
7
+ watch: jest.fn(() => ({
8
+ on: jest.fn(),
9
+ close: jest.fn()
10
+ }))
11
+ }
12
+ }));
13
+ const watcher_1 = require("../claude/watcher");
14
+ describe('ClaudeWatcher', () => {
15
+ let watcher;
16
+ beforeEach(() => {
17
+ watcher = new watcher_1.ClaudeWatcher();
18
+ });
19
+ afterEach(() => {
20
+ watcher.stop();
21
+ });
22
+ it('should be an EventEmitter', () => {
23
+ expect(watcher).toBeInstanceOf(events_1.EventEmitter);
24
+ });
25
+ it('should emit user_input events', (done) => {
26
+ watcher.on('user_input', (data) => {
27
+ expect(data).toHaveProperty('message');
28
+ expect(data).toHaveProperty('timestamp');
29
+ expect(data).toHaveProperty('sessionId');
30
+ done();
31
+ });
32
+ // Simulate user input event
33
+ watcher.emit('user_input', {
34
+ message: 'test message',
35
+ timestamp: Date.now(),
36
+ sessionId: 'test-session',
37
+ project: '/test/project'
38
+ });
39
+ });
40
+ it('should handle queue processing', async () => {
41
+ const events = [];
42
+ watcher.on('user_input', (data) => {
43
+ events.push(data);
44
+ });
45
+ // Simulate multiple rapid events
46
+ for (let i = 0; i < 5; i++) {
47
+ watcher.emit('user_input', {
48
+ message: `message ${i}`,
49
+ timestamp: Date.now(),
50
+ sessionId: 'test-session',
51
+ project: '/test/project'
52
+ });
53
+ }
54
+ // Wait for processing
55
+ await new Promise(resolve => setTimeout(resolve, 200));
56
+ expect(events.length).toBe(5);
57
+ });
58
+ });