|
| 1 | +if (typeof exports === 'object') { |
| 2 | + var assert = require('assert'); |
| 3 | + var alasql = require('..'); |
| 4 | + var fs = require('fs'); |
| 5 | + var path = require('path'); |
| 6 | +} |
| 7 | + |
| 8 | +describe('Test 2317 - TypeScript type resolution via exports map', function () { |
| 9 | + const test = '2317'; // insert test file number |
| 10 | + |
| 11 | + it('A) package.json should have types in exports map', function () { |
| 12 | + // Read package.json |
| 13 | + const packageJsonPath = path.join(__dirname, '..', 'package.json'); |
| 14 | + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); |
| 15 | + |
| 16 | + // Verify exports field exists |
| 17 | + assert.ok(packageJson.exports, 'package.json should have exports field'); |
| 18 | + |
| 19 | + // Verify main export has types field |
| 20 | + assert.ok(packageJson.exports['.'], 'package.json exports should have "." entry'); |
| 21 | + assert.ok(packageJson.exports['.'].types, 'package.json exports["."] should have types field'); |
| 22 | + |
| 23 | + // Verify types field points to correct file |
| 24 | + assert.strictEqual( |
| 25 | + packageJson.exports['.'].types, |
| 26 | + './types/alasql.d.ts', |
| 27 | + 'types field should point to ./types/alasql.d.ts' |
| 28 | + ); |
| 29 | + }); |
| 30 | + |
| 31 | + it('B) types file should exist', function () { |
| 32 | + // Verify the types file actually exists |
| 33 | + const typesFilePath = path.join(__dirname, '..', 'types', 'alasql.d.ts'); |
| 34 | + assert.ok(fs.existsSync(typesFilePath), 'types/alasql.d.ts should exist'); |
| 35 | + }); |
| 36 | + |
| 37 | + it('C) alasql import should work (runtime verification)', function () { |
| 38 | + // Basic runtime check that alasql still works |
| 39 | + var res = alasql('SELECT 1 as one'); |
| 40 | + assert.deepEqual(res, [{one: 1}]); |
| 41 | + }); |
| 42 | +}); |
0 commit comments