@@ -26,9 +26,10 @@ import {
2626 WriteRelationshipsResponse ,
2727 WriteSchemaRequest ,
2828} from "./v1" ;
29+ import { describe , it , expect , beforeEach } from 'vitest'
2930
3031describe ( "a check with an unknown namespace" , ( ) => {
31- it ( "should raise a failed precondition" , ( done ) => {
32+ it ( "should raise a failed precondition" , ( ) => new Promise < void > ( ( done ) => {
3233 const resource = ObjectReference . create ( {
3334 objectType : "test/somenamespace" ,
3435 objectId : "bar" ,
@@ -58,11 +59,11 @@ describe("a check with an unknown namespace", () => {
5859 client . close ( ) ;
5960 done ( ) ;
6061 } ) ;
61- } ) ;
62+ } ) ) ;
6263} ) ;
6364
6465describe ( "a check with an known namespace" , ( ) => {
65- it ( "should succeed" , ( done ) => {
66+ it ( "should succeed" , ( ) => new Promise < void > ( ( done ) => {
6667 // Write some schema.
6768 const client = NewClient (
6869 generateTestToken ( "v1-namespace" ) ,
@@ -165,10 +166,10 @@ describe("a check with an known namespace", () => {
165166 client . close ( ) ;
166167 done ( ) ;
167168 } ) ;
168- } ) ;
169+ } ) ) ;
169170
170171 describe ( "with caveated relations" , ( ) => {
171- it ( "should succeed" , ( done ) => {
172+ it ( "should succeed" , ( ) => new Promise < void > ( ( done ) => {
172173 // Write some schema.
173174 const client = NewClient (
174175 generateTestToken ( "v1-namespace-caveats" ) ,
@@ -279,14 +280,14 @@ describe("a check with an known namespace", () => {
279280 client . close ( ) ;
280281 done ( ) ;
281282 } ) ;
282- } ) ;
283+ } ) ) ;
283284 } ) ;
284285} ) ;
285286
286287describe ( "Lookup APIs" , ( ) => {
287288 let token : string ;
288289
289- beforeEach ( ( done ) => {
290+ beforeEach ( ( ) => new Promise < void > ( ( done ) => {
290291 token = generateTestToken ( "v1-lookup" ) ;
291292 const client = NewClient (
292293 token ,
@@ -348,9 +349,9 @@ describe("Lookup APIs", () => {
348349 done ( ) ;
349350 } ) ;
350351 } ) ;
351- } ) ;
352+ } ) ) ;
352353
353- it ( "can lookup subjects" , ( done ) => {
354+ it ( "can lookup subjects" , ( ) => new Promise < void > ( ( done , fail ) => {
354355 const client = NewClient (
355356 token ,
356357 "localhost:50051" ,
@@ -375,7 +376,7 @@ describe("Lookup APIs", () => {
375376 const resStream = client . lookupSubjects ( request ) ;
376377
377378 resStream . on ( "data" , function ( subject : LookupSubjectsResponse ) {
378- expect ( [ "someuser" , "someuser2" ] ) . toContain ( subject . subjectObjectId ) ;
379+ expect ( [ "someuser" , "someuser2" ] ) . toContain ( subject . subject ?. subjectObjectId ) ;
379380 } ) ;
380381
381382 resStream . on ( "end" , function ( ) {
@@ -385,15 +386,15 @@ describe("Lookup APIs", () => {
385386
386387 resStream . on ( "error" , function ( e ) {
387388 client . close ( ) ;
388- done . fail ( e ) ;
389+ fail ( e ) ;
389390 } ) ;
390391
391392 resStream . on ( "status" , function ( status ) {
392393 expect ( status . code ) . toEqual ( grpc . status . OK ) ;
393394 } ) ;
394- } ) ;
395+ } ) ) ;
395396
396- it ( "can lookup resources" , ( done ) => {
397+ it ( "can lookup resources" , ( ) => new Promise < void > ( ( done , fail ) => {
397398 const client = NewClient (
398399 token ,
399400 "localhost:50051" ,
@@ -430,17 +431,17 @@ describe("Lookup APIs", () => {
430431
431432 resStream . on ( "error" , function ( e ) {
432433 client . close ( ) ;
433- done . fail ( e ) ;
434+ fail ( e ) ;
434435 } ) ;
435436
436437 resStream . on ( "status" , function ( status ) {
437438 expect ( status . code ) . toEqual ( grpc . status . OK ) ;
438439 } ) ;
439- } ) ;
440+ } ) ) ;
440441} ) ;
441442
442443describe ( "a check with a negative timeout" , ( ) => {
443- it ( "should fail immediately" , ( done ) => {
444+ it ( "should fail immediately" , ( ) => new Promise < void > ( ( done ) => {
444445 const resource = ObjectReference . create ( {
445446 objectType : "test/somenamespace" ,
446447 objectId : "bar" ,
@@ -474,13 +475,13 @@ describe("a check with a negative timeout", () => {
474475 client . close ( ) ;
475476 done ( ) ;
476477 } ) ;
477- } ) ;
478+ } ) ) ;
478479} ) ;
479480
480481describe ( "Experimental Service" , ( ) => {
481482 let token : string ;
482483
483- beforeEach ( ( done ) => {
484+ beforeEach ( ( ) => new Promise < void > ( ( done ) => {
484485 token = generateTestToken ( "v1-experimental-service" ) ;
485486 const client = NewClient (
486487 token ,
@@ -503,9 +504,9 @@ describe("Experimental Service", () => {
503504 client . close ( ) ;
504505 done ( ) ;
505506 } ) ;
506- } ) ;
507+ } ) ) ;
507508
508- it ( "can bulk import relationships" , ( done ) => {
509+ it ( "can bulk import relationships" , ( ) => new Promise < void > ( ( done , fail ) => {
509510 const client = NewClient (
510511 token ,
511512 "localhost:50051" ,
@@ -514,7 +515,7 @@ describe("Experimental Service", () => {
514515
515516 const writeStream = client . bulkImportRelationships ( ( err , value ) => {
516517 if ( err ) {
517- done . fail ( err ) ;
518+ fail ( err ) ;
518519 }
519520
520521 expect ( value ?. numLoaded ) . toEqual ( "2" ) ;
@@ -523,7 +524,7 @@ describe("Experimental Service", () => {
523524 } ) ;
524525
525526 writeStream . on ( "error" , ( e ) => {
526- done . fail ( e ) ;
527+ fail ( e ) ;
527528 } ) ;
528529
529530 const resource = ObjectReference . create ( {
@@ -559,9 +560,9 @@ describe("Experimental Service", () => {
559560 ) ;
560561
561562 writeStream . end ( ) ;
562- } ) ;
563+ } ) ) ;
563564
564- it ( "can bulk export relationships" , ( done ) => {
565+ it ( "can bulk export relationships" , ( ) => new Promise < void > ( ( done , fail ) => {
565566 const client = NewClient (
566567 token ,
567568 "localhost:50051" ,
@@ -655,12 +656,12 @@ describe("Experimental Service", () => {
655656
656657 resStream . on ( "error" , function ( e ) {
657658 client . close ( ) ;
658- done . fail ( e ) ;
659+ fail ( e ) ;
659660 } ) ;
660661
661662 resStream . on ( "status" , function ( status ) {
662663 expect ( status . code ) . toEqual ( grpc . status . OK ) ;
663664 } ) ;
664665 } ) ;
665- } ) ;
666+ } ) ) ;
666667} ) ;
0 commit comments