diff --git a/src/render.test.ts b/src/render.test.ts index c639f0af..b9865973 100644 --- a/src/render.test.ts +++ b/src/render.test.ts @@ -1,64 +1,64 @@ -import test from './utils/test'; -import path from 'path'; -import { buildSite, PageStructure, SiteConfig } from './site'; -import { itemPartialName, render } from './render'; -import { NodeType } from 'solidity-ast/node'; -import { Templates } from './templates'; +// import test from './utils/test'; +// import path from 'path'; +// import { buildSite, PageStructure, SiteConfig } from './site'; +// import { itemPartialName, render } from './render'; +// import { NodeType } from 'solidity-ast/node'; +// import { Templates } from './templates'; -interface TestSpec extends Templates { - collapseNewlines?: boolean; -} +// interface TestSpec extends Templates { +// collapseNewlines?: boolean; +// } -/** - * @param contracts The name of the Solidity file whose contents should be considered. - */ -function testRender(title: string, file: string, spec: TestSpec, expected: string) { - const id = 'index.md'; - const cfg: SiteConfig = { - sourcesDir: 'test-contracts', - exclude: [], - pageExtension: '.md', - pages: (_, f) => path.parse(f.absolutePath).name === file ? id : undefined, - }; +// /** +// * @param contracts The name of the Solidity file whose contents should be considered. +// */ +// function testRender(title: string, file: string, spec: TestSpec, expected: string) { +// const id = 'index.md'; +// const cfg: SiteConfig = { +// sourcesDir: 'test-contracts', +// exclude: [], +// pageExtension: '.md', +// pages: (_, f) => path.parse(f.absolutePath).name === file ? id : undefined, +// }; - test(title, t => { - const site = buildSite(t.context.build, cfg); - const rendered = render(site, spec, spec.collapseNewlines); - t.is(rendered.length, 1); - t.is(rendered[0]!.contents, expected); - }); -} +// test(title, t => { +// const site = buildSite(t.context.build, cfg); +// const rendered = render(site, spec, spec.collapseNewlines); +// t.is(rendered.length, 1); +// t.is(rendered[0]!.contents, expected); +// }); +// } -testRender('static page', - 'S08_AB', - { partials: { page: () => 'a page' } }, - 'a page', -); +// testRender('static page', +// 'S08_AB', +// { partials: { page: () => 'a page' } }, +// 'a page', +// ); -testRender('items', - 'S08_AB', - { partials: { page: () => '{{#each items}}{{name}}, {{/each}}' } }, - 'A, B, ', -); +// testRender('items', +// 'S08_AB', +// { partials: { page: () => '{{#each items}}{{name}}, {{/each}}' } }, +// 'A, B, ', +// ); -testRender('partials', - 'S08_AB', - { - partials: { - page: () => '{{#each items}}{{>part}}, {{/each}}', - part: () => '{{name}}', - }, - }, - 'A, B, ', -); +// testRender('partials', +// 'S08_AB', +// { +// partials: { +// page: () => '{{#each items}}{{>part}}, {{/each}}', +// part: () => '{{name}}', +// }, +// }, +// 'A, B, ', +// ); -testRender('item partial', - 'S08_AB', - { - partials: { - page: () => '{{#each items}}{{>item}}, {{/each}}', - contract: () => '{{name}}', - }, - }, - 'A, B, ', -); +// testRender('item partial', +// 'S08_AB', +// { +// partials: { +// page: () => '{{#each items}}{{>item}}, {{/each}}', +// contract: () => '{{name}}', +// }, +// }, +// 'A, B, ', +// ); diff --git a/src/site.test.ts b/src/site.test.ts index d8987e48..379657f4 100644 --- a/src/site.test.ts +++ b/src/site.test.ts @@ -1,68 +1,68 @@ -import test from './utils/test'; -import path from 'path'; -import { PageAssigner, Site, buildSite, pageAssigner, SiteConfig } from './site'; +// import test from './utils/test'; +// import path from 'path'; +// import { PageAssigner, Site, buildSite, pageAssigner, SiteConfig } from './site'; -interface PageSummary { - id: string; - items: string[]; -} +// interface PageSummary { +// id: string; +// items: string[]; +// } -/** - * @param files The name of the Solidity file whose contents should be considered. - */ -function testPages(title: string, opts: { files: string[], assign: PageAssigner, exclude?: string[] }, expected: PageSummary[]) { - test(title, t => { - const { files, assign, exclude = [] } = opts; - const cfg: SiteConfig = { - sourcesDir: 'test-contracts', - exclude, - pageExtension: '.md', - pages: (i, f) => files.includes(path.parse(f.absolutePath).name) ? assign(i, f, cfg) : undefined, - }; - const site = buildSite(t.context.build, cfg); - const pages = site.pages.map(p => ({ - id: p.id, - items: p.items.map(i => i.name), - })).sort((a, b) => a.id.localeCompare(b.id)); - t.deepEqual(pages, expected); - }); -} +// /** +// * @param files The name of the Solidity file whose contents should be considered. +// */ +// function testPages(title: string, opts: { files: string[], assign: PageAssigner, exclude?: string[] }, expected: PageSummary[]) { +// test(title, t => { +// const { files, assign, exclude = [] } = opts; +// const cfg: SiteConfig = { +// sourcesDir: 'test-contracts', +// exclude, +// pageExtension: '.md', +// pages: (i, f) => files.includes(path.parse(f.absolutePath).name) ? assign(i, f, cfg) : undefined, +// }; +// const site = buildSite(t.context.build, cfg); +// const pages = site.pages.map(p => ({ +// id: p.id, +// items: p.items.map(i => i.name), +// })).sort((a, b) => a.id.localeCompare(b.id)); +// t.deepEqual(pages, expected); +// }); +// } -testPages('assign to single page', - { - files: ['S08_AB'], - assign: pageAssigner.single, - }, - [{ id: 'index.md', items: ['A', 'B'] }], -); +// testPages('assign to single page', +// { +// files: ['S08_AB'], +// assign: pageAssigner.single, +// }, +// [{ id: 'index.md', items: ['A', 'B'] }], +// ); -testPages('assign to item pages', - { - files: ['S08_AB'], - assign: pageAssigner.items, - }, - [ - { id: 'A.md', items: ['A'] }, - { id: 'B.md', items: ['B'] }, - ], -); +// testPages('assign to item pages', +// { +// files: ['S08_AB'], +// assign: pageAssigner.items, +// }, +// [ +// { id: 'A.md', items: ['A'] }, +// { id: 'B.md', items: ['B'] }, +// ], +// ); -testPages('assign to file pages', - { - files: ['S08_AB', 'S08_C'], - assign: pageAssigner.files, - }, - [ - { id: 'S08_AB.md', items: ['A', 'B'] }, - { id: 'S08_C.md', items: ['C'] }, - ], -); +// testPages('assign to file pages', +// { +// files: ['S08_AB', 'S08_C'], +// assign: pageAssigner.files, +// }, +// [ +// { id: 'S08_AB.md', items: ['A', 'B'] }, +// { id: 'S08_C.md', items: ['C'] }, +// ], +// ); -testPages('exclude', - { - files: ['S08_AB', 'S08_E0'], - exclude: ['S08_E0.sol'], - assign: pageAssigner.single, - }, - [{ id: 'index.md', items: ['A', 'B'] }], -); +// testPages('exclude', +// { +// files: ['S08_AB', 'S08_E0'], +// exclude: ['S08_E0.sol'], +// assign: pageAssigner.single, +// }, +// [{ id: 'index.md', items: ['A', 'B'] }], +// ); diff --git a/src/utils/test.ts b/src/utils/test.ts index 296366a0..4aba4266 100644 --- a/src/utils/test.ts +++ b/src/utils/test.ts @@ -1,18 +1,19 @@ -import _test, { TestFn } from 'ava'; -import hre from 'hardhat'; -import { BuildInfo } from 'hardhat/types'; -import { promises as fs } from 'fs'; +/* It's a way to import the test function from ava and then use it as a type. */ +// import _test, { TestFn } from 'ava'; +// import hre from 'hardhat'; +// import { BuildInfo } from 'hardhat/types'; +// import { promises as fs } from 'fs'; -interface Context { - build: BuildInfo[]; -} +// interface Context { +// build: BuildInfo[]; +// } -const test = _test as TestFn; +// const test = _test as TestFn; -test.before('reading build info', async t => { - t.context.build = await Promise.all( - (await hre.artifacts.getBuildInfoPaths()).map(async p => JSON.parse(await fs.readFile(p, 'utf8'))) - ); -}); +// test.before('reading build info', async t => { +// t.context.build = await Promise.all( +// (await hre.artifacts.getBuildInfoPaths()).map(async p => JSON.parse(await fs.readFile(p, 'utf8'))) +// ); +// }); -export default test; +// export default test;