forked from lightningpixel/modly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextensionsStore.test.mjs
More file actions
49 lines (45 loc) · 1.46 KB
/
Copy pathextensionsStore.test.mjs
File metadata and controls
49 lines (45 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import test from 'node:test'
import assert from 'node:assert/strict'
import { buildSync } from 'esbuild'
import { createRequire } from 'node:module'
import { mkdtempSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
function loadModule() {
const outfile = join(mkdtempSync(join(tmpdir(), 'modly-ext-store-test-')), 'extensionsStore.cjs')
const require = createRequire(import.meta.url)
const result = buildSync({
entryPoints: [resolve('src/shared/stores/extensionsStore.ts')],
bundle: true,
platform: 'node',
format: 'cjs',
write: false,
})
writeFileSync(outfile, result.outputFiles[0].text, 'utf8')
return require(outfile)
}
test('extension list keeps an interrupted model in the model store with recovery metadata', () => {
const { partitionExtensionsByType } = loadModule()
const pendingModel = {
type: 'model',
id: 'pixal3d',
name: 'Pixal3D',
trusted: false,
builtin: false,
nodes: [{ id: 'generate' }],
corrupted: true,
manifestError: 'incomplete',
}
const processExtension = {
type: 'process',
id: 'mesh-tool',
name: 'Mesh Tool',
trusted: false,
builtin: false,
entry: 'processor.js',
nodes: [{ id: 'simplify' }],
}
const result = partitionExtensionsByType([pendingModel, processExtension])
assert.deepEqual(result.modelExtensions, [pendingModel])
assert.deepEqual(result.processExtensions, [processExtension])
})