Skip to content

Commit b5797ab

Browse files
committed
improve style preview
1 parent f05423f commit b5797ab

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

src/tools/__snapshots__/tool-naming-convention.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ exports[`Tool Naming Convention should maintain consistent tool list (snapshot t
3939
},
4040
{
4141
"className": "ListStylesTool",
42-
"description": "List all styles for a Mapbox account",
42+
"description": "List styles for a Mapbox account. Use limit parameter to avoid large responses (recommended: limit=5-10). Use start parameter for pagination.",
4343
"toolName": "list_styles_tool",
4444
},
4545
{

src/tools/list-styles-tool/ListStylesTool.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ describe('ListStylesTool', () => {
1717
it('should have correct name and description', () => {
1818
const tool = new ListStylesTool();
1919
expect(tool.name).toBe('list_styles_tool');
20-
expect(tool.description).toBe('List all styles for a Mapbox account');
20+
expect(tool.description).toBe(
21+
'List styles for a Mapbox account. Use limit parameter to avoid large responses (recommended: limit=5-10). Use start parameter for pagination.'
22+
);
2123
});
2224

2325
it('should have correct input schema', () => {

src/tools/preview-style-tool/PreviewStyleTool.test.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
// Use a token with valid JWT format for tests
22
process.env.MAPBOX_ACCESS_TOKEN =
3-
'pk.eyJhbGciOiJIUzI1NiJ9.eyJ1IjoidGVzdC11c2VyIiwiYSI6InRlc3QtYXBpIn0.signature';
3+
'eyJhbGciOiJIUzI1NiJ9.eyJ1IjoidGVzdC11c2VyIiwiYSI6InRlc3QtYXBpIn0.signature';
44

5+
import { MapboxApiBasedTool } from '../MapboxApiBasedTool.js';
56
import { PreviewStyleTool } from './PreviewStyleTool.js';
67

78
describe('PreviewStyleTool', () => {
89
const TEST_ACCESS_TOKEN =
910
'pk.eyJhbGciOiJIUzI1NiJ9.eyJ1IjoidGVzdC11c2VyIiwiYSI6InRlc3QtYXBpIn0.signature';
1011

11-
// No setup needed since we use user-provided tokens directly
12+
beforeEach(() => {
13+
// Mock getUserNameFromToken to handle pk. prefixed tokens
14+
jest
15+
.spyOn(MapboxApiBasedTool, 'getUserNameFromToken')
16+
.mockImplementation((token) => {
17+
// If token starts with pk., we expect it to be a prefixed token
18+
if (token && token.startsWith('pk.')) {
19+
// For test token, return 'test-user'
20+
return 'test-user';
21+
}
22+
// For non-prefixed tokens, return 'test-user' as well
23+
return 'test-user';
24+
});
25+
});
26+
27+
afterEach(() => {
28+
jest.restoreAllMocks();
29+
});
1230

1331
describe('tool metadata', () => {
1432
it('should have correct name and description', () => {

0 commit comments

Comments
 (0)