32 lines
1.4 KiB
JavaScript
32 lines
1.4 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
const root = path.resolve(import.meta.dirname, "../../..");
|
|
const templateKeys = fs
|
|
.readdirSync(path.join(root, "packages"))
|
|
.filter((directory) => directory.startsWith("template-"))
|
|
.filter((directory) => fs.existsSync(path.join(root, "packages", directory, "template.json")))
|
|
.map((directory) => directory.slice("template-".length))
|
|
.sort();
|
|
|
|
for (const key of templateKeys)
|
|
test(`${key} 两端产物有真实入口及模板导航`, () => {
|
|
const manifest = JSON.parse(
|
|
fs.readFileSync(path.join(root, `packages/template-${key}/template.json`)),
|
|
);
|
|
const base = path.join(root, `apps/taro/dist/${key}`);
|
|
const config = JSON.parse(fs.readFileSync(path.join(base, "weapp/app.json")));
|
|
assert.equal(config.pages.length, 8);
|
|
assert.deepEqual(
|
|
config.tabBar.list.map((item) => item.text),
|
|
manifest.navigation.map((item) => item.label),
|
|
);
|
|
for (const page of config.pages)
|
|
for (const ext of ["js", "wxml", "json"])
|
|
assert.ok(fs.existsSync(path.join(base, "weapp", `${page}.${ext}`)), `${page}.${ext}`);
|
|
assert.ok(fs.readFileSync(path.join(base, "h5/index.html"), "utf8").includes('type="module"'));
|
|
assert.ok(fs.existsSync(path.join(base, "weapp/project.config.json")));
|
|
assert.ok(fs.readFileSync(path.join(base, "weapp/common.wxss"), "utf8").length > 1000);
|
|
});
|