Skip to content

Commit

Permalink
Use array
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie committed Oct 3, 2023
1 parent e6a5ba3 commit f851918
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/test/antoraSupport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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),
}))
}

Expand Down

0 comments on commit f851918

Please sign in to comment.