23 lines
990 B
JavaScript
23 lines
990 B
JavaScript
import { test } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readFileSync } from 'node:fs'
|
|
import { readOdtEntry } from '#import-recipes/odt/readOdtEntry.js'
|
|
|
|
// A real .odt built by tests/buildSampleOdt.py - a zip, mimetype first.
|
|
const SAMPLE_ODT = new URL('./sample-recipe.odt', import.meta.url)
|
|
|
|
test('reads an entry of a real .odt file', () => {
|
|
const contentXml = readOdtEntry(readFileSync(SAMPLE_ODT), 'content.xml')
|
|
assert.ok(contentXml.startsWith('<?xml version="1.0" encoding="UTF-8"?>'))
|
|
assert.ok(contentXml.includes('<office:document-content'))
|
|
assert.ok(contentXml.includes('Gratin de courgettes'))
|
|
})
|
|
|
|
test('reads the uncompressed mimetype entry', () => {
|
|
const mimetype = readOdtEntry(readFileSync(SAMPLE_ODT), 'mimetype')
|
|
assert.equal(mimetype, 'application/vnd.oasis.opendocument.text')
|
|
})
|
|
|
|
test('returns null for an entry the archive does not hold', () => {
|
|
assert.equal(readOdtEntry(readFileSync(SAMPLE_ODT), 'settings.xml'), null)
|
|
})
|