feat(library): picker option to mark notes no_resolve

This commit is contained in:
afiqzudinhadi 2026-08-05 15:47:13 +08:00
parent 2686c3fa64
commit 16b8b242b8
4 changed files with 45 additions and 9 deletions

View file

@ -11,13 +11,14 @@ function fakeApp(): any {
}
describe('CandidatePickerModal', () => {
test('getItems: candidate labels followed by a trailing Skip item (null index)', () => {
test('getItems: candidate labels followed by Skip then Never resolve', () => {
const modal = new CandidatePickerModal(fakeApp(), 'Some Note.md', CANDIDATES);
const items = modal.getItems();
expect(items).toEqual([
{ label: 'Foo (2020)', index: 0 },
{ label: 'Bar (2021)', index: 1 },
{ label: 'Skip', index: null },
{ label: 'Never resolve (mark no_resolve)', index: 'never' },
]);
});
@ -40,6 +41,13 @@ describe('CandidatePickerModal', () => {
expect(await result).toBeNull();
});
test('onChooseItem(Never resolve) -> pick() resolves to \'never\'', async () => {
const modal = new CandidatePickerModal(fakeApp(), 'Some Note.md', CANDIDATES);
const result = modal.pick();
modal.onChooseItem({ label: 'Never resolve (mark no_resolve)', index: 'never' }, {} as MouseEvent);
expect(await result).toBe('never');
});
test('onClose without a prior choice (Esc / dismiss) -> pick() resolves to null', async () => {
const modal = new CandidatePickerModal(fakeApp(), 'Some Note.md', CANDIDATES);
const result = modal.pick();