import { expect } from 'chai';
import { describe, it } from 'mocha';
/**
* Unit tests for sheet_sql tool schema validation
*
* Tests the tool schema without requiring authentication or server infrastructure.
*/
describe('SheetSqlTool Schema Tests', () => {
const expectedSchema = {
name: 'sheet_sql',
requiredParams: ['spreadsheetId', 'range', 'statement'],
optionalParams: ['returnMetadata']
};
it('should have correct tool name', function() {
expect(expectedSchema.name).to.equal('sheet_sql');
});
it('should require spreadsheetId parameter', function() {
expect(expectedSchema.requiredParams).to.include('spreadsheetId');
});
it('should require range parameter for multi-sheet support', function() {
expect(expectedSchema.requiredParams).to.include('range');
});
it('should require statement parameter', function() {
expect(expectedSchema.requiredParams).to.include('statement');
});
it('should have optional returnMetadata parameter', function() {
expect(expectedSchema.optionalParams).to.include('returnMetadata');
});
it('should have exactly 3 required parameters', function() {
expect(expectedSchema.requiredParams).to.have.length(3);
});
});
/**
* Example usage documentation tests
*/
describe('SheetSqlTool Usage Examples', () => {
const exampleRanges = [
'Transactions!A:Z',
'Sheet1!A1:Z1000',
'Sales!A:F',
'Customers!A1:D100'
];
const exampleStatements = {
select: 'SELECT A, B, COUNT(C) WHERE D > 1000 GROUP BY A, B ORDER BY COUNT(C) DESC',
selectText: 'SELECT * WHERE B contains "Premium" LIMIT 100',
insert: 'INSERT VALUES ("John", "Doe", 30, "Premium")',
update: 'UPDATE SET C = "Premium", D = 100 WHERE E > 50',
delete: 'DELETE WHERE A < DATE "2020-01-01"'
};
it('should support sheet name in range format', function() {
exampleRanges.forEach(range => {
expect(range).to.match(/^[A-Za-z0-9_\s]+!/);
});
});
it('should have SELECT statement examples', function() {
expect(exampleStatements.select).to.match(/^SELECT/);
expect(exampleStatements.selectText).to.match(/^SELECT/);
});
it('should have INSERT statement example', function() {
expect(exampleStatements.insert).to.match(/^INSERT VALUES/);
});
it('should have UPDATE statement example', function() {
expect(exampleStatements.update).to.match(/^UPDATE SET .* WHERE/);
});
it('should have DELETE statement example', function() {
expect(exampleStatements.delete).to.match(/^DELETE WHERE/);
});
it('should use column letters in statements', function() {
// All statements should use column letters (A, B, C) not column names
const allStatements = Object.values(exampleStatements).join(' ');
expect(allStatements).to.match(/[A-Z](?:\s|,|>|<|=)/); // Column letters used
expect(allStatements).not.to.match(/SELECT name|WHERE name|SET name/i); // No column names
});
});
console.log('\nā
Schema validation tests complete');
console.log('š Range parameter is REQUIRED for multi-sheet workbook support');
console.log('š¤ Uses column letters (A, B, C) instead of column names');
console.log('š Supports SELECT, INSERT, UPDATE, DELETE operations');