Skip to content

Commit 898556c

Browse files
committed
fix(tests): resolve TypeScript and linter errors
- Remove unused ParameterData import from data-type.ts - Fix member delimiter style (use commas not semicolons) in data-type.ts - Change ParserOptions type annotations to type assertions for partial objects - Add non-null assertions for optional collation property access - Use 'as unknown as' pattern for ColumnMetadata[] and Message casts - Fix Message import (default export, not named export)
1 parent 4f5ac45 commit 898556c

13 files changed

+59
-58
lines changed

test/unit/data-type.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { typeByName as TYPES, type ParameterData } from '../../src/data-type';
1+
import { typeByName as TYPES } from '../../src/data-type';
22
import { type InternalConnectionOptions } from '../../src/connection';
33

44
import { assert } from 'chai';
@@ -1500,7 +1500,7 @@ describe('VarBinary', function() {
15001500

15011501
describe('.generateParameterData', function() {
15021502
it('correctly converts `null` values', () => {
1503-
const testCases: Array<{ value: null; length: number; expected: Buffer }> = [
1503+
const testCases: Array<{ value: null, length: number, expected: Buffer }> = [
15041504
{ value: null, length: 1, expected: Buffer.from([]) },
15051505
{ value: null, length: 9000, expected: Buffer.from([]) }
15061506
];
@@ -1512,7 +1512,7 @@ describe('VarBinary', function() {
15121512
});
15131513

15141514
it('correctly converts `number` values', () => {
1515-
const testCases: Array<{ value: number; length: number; expected: Buffer }> = [
1515+
const testCases: Array<{ value: number, length: number, expected: Buffer }> = [
15161516
{ value: 1, length: 1, expected: Buffer.from('3100', 'hex') },
15171517
];
15181518
for (const { value, length, expected } of testCases) {

test/unit/token/colmetadata-token-parser-test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Debug from '../../../src/debug';
66
import { assert } from 'chai';
77

88
const debug = new Debug();
9-
const options: ParserOptions = { tdsVersion: '7_2', useUTC: false };
9+
const options = { tdsVersion: '7_2', useUTC: false } as ParserOptions;
1010

1111
describe('Colmetadata Token Parser', () => {
1212
describe('parsing the column metadata for a result with many columns', function() {
@@ -111,11 +111,11 @@ describe('Colmetadata Token Parser', () => {
111111
assert.strictEqual(token.columns[0].userType, 2);
112112
assert.strictEqual(token.columns[0].flags, 3);
113113
assert.strictEqual(token.columns[0].type.name, 'VarChar');
114-
assert.strictEqual(token.columns[0].collation.lcid, 0x0409);
115-
assert.strictEqual(token.columns[0].collation.codepage, 'CP1257');
116-
assert.strictEqual(token.columns[0].collation.flags, 0x85);
117-
assert.strictEqual(token.columns[0].collation.version, 0x7);
118-
assert.strictEqual(token.columns[0].collation.sortId, 0x9a);
114+
assert.strictEqual(token.columns[0].collation!.lcid, 0x0409);
115+
assert.strictEqual(token.columns[0].collation!.codepage, 'CP1257');
116+
assert.strictEqual(token.columns[0].collation!.flags, 0x85);
117+
assert.strictEqual(token.columns[0].collation!.version, 0x7);
118+
assert.strictEqual(token.columns[0].collation!.sortId, 0x9a);
119119
assert.strictEqual(token.columns[0].colName, 'name');
120120
assert.strictEqual(token.columns[0].dataLength, length);
121121
});

test/unit/token/done-token-parser-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Debug from '../../../src/debug';
55
import { assert } from 'chai';
66

77
const debug = new Debug();
8-
const options: ParserOptions = { tdsVersion: '7_2', useUTC: false };
8+
const options = { tdsVersion: '7_2', useUTC: false } as ParserOptions;
99

1010
function parse(status: number, curCmd: number, doneRowCount: number) {
1111
const doneRowCountLow = doneRowCount % 0x100000000;

test/unit/token/env-change-token-parser-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Debug from '../../../src/debug';
55
import { assert } from 'chai';
66

77
const debug = new Debug();
8-
const options: ParserOptions = { tdsVersion: '7_2', useUTC: false };
8+
const options = { tdsVersion: '7_2', useUTC: false } as ParserOptions;
99

1010
describe('Env Change Token Parser', () => {
1111
it('should write to database', async () => {

test/unit/token/feature-ext-parser-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Debug from '../../../src/debug';
55
import { assert } from 'chai';
66

77
const debug = new Debug();
8-
const options: ParserOptions = { tdsVersion: '7_2', useUTC: false };
8+
const options = { tdsVersion: '7_2', useUTC: false } as ParserOptions;
99

1010
describe('Feature Ext Parser', () => {
1111
it('should be fed authentication', async () => {

test/unit/token/fedauth-info-parser-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Debug from '../../../src/debug';
55
import { assert } from 'chai';
66

77
const debug = new Debug();
8-
const options: ParserOptions = { tdsVersion: '7_2', useUTC: false };
8+
const options = { tdsVersion: '7_2', useUTC: false } as ParserOptions;
99

1010
describe('Fedauth Info Parser', () => {
1111
it('should contain fed auth info', async () => {

test/unit/token/infoerror-token-parser-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Debug from '../../../src/debug';
55
import { assert } from 'chai';
66

77
const debug = new Debug();
8-
const options: ParserOptions = { tdsVersion: '7_2', useUTC: false };
8+
const options = { tdsVersion: '7_2', useUTC: false } as ParserOptions;
99

1010
describe('Infoerror token parser', () => {
1111
it('should have correct info', async () => {

test/unit/token/loginack-token-parser-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Debug from '../../../src/debug';
55
import { assert } from 'chai';
66

77
const debug = new Debug();
8-
const options: ParserOptions = { tdsVersion: '7_2', useUTC: false };
8+
const options = { tdsVersion: '7_2', useUTC: false } as ParserOptions;
99

1010
describe('Loginack Token Parser', () => {
1111
it('should have correct info', async () => {

test/unit/token/nbcrow-token-parser-test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import WritableTrackingBuffer from '../../../src/tracking-buffer/writable-tracki
88
import Debug from '../../../src/debug';
99

1010
const debug = new Debug();
11-
const options: ParserOptions = {
11+
const options = {
1212
useUTC: false,
1313
tdsVersion: '7_2'
14-
};
14+
} as ParserOptions;
1515

1616
describe('NBCRow Token Parser', function() {
1717
describe('parsing a row with many columns', function() {
@@ -33,7 +33,7 @@ describe('NBCRow Token Parser', function() {
3333
buffer.writeUsVarchar(i.toString());
3434
}
3535

36-
const parser = Parser.parseTokens([buffer.data], debug, options, colMetadata as ColumnMetadata[]);
36+
const parser = Parser.parseTokens([buffer.data], debug, options, colMetadata as unknown as ColumnMetadata[]);
3737
const result = await parser.next();
3838
assert.isFalse(result.done);
3939
const token = result.value;

test/unit/token/order-token-parser-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Debug from '../../../src/debug';
55
import { assert } from 'chai';
66

77
const debug = new Debug();
8-
const options: ParserOptions = { tdsVersion: '7_2', useUTC: false };
8+
const options = { tdsVersion: '7_2', useUTC: false } as ParserOptions;
99

1010
describe('Order Token Parser', () => {
1111
it('should have one column', async () => {

0 commit comments

Comments
 (0)