UNPKG

meld-spec

Version:

Specification for the Meld scripting language

225 lines (224 loc) 6.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.importTests = void 0; /** * Test cases for the @import directive that all implementations must pass */ exports.importTests = [ // Basic import { name: 'basic-import', input: '@import [file.md]', expected: { type: 'Directive', directive: { kind: 'import', path: { raw: 'file.md', structured: { base: '.', segments: ['file.md'], variables: {}, cwd: true } } } }, description: 'Basic file import' }, // Import with nested brackets { name: 'nested-brackets', input: '@import [path/with [brackets].md]', expected: { type: 'Directive', directive: { kind: 'import', path: { raw: 'path/with [brackets].md', structured: { base: '.', segments: ['path', 'with [brackets].md'], variables: {}, cwd: false } } } }, description: 'Import path with nested brackets' }, // Import with text variable { name: 'text-variable', input: '@import [${file_path}]', expected: { type: 'Directive', directive: { kind: 'import', path: { raw: '${file_path}', structured: { base: '.', segments: ['${file_path}'], variables: { text: ['file_path'] }, cwd: true } } } }, description: 'Import with text variable' }, // Import with path variable { name: 'path-variable', input: '@import [$file]', expected: { type: 'Directive', directive: { kind: 'import', path: { raw: '$file', structured: { base: '.', segments: ['$file'], variables: { path: ['file'] }, cwd: true } } } }, description: 'Import with path variable' }, // Import with special path variables { name: 'home-path', input: '@import [$HOMEPATH/docs/file.md]', expected: { type: 'Directive', directive: { kind: 'import', path: { raw: '$HOMEPATH/docs/file.md', structured: { base: '$HOMEPATH', segments: ['docs', 'file.md'], variables: { special: ['HOMEPATH'] } } } } }, description: 'Import with HOMEPATH variable' }, // Import with home alias { name: 'home-alias', input: '@import [$~/docs/file.md]', expected: { type: 'Directive', directive: { kind: 'import', path: { raw: '$~/docs/file.md', structured: { base: '$~', segments: ['docs', 'file.md'], variables: { special: ['HOMEPATH'] } } } } }, description: 'Import with ~ alias for HOMEPATH' }, // Import with project path { name: 'project-path', input: '@import [$PROJECTPATH/src/file.md]', expected: { type: 'Directive', directive: { kind: 'import', path: { raw: '$PROJECTPATH/src/file.md', structured: { base: '$PROJECTPATH', segments: ['src', 'file.md'], variables: { special: ['PROJECTPATH'] } } } } }, description: 'Import with PROJECTPATH variable' }, // Import with project alias { name: 'project-alias', input: '@import [$./src/file.md]', expected: { type: 'Directive', directive: { kind: 'import', path: { raw: '$./src/file.md', structured: { base: '$.', segments: ['src', 'file.md'], variables: { special: ['PROJECTPATH'] } } } } }, description: 'Import with . alias for PROJECTPATH' }, // Import with relative paths { name: 'relative-path', input: '@import [../parent/file.md]', expected: { type: 'Directive', directive: { kind: 'import', path: { raw: '../parent/file.md', structured: { base: '..', segments: ['parent', 'file.md'], variables: {} } } } }, description: 'Import with relative path' }, // Import with current directory { name: 'current-dir', input: '@import [./current/file.md]', expected: { type: 'Directive', directive: { kind: 'import', path: { raw: './current/file.md', structured: { base: '.', segments: ['current', 'file.md'], variables: {} } } } }, description: 'Import with current directory path' } ];