This commit is contained in:
@@ -82,8 +82,8 @@ describe('search command', () => {
|
||||
const searchSpy = vi.spyOn(TwitterClient.prototype, 'search').mockResolvedValue({ success: true, tweets: [] });
|
||||
|
||||
try {
|
||||
await program.parseAsync(['node', 'bird', 'search', 'cats', '--all', '--json']);
|
||||
expect(getAllSpy).toHaveBeenCalledWith('cats', expect.objectContaining({ includeRaw: false }));
|
||||
await program.parseAsync(['node', 'bird', 'search', 'cats', '--all', '--json', '--product', 'Top']);
|
||||
expect(getAllSpy).toHaveBeenCalledWith('cats', expect.objectContaining({ includeRaw: false, product: 'Top' }));
|
||||
expect(searchSpy).not.toHaveBeenCalled();
|
||||
expect(mockContext.printTweetsResult).toHaveBeenCalledWith(expect.objectContaining({ tweets: [] }), {
|
||||
json: true,
|
||||
@@ -96,6 +96,30 @@ describe('search command', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('passes --product to non-paged search', async () => {
|
||||
registerSearchCommands(program, mockContext as CliContext);
|
||||
const searchSpy = vi.spyOn(TwitterClient.prototype, 'search').mockResolvedValue({ success: true, tweets: [] });
|
||||
|
||||
try {
|
||||
await program.parseAsync(['node', 'bird', 'search', 'cats', '--product', 'Top']);
|
||||
expect(searchSpy).toHaveBeenCalledWith('cats', 10, {
|
||||
includeRaw: false,
|
||||
product: 'Top',
|
||||
});
|
||||
} finally {
|
||||
searchSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it('rejects unsupported search products', async () => {
|
||||
program.exitOverride();
|
||||
registerSearchCommands(program, mockContext as CliContext);
|
||||
|
||||
await expect(program.parseAsync(['node', 'bird', 'search', 'cats', '--product', 'Media'])).rejects.toMatchObject({
|
||||
code: 'commander.invalidArgument',
|
||||
});
|
||||
});
|
||||
|
||||
it('uses cursor pagination when --cursor is set', async () => {
|
||||
registerSearchCommands(program, mockContext as CliContext);
|
||||
const getAllSpy = vi
|
||||
|
||||
Reference in New Issue
Block a user