OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-note / test / unit / export.test.js

30 lines · javascript ref:
import test from 'brittle'
import { buildExportManifest } from '../../lib/export.js'

test('buildExportManifest - creates manifest with notebook info', async (t) => {
  const notebooks = [
    { slug: 'general', name: 'General', noteCount: 3 },
    { slug: 'dev', name: 'Development', noteCount: 1 }
  ]

  const manifest = buildExportManifest(notebooks, '0.3.1')

  t.is(manifest.version, '0.3.1')
  t.is(manifest.format, 'hypernote-export-v1')
  t.is(manifest.notebooks.length, 2)
  t.is(manifest.notebooks[0].slug, 'general')
  t.is(manifest.notebooks[1].name, 'Development')
  t.ok(manifest.exportedAt)
})

test('buildExportManifest - handles empty notebooks array', async (t) => {
  const manifest = buildExportManifest([], '1.0.0')
  t.is(manifest.notebooks.length, 0)
  t.is(manifest.version, '1.0.0')
})

test('buildExportManifest - defaults version to 0.0.0', async (t) => {
  const manifest = buildExportManifest([])
  t.is(manifest.version, '0.0.0')
})