From f3c1738abb53f18dcefb75390113205d2d318c73 Mon Sep 17 00:00:00 2001 From: Alvis HT Tang Date: Thu, 14 Jul 2022 22:55:47 +0100 Subject: [PATCH] fix(presetter): resolve presets as a tree not a list --- spec/index.spec.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/spec/index.spec.ts b/spec/index.spec.ts index e216991..2c4ef62 100644 --- a/spec/index.spec.ts +++ b/spec/index.spec.ts @@ -15,7 +15,7 @@ import { readdirSync } from 'fs'; import { resolve } from 'path'; -import { resolveContext, resolveDynamicMap } from 'presetter'; +import { loadDynamicMap, resolveContext } from 'presetter'; import getPresetAsset from '#index'; @@ -27,15 +27,18 @@ jest.mock('path', () => ({ describe('fn:getPresetAsset', () => { it('use all templates', async () => { - const assets = [await getPresetAsset()]; - const context = await resolveContext(assets, { - target: { name: 'preset', root: '/', package: {} }, - custom: { preset: 'preset' }, + const asset = await getPresetAsset(); + const context = await resolveContext({ + graph: [{ name: 'preset', asset, nodes: [] }], + context: { + target: { name: 'preset', root: '/', package: {} }, + custom: { preset: 'preset' }, + }, }); // load all potential dynamic content - await resolveDynamicMap(assets, context, 'supplementaryConfig'); - await resolveDynamicMap(assets, context, 'template'); + await loadDynamicMap(asset.supplementaryConfig, context); + await loadDynamicMap(asset.template, context); const TEMPLATES = resolve(__dirname, '..', 'templates'); const allTemplates = await readdirSync(TEMPLATES);