Improve code coverage for cli package (#13724)

This commit is contained in:
Megha Bansal
2025-11-24 23:11:46 +05:30
committed by GitHub
parent 569c6f1dd0
commit 95693e265e
47 changed files with 5115 additions and 489 deletions
+32
View File
@@ -0,0 +1,32 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { describe, it, expect, vi } from 'vitest';
import { appEvents, AppEvent } from './events.js';
describe('events', () => {
it('should allow registering and emitting events', () => {
const callback = vi.fn();
appEvents.on(AppEvent.OauthDisplayMessage, callback);
appEvents.emit(AppEvent.OauthDisplayMessage, 'test message');
expect(callback).toHaveBeenCalledWith('test message');
appEvents.off(AppEvent.OauthDisplayMessage, callback);
});
it('should work with events without data', () => {
const callback = vi.fn();
appEvents.on(AppEvent.Flicker, callback);
appEvents.emit(AppEvent.Flicker);
expect(callback).toHaveBeenCalled();
appEvents.off(AppEvent.Flicker, callback);
});
});