From de9581e510792af027a0f6f352ec48a2aa6d1ec1 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Fri, 26 Jun 2026 16:28:11 -0700 Subject: [PATCH] test: use testBuild for successful build fixtures --- test-cases/default-layout/index.test.js | 16 +++++++--------- test-cases/drafts/index.test.js | 15 ++++++++------- test-cases/general-features/index.test.js | 13 +++++++------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/test-cases/default-layout/index.test.js b/test-cases/default-layout/index.test.js index 1f9f378..96d862d 100644 --- a/test-cases/default-layout/index.test.js +++ b/test-cases/default-layout/index.test.js @@ -1,21 +1,19 @@ import { test } from 'node:test' import assert from 'node:assert' -import { DomStack } from '../../index.js' +import { testBuild } from '../../index.js' import * as path from 'path' -import { rm } from 'fs/promises' const __dirname = import.meta.dirname test.describe('default-layout', () => { - test('should build site with default layout', async () => { + test('should build site with default layout', async (t) => { const src = path.join(__dirname, './src') - const dest = path.join(__dirname, './public') - const siteUp = new DomStack(src, dest) + const build = await testBuild(src) - await rm(dest, { recursive: true, force: true }) + t.after(async () => { + await build.cleanup() + }) - await siteUp.build() - - assert.ok(true, 'built with default layout') + assert.ok(build.results, 'built with default layout') }) }) diff --git a/test-cases/drafts/index.test.js b/test-cases/drafts/index.test.js index 9913d64..7071585 100644 --- a/test-cases/drafts/index.test.js +++ b/test-cases/drafts/index.test.js @@ -1,22 +1,23 @@ import { test } from 'node:test' import assert from 'node:assert' -import { DomStack } from '../../index.js' +import { testBuild } from '../../index.js' import * as path from 'path' -import { rm, stat, readFile } from 'fs/promises' +import { stat, readFile } from 'fs/promises' import * as cheerio from 'cheerio' import { allFiles } from 'async-folder-walker' const __dirname = import.meta.dirname test.describe('drafts', () => { - test('should build site with draft pages', async () => { + test('should build site with draft pages', async (t) => { const src = path.join(__dirname, './src') - const dest = path.join(__dirname, './public') - const siteUp = new DomStack(src, dest, { buildDrafts: true }) + const build = await testBuild(src, { buildDrafts: true }) + const { dest, results } = build - await rm(dest, { recursive: true, force: true }) + t.after(async () => { + await build.cleanup() + }) - const results = await siteUp.build() assert.ok(results, 'Domstack built site and returned build results') const pages = { diff --git a/test-cases/general-features/index.test.js b/test-cases/general-features/index.test.js index 3c6e8e3..616ba4d 100644 --- a/test-cases/general-features/index.test.js +++ b/test-cases/general-features/index.test.js @@ -1,8 +1,8 @@ import { test } from 'node:test' import assert from 'node:assert' -import { DomStack } from '../../index.js' +import { testBuild } from '../../index.js' import * as path from 'path' -import { rm, stat, readFile } from 'fs/promises' +import { stat, readFile } from 'fs/promises' import * as cheerio from 'cheerio' import { allFiles } from 'async-folder-walker' @@ -11,12 +11,13 @@ const __dirname = import.meta.dirname test.describe('general-features', () => { test('should build site with all features', async (t) => { const src = path.join(__dirname, './src') - const dest = path.join(__dirname, './public') - const siteUp = new DomStack(src, dest, { copy: [path.join(__dirname, './copyfolder')] }) + const build = await testBuild(src, { copy: [path.join(__dirname, './copyfolder')] }) + const { dest, results } = build - await rm(dest, { recursive: true, force: true }) + t.after(async () => { + await build.cleanup() + }) - const results = await siteUp.build() assert.ok(results, 'DomStack built site and returned build results') const globalAssets = {