diff --git a/src/test/antoraSupport.test.ts b/src/test/antoraSupport.test.ts index 73e0469e..c726f9de 100644 --- a/src/test/antoraSupport.test.ts +++ b/src/test/antoraSupport.test.ts @@ -5,7 +5,10 @@ import { findAntoraConfigFile, getAntoraDocumentContext } from '../features/anto import { createDirectories, createDirectory, createFile, createLink, removeFiles } from './workspaceHelper' import { extensionContext } from './helper' -async function testGetAntoraConfig ({ asciidocPathUri, antoraConfigExpectedUri }) { +async function testGetAntoraConfig ({ + asciidocPathUri, + antoraConfigExpectedUri + }) { const antoraConfigUri = await findAntoraConfigFile(asciidocPathUri) if (antoraConfigExpectedUri === undefined) { assert.strictEqual(antoraConfigUri, undefined) @@ -19,52 +22,52 @@ suite('Antora Support', () => { const testCases = [ { title: 'Should return Antora config for document inside "pages" directory which is inside another directory', - asciidocPathSegments: 'antora/multiComponents/cli/modules/commands/pages/page1.adoc', - antoraConfigExpectedPathSegments: 'antora/multiComponents/cli/antora.yml', + asciidocPathSegments: ['antora', 'multiComponents', 'cli', 'modules', 'commands', 'pages', 'page1.adoc'], + antoraConfigExpectedPathSegments: ['antora', 'multiComponents', 'cli', 'antora.yml'], }, { title: 'Should return Antora config for document inside "pages" directory', - asciidocPathSegments: 'antora/multiComponents/api/modules/auth/pages/page3.adoc', - antoraConfigExpectedPathSegments: 'antora/multiComponents/api/antora.yml', + asciidocPathSegments: ['antora', 'multiComponents', 'api', 'modules', 'auth', 'pages', 'page3.adoc'], + antoraConfigExpectedPathSegments: ['antora', 'multiComponents', 'api', 'antora.yml'], }, { title: 'Should return Antora config for document inside a subdirectory', - asciidocPathSegments: 'antora/multiComponents/api/modules/auth/pages/jwt/page2.adoc', - antoraConfigExpectedPathSegments: 'antora/multiComponents/api/antora.yml', + asciidocPathSegments: ['antora', 'multiComponents', 'api', 'modules', 'auth', 'pages', 'jwt', 'page2.adoc'], + antoraConfigExpectedPathSegments: ['antora', 'multiComponents', 'api', 'antora.yml'], }, { title: 'Should return Antora config for document inside a "modules" subdirectory', - asciidocPathSegments: 'antora/multiComponents/api/modules/auth/pages/modules/page4.adoc', - antoraConfigExpectedPathSegments: 'antora/multiComponents/api/antora.yml', + asciidocPathSegments: ['antora', 'multiComponents', 'api', 'modules', 'auth', 'pages', 'modules', 'page4.adoc'], + antoraConfigExpectedPathSegments: ['antora', 'multiComponents', 'api', 'antora.yml'], }, { title: 'Should return Antora config for document inside a "modules" directory which is inside an Antora modules in a component named "modules"', - asciidocPathSegments: 'antora/multiComponents/modules/api/docs/modules/asciidoc/pages/modules/page5.adoc', - antoraConfigExpectedPathSegments: 'antora/multiComponents/modules/api/docs/antora.yml', + asciidocPathSegments: ['antora', 'multiComponents', 'modules', 'api', 'docs', 'modules', 'asciidoc', 'pages', 'modules', 'page5.adoc'], + antoraConfigExpectedPathSegments: ['antora', 'multiComponents', 'modules', 'api', 'docs', 'antora.yml'], }, { title: 'Should return Antora config for document inside a directory which has the same name as the workspace', - asciidocPathSegments: 'antora/multiComponents/api/modules/auth/pages/modules/multiComponents/page6.adoc', - antoraConfigExpectedPathSegments: 'antora/multiComponents/api/antora.yml', + asciidocPathSegments: ['antora', 'multiComponents', 'api', 'modules', 'auth', 'pages', 'modules', 'multiComponents', 'page6.adoc'], + antoraConfigExpectedPathSegments: ['antora', 'multiComponents', 'api', 'antora.yml'], }, { title: 'Should not return Antora config for document outside "modules" Antora folder', - asciidocPathSegments: 'antora/multiComponents/api/modules/writer-guide.adoc', + asciidocPathSegments: ['antora', 'multiComponents', 'api', 'modules', 'writer-guide.adoc'], antoraConfigExpectedPathSegments: undefined, }, { title: 'Should not return Antora config for document outside of workspace', - asciidocPathSegments: 'antora/contributing.adoc', + asciidocPathSegments: ['antora', 'contributing.adoc'], antoraConfigExpectedPathSegments: undefined, }, ] for (const testCase of testCases) { test(testCase.title, async () => testGetAntoraConfig({ - asciidocPathUri: vscode.Uri.joinPath(workspaceUri, testCase.asciidocPathSegments), + asciidocPathUri: vscode.Uri.joinPath(workspaceUri, ...testCase.asciidocPathSegments), antoraConfigExpectedUri: testCase.antoraConfigExpectedPathSegments === undefined ? undefined - : vscode.Uri.joinPath(workspaceUri, testCase.antoraConfigExpectedPathSegments), + : vscode.Uri.joinPath(workspaceUri, ...testCase.antoraConfigExpectedPathSegments), })) }