adb_cli/tests/adbArgs.test.ts
2026-09-07 16:16:22 +08:00

20 lines
917 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, expect, it } from 'vitest';
import { buildAdbArgs } from '../src/adb/adbClient.js';
describe('buildAdbArgs(-s 注入规则,delivery D2)', () => {
it('deviceScoped 命令且有目标设备时注入 -s', () => {
expect(buildAdbArgs({ name: 'push', deviceScoped: true }, ['a.txt', '/sdcard/'], 'emulator-5554'))
.toEqual(['-s', 'emulator-5554', 'push', 'a.txt', '/sdcard/']);
});
it('connect 不注入 -s(作用于 adb server)', () => {
expect(buildAdbArgs({ name: 'connect', deviceScoped: false }, ['192.168.1.8:5555'], 'emulator-5554'))
.toEqual(['connect', '192.168.1.8:5555']);
});
it('deviceScoped 命令但无目标设备时不注入 -s', () => {
expect(buildAdbArgs({ name: 'root', deviceScoped: true }, [], null)).toEqual(['root']);
expect(buildAdbArgs({ name: 'remount', deviceScoped: true }, [], undefined)).toEqual(['remount']);
});
});