From f1c19d453a5cbec217adc75ed986b436ff5f1d22 Mon Sep 17 00:00:00 2001 From: nicwands Date: Tue, 24 Mar 2026 13:56:52 -0400 Subject: [PATCH] update to new sdk --- .nvmrc | 1 + src/FileSystemAdapter.js | 9 +++++++++ test/plugin.test.js | 34 +++------------------------------- vitest.config.js | 1 + 4 files changed, 14 insertions(+), 31 deletions(-) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..2bd5a0a --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22 diff --git a/src/FileSystemAdapter.js b/src/FileSystemAdapter.js index 7082457..eb55988 100644 --- a/src/FileSystemAdapter.js +++ b/src/FileSystemAdapter.js @@ -45,6 +45,15 @@ export default class FileSystemAdapter extends BaseNotesAdapter { await fs.unlink(filePath) } + async testConnection() { + try { + await fs.access(this.notesDir) + return true + } catch (error) { + return false + } + } + async _write(note) { const filePath = path.join(this.notesDir, `${note.id}.json`) diff --git a/test/plugin.test.js b/test/plugin.test.js index 7870a19..bc7355e 100644 --- a/test/plugin.test.js +++ b/test/plugin.test.js @@ -1,7 +1,6 @@ import { describe, it } from 'vitest' -import { runPluginTests } from '@takerofnotes/plugin-sdk' +import { describePluginTests } from '@takerofnotes/plugin-sdk' import plugin from './src/index.js' -import FileSystemAdapter from './src/FileSystemAdapter.js' import path from 'path' import { fileURLToPath } from 'url' import fs from 'fs' @@ -13,33 +12,6 @@ if (!fs.existsSync(testDir)) { fs.mkdirSync(testDir, { recursive: true }) } -const adapter = new FileSystemAdapter({ notesDir: testDir }) -const tests = runPluginTests({ plugin, adapter }) +const adapter = plugin.createAdapter({ notesDir: testDir }) -describe('Plugin Validation', () => { - tests.validatePlugin(it, (a, b) => expect(a).toBe(b)) -}) - -describe('Adapter: init()', () => { - tests.init(it) -}) - -describe('Adapter: getAll()', () => { - tests.getAll(it) -}) - -describe('Adapter: create()', () => { - tests.create(it) -}) - -describe('Adapter: update()', () => { - tests.update(it) -}) - -describe('Adapter: delete()', () => { - tests.delete(it) -}) - -describe('Full CRUD Cycle', () => { - tests.crudCycle(it) -}) +describePluginTests({ plugin, adapter }, describe, it, expect) diff --git a/vitest.config.js b/vitest.config.js index 466694d..ca4b6a6 100644 --- a/vitest.config.js +++ b/vitest.config.js @@ -3,5 +3,6 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { globals: true, + testTimeout: 30000, }, })