-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sanjaye Narayan
authored and
Sanjaye Narayan
committed
Jan 30, 2025
1 parent
34f07b1
commit b902f40
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { allValuesFrom } from '@sourcegraph/cody-shared' | ||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
import { StatusBarAlignment, vsCodeMocks } from '../testutils/mocks' | ||
import { CodyStatusBar } from './StatusBar' | ||
|
||
vi.mock('vscode', () => ({ | ||
...vsCodeMocks, | ||
StatusBarAlignment, | ||
})) | ||
|
||
describe('StatusBar loader debouncing', () => { | ||
let statusBar: CodyStatusBar | ||
let observedChanges: Promise<Set<any>[]> | ||
|
||
beforeEach(() => { | ||
vi.useFakeTimers() | ||
statusBar = CodyStatusBar.init() | ||
// Track all changes to the loaders collection | ||
observedChanges = allValuesFrom(statusBar['loaders'].changes).then(changes => | ||
Check failure on line 19 in vscode/src/services/StatusBar.test.ts GitHub Actions / build
|
||
changes.map(set => new Set(set)) | ||
) | ||
}) | ||
|
||
afterEach(() => { | ||
statusBar?.dispose() | ||
vi.useRealTimers() | ||
}) | ||
|
||
it('tracks loader mutations', async () => { | ||
statusBar.addLoader({ title: 'Test Loader' }) | ||
statusBar['loaders'].complete() | ||
Check failure on line 31 in vscode/src/services/StatusBar.test.ts GitHub Actions / build
|
||
|
||
const states = await observedChanges | ||
// Initial empty state | ||
expect(states[0].size).toBe(0) | ||
// After adding loader | ||
expect(states[1].size).toBe(1) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters