update to new sdk
This commit is contained in:
@@ -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`)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -3,5 +3,6 @@ import { defineConfig } from 'vitest/config'
|
||||
export default defineConfig({
|
||||
test: {
|
||||
globals: true,
|
||||
testTimeout: 30000,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user