1- import { test , describe } from 'node:test' ;
2- import assert from 'node:assert' ;
1+ import { describe , it , expect } from 'vitest' ;
32import {
43 getCurrentPlatform ,
54 getPlatformPackageName ,
@@ -8,10 +7,10 @@ import {
87 getExtensionPath ,
98 getExtensionInfo ,
109 ExtensionNotFoundError
11- } from './index.js ' ;
10+ } from './index' ;
1211
1312describe ( 'Platform Detection' , ( ) => {
14- test ( 'getCurrentPlatform() returns a valid platform' , ( ) => {
13+ it ( 'getCurrentPlatform() returns a valid platform' , ( ) => {
1514 const platform = getCurrentPlatform ( ) ;
1615 const validPlatforms = [
1716 'darwin-arm64' ,
@@ -23,87 +22,68 @@ describe('Platform Detection', () => {
2322 'win32-x86_64' ,
2423 ] ;
2524
26- assert . ok (
27- validPlatforms . includes ( platform ) ,
28- `Platform ${ platform } should be one of: ${ validPlatforms . join ( ', ' ) } `
29- ) ;
25+ expect ( validPlatforms ) . toContain ( platform ) ;
3026 } ) ;
3127
32- test ( 'getPlatformPackageName() returns correct package name format' , ( ) => {
28+ it ( 'getPlatformPackageName() returns correct package name format' , ( ) => {
3329 const packageName = getPlatformPackageName ( ) ;
3430
35- assert . ok (
36- packageName . startsWith ( '@sqliteai/sqlite-vector-' ) ,
37- 'Package name should start with @sqliteai/sqlite-vector-'
38- ) ;
31+ expect ( packageName . startsWith ( '@sqliteai/sqlite-vector-' ) ) . toBe ( true ) ;
3932
40- assert . match (
41- packageName ,
42- / ^ @ s q l i t e a i \/ s q l i t e - v e c t o r - ( d a r w i n | l i n u x | w i n 3 2 ) - ( a r m 6 4 | x 8 6 _ 6 4 ) ( - m u s l ) ? $ / ,
43- 'Package name should match expected format'
33+ expect ( packageName ) . toMatch (
34+ / ^ @ s q l i t e a i \/ s q l i t e - v e c t o r - ( d a r w i n | l i n u x | w i n 3 2 ) - ( a r m 6 4 | x 8 6 _ 6 4 ) ( - m u s l ) ? $ /
4435 ) ;
4536 } ) ;
4637
47- test ( 'getBinaryName() returns correct extension' , ( ) => {
38+ it ( 'getBinaryName() returns correct extension' , ( ) => {
4839 const binaryName = getBinaryName ( ) ;
4940
50- assert . match (
51- binaryName ,
52- / ^ v e c t o r \. ( d y l i b | s o | d l l ) $ / ,
53- 'Binary name should be vector.dylib, vector.so, or vector.dll'
41+ expect ( binaryName ) . toMatch (
42+ / ^ v e c t o r \. ( d y l i b | s o | d l l ) $ /
5443 ) ;
5544 } ) ;
5645
57- test ( 'isMusl() returns a boolean' , ( ) => {
58- const result = isMusl ( ) ;
59- assert . strictEqual ( typeof result , 'boolean' ) ;
46+ it ( 'isMusl() returns a boolean' , ( ) => {
47+ expect ( typeof isMusl ( ) ) . toBe ( 'boolean' ) ;
6048 } ) ;
6149} ) ;
6250
6351describe ( 'Extension Path Resolution' , ( ) => {
64- test ( 'getExtensionPath() returns a string or throws' , ( ) => {
52+ it ( 'getExtensionPath() returns a string or throws' , ( ) => {
6553 try {
6654 const path = getExtensionPath ( ) ;
67- assert . strictEqual ( typeof path , 'string' ) ;
68- assert . ok ( path . length > 0 , 'Path should not be empty' ) ;
55+ expect ( typeof path ) . toBe ( 'string' ) ;
56+ expect ( path . length ) . toBeGreaterThan ( 0 ) ;
6957 } catch ( error ) {
70- // If it throws, it should be ExtensionNotFoundError
71- assert . ok (
72- error instanceof ExtensionNotFoundError ,
73- 'Should throw ExtensionNotFoundError if extension not found'
74- ) ;
58+ expect ( error instanceof ExtensionNotFoundError ) . toBe ( true ) ;
7559 }
7660 } ) ;
7761
78- test ( 'getExtensionInfo() returns complete info object' , ( ) => {
62+ it ( 'getExtensionInfo() returns complete info object' , ( ) => {
7963 try {
8064 const info = getExtensionInfo ( ) ;
8165
82- assert . ok ( info . platform , 'Should have platform' ) ;
83- assert . ok ( info . packageName , 'Should have packageName' ) ;
84- assert . ok ( info . binaryName , 'Should have binaryName' ) ;
85- assert . ok ( info . path , 'Should have path' ) ;
66+ expect ( info . platform ) . toBeTruthy ( ) ;
67+ expect ( info . packageName ) . toBeTruthy ( ) ;
68+ expect ( info . binaryName ) . toBeTruthy ( ) ;
69+ expect ( info . path ) . toBeTruthy ( ) ;
8670
87- assert . strictEqual ( typeof info . platform , 'string' ) ;
88- assert . strictEqual ( typeof info . packageName , 'string' ) ;
89- assert . strictEqual ( typeof info . binaryName , 'string' ) ;
90- assert . strictEqual ( typeof info . path , 'string' ) ;
71+ expect ( typeof info . platform ) . toBe ( 'string' ) ;
72+ expect ( typeof info . packageName ) . toBe ( 'string' ) ;
73+ expect ( typeof info . binaryName ) . toBe ( 'string' ) ;
74+ expect ( typeof info . path ) . toBe ( 'string' ) ;
9175 } catch ( error ) {
92- // If it throws, it should be ExtensionNotFoundError
93- assert . ok (
94- error instanceof ExtensionNotFoundError ,
95- 'Should throw ExtensionNotFoundError if extension not found'
96- ) ;
76+ expect ( error instanceof ExtensionNotFoundError ) . toBe ( true ) ;
9777 }
9878 } ) ;
9979} ) ;
10080
10181describe ( 'Error Handling' , ( ) => {
102- test ( 'ExtensionNotFoundError has correct properties' , ( ) => {
82+ it ( 'ExtensionNotFoundError has correct properties' , ( ) => {
10383 const error = new ExtensionNotFoundError ( 'Test message' ) ;
10484
105- assert . ok ( error instanceof Error ) ;
106- assert . strictEqual ( error . name , 'ExtensionNotFoundError' ) ;
107- assert . strictEqual ( error . message , 'Test message' ) ;
85+ expect ( error instanceof Error ) . toBe ( true ) ;
86+ expect ( error . name ) . toBe ( 'ExtensionNotFoundError' ) ;
87+ expect ( error . message ) . toBe ( 'Test message' ) ;
10888 } ) ;
109- } ) ;
89+ } ) ;
0 commit comments