@@ -5,22 +5,37 @@ import { appWithClient, tableWithClient } from "./test-common";
5
5
6
6
jest . mock ( "cross-fetch" , ( ) => jest . fn ( jest . requireActual ( "cross-fetch" ) as any ) ) ;
7
7
8
- test ( "sanity - get named table" , async ( ) => {
9
- const table = await appWithClient . getTableNamed ( "Things" ) ;
10
- const spy = ( fetch as jest . Mock ) . mockImplementationOnce ( fetch ) ;
11
- const clientID = spy . mock . calls [ 0 ] [ 1 ] [ "headers" ] [ "X-Glide-Client-ID" ] ;
12
- expect ( clientID ) . toBeDefined ( ) ;
13
- expect ( clientID ) . toEqual ( process . env . GLIDE_CLIENT_ID ) ;
14
- expect ( table ) . toBeDefined ( ) ;
15
- } ) ;
8
+ describe ( "client id sanity" , ( ) => {
9
+ jest . setTimeout ( 60_000 ) ;
10
+
11
+ test ( "get named table" , async ( ) => {
12
+ const table = await appWithClient . getTableNamed ( "Things" ) ;
13
+ const spy = ( fetch as jest . Mock ) . mockImplementationOnce ( fetch ) ;
14
+ const clientID = spy . mock . calls [ 0 ] [ 1 ] [ "headers" ] [ "X-Glide-Client-ID" ] ;
15
+ expect ( clientID ) . toBeDefined ( ) ;
16
+ expect ( clientID ) . toEqual ( process . env . GLIDE_CLIENT_ID ) ;
17
+ expect ( table ) . toBeDefined ( ) ;
18
+ } ) ;
19
+
20
+ test ( "get schema" , async ( ) => {
21
+ const {
22
+ data : { columns } ,
23
+ } = await tableWithClient . getSchema ( ) ;
24
+ const spy = ( fetch as jest . Mock ) . mockImplementationOnce ( fetch ) ;
25
+ const clientID = spy . mock . calls [ 0 ] [ 1 ] [ "headers" ] [ "X-Glide-Client-ID" ] ;
26
+ expect ( clientID ) . toBeDefined ( ) ;
27
+ expect ( clientID ) . toEqual ( process . env . GLIDE_CLIENT_ID ) ;
28
+ expect ( columns ) . toBeDefined ( ) ;
29
+ } ) ;
30
+
31
+ it ( "can add a row" , async ( ) => {
32
+ const rowID = await tableWithClient . add ( {
33
+ name : "Test Item" ,
34
+ renamed : "Test Description" ,
35
+ stock : 100 ,
36
+ } ) ;
37
+ expect ( rowID ) . toBeDefined ( ) ;
16
38
17
- test ( "sanity - get named table" , async ( ) => {
18
- const {
19
- data : { columns } ,
20
- } = await tableWithClient . getSchema ( ) ;
21
- const spy = ( fetch as jest . Mock ) . mockImplementationOnce ( fetch ) ;
22
- const clientID = spy . mock . calls [ 0 ] [ 1 ] [ "headers" ] [ "X-Glide-Client-ID" ] ;
23
- expect ( clientID ) . toBeDefined ( ) ;
24
- expect ( clientID ) . toEqual ( process . env . GLIDE_CLIENT_ID ) ;
25
- expect ( columns ) . toBeDefined ( ) ;
39
+ await tableWithClient . delete ( rowID ) ;
40
+ } ) ;
26
41
} ) ;
0 commit comments