forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstickyNotesPath.test.ts
More file actions
46 lines (40 loc) · 1.62 KB
/
Copy pathstickyNotesPath.test.ts
File metadata and controls
46 lines (40 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { describe, it, expect } from 'vitest'
import { join } from 'path'
import { resolveStickyNotesDb } from './stickyNotesPath'
describe('resolveStickyNotesDb', () => {
const local = 'C:\\Users\\me\\AppData\\Local'
const pkgDir = 'Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe'
const dbPath = join(local, 'Packages', pkgDir, 'LocalState', 'plum.sqlite')
it('resolves the plum.sqlite path under the matching package dir', () => {
const got = resolveStickyNotesDb(
{ LOCALAPPDATA: local },
() => [pkgDir, 'Some.Other.Package_abc'],
(p) => p === dbPath
)
expect(got).toBe(dbPath)
})
it('picks the first listed package whose db exists (caller pre-sorts newest-first)', () => {
const newer = 'Microsoft.MicrosoftStickyNotes_new'
const older = 'Microsoft.MicrosoftStickyNotes_old'
const olderDb = join(local, 'Packages', older, 'LocalState', 'plum.sqlite')
const got = resolveStickyNotesDb(
{ LOCALAPPDATA: local },
() => [newer, older], // newest-first
(p) => p === olderDb // only the older one actually has a db
)
expect(got).toBe(olderDb)
})
it('returns null when no Sticky Notes package dir exists', () => {
expect(
resolveStickyNotesDb({ LOCALAPPDATA: local }, () => ['Some.Other_x'], () => true)
).toBeNull()
})
it('returns null when the package exists but plum.sqlite does not', () => {
expect(
resolveStickyNotesDb({ LOCALAPPDATA: local }, () => [pkgDir], () => false)
).toBeNull()
})
it('returns null when LOCALAPPDATA is unset', () => {
expect(resolveStickyNotesDb({}, () => [pkgDir], () => true)).toBeNull()
})
})