Skip to content

Commit 4fe23ab

Browse files
authored
Merge pull request #269 from bcomnes/chore/migrate-tests-to-test-build
Migrate successful build fixtures to testBuild
2 parents 8b1d360 + de9581e commit 4fe23ab

3 files changed

Lines changed: 22 additions & 22 deletions

File tree

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
import { test } from 'node:test'
22
import assert from 'node:assert'
3-
import { DomStack } from '../../index.js'
3+
import { testBuild } from '../../index.js'
44
import * as path from 'path'
5-
import { rm } from 'fs/promises'
65

76
const __dirname = import.meta.dirname
87

98
test.describe('default-layout', () => {
10-
test('should build site with default layout', async () => {
9+
test('should build site with default layout', async (t) => {
1110
const src = path.join(__dirname, './src')
12-
const dest = path.join(__dirname, './public')
13-
const siteUp = new DomStack(src, dest)
11+
const build = await testBuild(src)
1412

15-
await rm(dest, { recursive: true, force: true })
13+
t.after(async () => {
14+
await build.cleanup()
15+
})
1616

17-
await siteUp.build()
18-
19-
assert.ok(true, 'built with default layout')
17+
assert.ok(build.results, 'built with default layout')
2018
})
2119
})

test-cases/drafts/index.test.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import { test } from 'node:test'
22
import assert from 'node:assert'
3-
import { DomStack } from '../../index.js'
3+
import { testBuild } from '../../index.js'
44
import * as path from 'path'
5-
import { rm, stat, readFile } from 'fs/promises'
5+
import { stat, readFile } from 'fs/promises'
66
import * as cheerio from 'cheerio'
77
import { allFiles } from 'async-folder-walker'
88

99
const __dirname = import.meta.dirname
1010

1111
test.describe('drafts', () => {
12-
test('should build site with draft pages', async () => {
12+
test('should build site with draft pages', async (t) => {
1313
const src = path.join(__dirname, './src')
14-
const dest = path.join(__dirname, './public')
15-
const siteUp = new DomStack(src, dest, { buildDrafts: true })
14+
const build = await testBuild(src, { buildDrafts: true })
15+
const { dest, results } = build
1616

17-
await rm(dest, { recursive: true, force: true })
17+
t.after(async () => {
18+
await build.cleanup()
19+
})
1820

19-
const results = await siteUp.build()
2021
assert.ok(results, 'Domstack built site and returned build results')
2122

2223
const pages = {

test-cases/general-features/index.test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { test } from 'node:test'
22
import assert from 'node:assert'
3-
import { DomStack } from '../../index.js'
3+
import { testBuild } from '../../index.js'
44
import * as path from 'path'
5-
import { rm, stat, readFile } from 'fs/promises'
5+
import { stat, readFile } from 'fs/promises'
66
import * as cheerio from 'cheerio'
77
import { allFiles } from 'async-folder-walker'
88

@@ -11,12 +11,13 @@ const __dirname = import.meta.dirname
1111
test.describe('general-features', () => {
1212
test('should build site with all features', async (t) => {
1313
const src = path.join(__dirname, './src')
14-
const dest = path.join(__dirname, './public')
15-
const siteUp = new DomStack(src, dest, { copy: [path.join(__dirname, './copyfolder')] })
14+
const build = await testBuild(src, { copy: [path.join(__dirname, './copyfolder')] })
15+
const { dest, results } = build
1616

17-
await rm(dest, { recursive: true, force: true })
17+
t.after(async () => {
18+
await build.cleanup()
19+
})
1820

19-
const results = await siteUp.build()
2021
assert.ok(results, 'DomStack built site and returned build results')
2122

2223
const globalAssets = {

0 commit comments

Comments
 (0)