diff options
| author | YurenHao0426 <blackhao0426@gmail.com> | 2026-09-13 04:24:07 +0000 |
|---|---|---|
| committer | YurenHao0426 <blackhao0426@gmail.com> | 2026-09-13 04:24:07 +0000 |
| commit | a55e313de44444d22ef928b1bb91fd96284ea367 (patch) | |
| tree | 7273cbee484effff4878fa81a8a3313e14695aba /src/cli/test.ts | |
| parent | 55bf3f24c57521907a1bac7180aa29ea8cbf83d7 (diff) | |
Add copy command to clone Overleaf projects server-sidefix-cli-shebang
Adds `lattex-cli copy <source-id|name> <new-name>` which uses
Overleaf's POST /project/{id}/clone endpoint to create a
server-side copy of a project. Includes API method, CLI wiring,
help text, and tests.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/cli/test.ts')
| -rw-r--r-- | src/cli/test.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/cli/test.ts b/src/cli/test.ts index e76182e..f81a89b 100644 --- a/src/cli/test.ts +++ b/src/cli/test.ts @@ -1,5 +1,6 @@ // Tests for CLI arg parsing and diff logic import { parseArgs } from './args' +import { OverleafApi } from './overleafApi' import { walkRootFolder } from './fileTree' import { join } from 'path' import { mkdtemp, writeFile, mkdir, rm } from 'fs/promises' @@ -229,6 +230,28 @@ l.3 \\usepackage{nonexistent}` eq(entries4[0].line, 20, 'overfull line') } +// ── copy command arg parsing test ── + +function testCopyArgs(): void { + console.log('--- copy args ---') + + const r1 = parseArgs(['node', 'cli', 'copy', '6a965e135690947a3be20882', 'My New Project']) + eq(r1.command, 'copy', 'copy command') + eq(r1.positional, ['6a965e135690947a3be20882', 'My New Project'], 'copy positionals') + + const r2 = parseArgs(['node', 'cli', 'copy', 'My Source', 'My Copy', '--json']) + eq(r2.command, 'copy', 'copy command with json') + eq(r2.positional, ['My Source', 'My Copy'], 'copy positionals by name') + eq(r2.flags.json, true, 'json flag with copy') +} + +// ── OverleafApi.copyProject existence test ── + +function testCopyProjectMethod(): void { + console.log('--- copyProject method ---') + assert(typeof OverleafApi.prototype.copyProject === 'function', 'copyProject is a method on OverleafApi') +} + // ── Run all tests ── async function runTests(): Promise<void> { @@ -237,6 +260,8 @@ async function runTests(): Promise<void> { testIsTextFile() await testComputeDiff() testParseCompileLog() + testCopyArgs() + testCopyProjectMethod() console.log(`\n${passed} passed, ${failed} failed`) process.exit(failed > 0 ? 1 : 0) |
