Skip to content

Commit

Permalink
fix: Adds tools exports to main index and also a few tests. (#151)
Browse files Browse the repository at this point in the history
fix: Adds tools exports to main index and also a few tests.
  • Loading branch information
darielnoel authored Nov 15, 2024
2 parents 59383e5 + fc25a8e commit 5301050
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/tools/src/exa/tool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,19 @@ describe('ExaSearch', () => {
const result = await tool._call({ query: 'test query' });
expect(result).toBe('An unexpected error occurred: Network Error');
});

test('ExaSearch is exported correctly in both paths', () => {
const { ExaSearch } = require('../../dist/exa/index.cjs.js');
const { ExaSearch: ExaSearchMain } = require('../../dist/index.cjs.js');

// Check that both imports are constructor functions
expect(typeof ExaSearch).toBe('function');
expect(typeof ExaSearchMain).toBe('function');

// Check they have the same name and properties
expect(ExaSearch.name).toBe(ExaSearchMain.name);
expect(Object.keys(ExaSearch.prototype)).toEqual(
Object.keys(ExaSearchMain.prototype)
);
});
});
15 changes: 15 additions & 0 deletions packages/tools/src/firecrawl/tool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,19 @@ describe('Firecrawl', () => {

expect(result).toBe('An unexpected error occurred: Network Error');
});

test('Firecrawl is exported correctly in both paths', () => {
const { Firecrawl } = require('../../dist/firecrawl/index.cjs.js');
const { Firecrawl: FirecrawlMain } = require('../../dist/index.cjs.js');

// Check that both imports are constructor functions
expect(typeof Firecrawl).toBe('function');
expect(typeof FirecrawlMain).toBe('function');

// Check they have the same name and properties
expect(Firecrawl.name).toBe(FirecrawlMain.name);
expect(Object.keys(Firecrawl.prototype)).toEqual(
Object.keys(FirecrawlMain.prototype)
);
});
});
17 changes: 17 additions & 0 deletions packages/tools/src/github-issues/tool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,21 @@ describe('GithubIssues', () => {
});
}
});

test('GithubIssues is exported correctly in both paths', () => {
const { GithubIssues } = require('../../dist/github-issues/index.cjs.js');
const {
GithubIssues: GithubIssuesMain,
} = require('../../dist/index.cjs.js');

// Check that both imports are constructor functions
expect(typeof GithubIssues).toBe('function');
expect(typeof GithubIssuesMain).toBe('function');

// Check they have the same name and properties
expect(GithubIssues.name).toBe(GithubIssuesMain.name);
expect(Object.keys(GithubIssues.prototype)).toEqual(
Object.keys(GithubIssuesMain.prototype)
);
});
});
4 changes: 4 additions & 0 deletions packages/tools/src/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
export * from './firecrawl/index.js';
export * from './tavily/index.js';
export * from './github-issues/index.js';
export * from './serper/index.js';
export * from './wolfram-alpha/index.js';
export * from './exa/index.js';
15 changes: 15 additions & 0 deletions packages/tools/src/serper/tool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,19 @@ describe('Serper', () => {

expect(result).toBe('An unexpected error occurred: Network Error');
});

test('Serper is exported correctly in both paths', () => {
const { Serper } = require('../../dist/serper/index.cjs.js');
const { Serper: SerperMain } = require('../../dist/index.cjs.js');

// Check that both imports are constructor functions
expect(typeof Serper).toBe('function');
expect(typeof SerperMain).toBe('function');

// Check they have the same name and properties
expect(Serper.name).toBe(SerperMain.name);
expect(Object.keys(Serper.prototype)).toEqual(
Object.keys(SerperMain.prototype)
);
});
});
17 changes: 17 additions & 0 deletions packages/tools/src/tavily/tool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,21 @@ describe('TavilySearchResults', () => {

expect(result).toBe('An unexpected error occurred: Network Error');
});

test('TavilySearchResults is exported correctly in both paths', () => {
const { TavilySearchResults } = require('../../dist/tavily/index.cjs.js');
const {
TavilySearchResults: TavilySearchResultsMain,
} = require('../../dist/index.cjs.js');

// Check that both imports are constructor functions
expect(typeof TavilySearchResults).toBe('function');
expect(typeof TavilySearchResultsMain).toBe('function');

// Check they have the same name and properties
expect(TavilySearchResults.name).toBe(TavilySearchResultsMain.name);
expect(Object.keys(TavilySearchResults.prototype)).toEqual(
Object.keys(TavilySearchResultsMain.prototype)
);
});
});
19 changes: 19 additions & 0 deletions packages/tools/src/wolfram-alpha/tool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,23 @@ describe('WolframAlphaTool', () => {
new WolframAlphaTool();
}).toThrow();
});

test('WolframAlphaTool is exported correctly in both paths', () => {
const {
WolframAlphaTool,
} = require('../../dist/wolfram-alpha/index.cjs.js');
const {
WolframAlphaTool: WolframAlphaToolMain,
} = require('../../dist/index.cjs.js');

// Check that both imports are constructor functions
expect(typeof WolframAlphaTool).toBe('function');
expect(typeof WolframAlphaToolMain).toBe('function');

// Check they have the same name and properties
expect(WolframAlphaTool.name).toBe(WolframAlphaToolMain.name);
expect(Object.keys(WolframAlphaTool.prototype)).toEqual(
Object.keys(WolframAlphaToolMain.prototype)
);
});
});

0 comments on commit 5301050

Please sign in to comment.