@@ -14,12 +14,9 @@ export const readDocument404 = withTestEnv(async client => {
14
14
} ) ;
15
15
const item = container . item ( "not-exist" ) ;
16
16
17
- try {
18
- await item . read ( ) ;
19
- assert . fail ( ) ;
20
- } catch ( err ) {
21
- assert . equal ( err . code , 404 ) ;
22
- }
17
+ const { resource, statusCode } = await item . read ( ) ;
18
+ assert . strictEqual ( resource , undefined ) ;
19
+ assert . strictEqual ( statusCode , 404 ) ;
23
20
} ) ;
24
21
25
22
export const upsertDocument = withTestEnv ( async client => {
@@ -28,10 +25,11 @@ export const upsertDocument = withTestEnv(async client => {
28
25
id : "test-collection"
29
26
} ) ;
30
27
await container . items . upsert ( { id : "test" , text : "hi" } ) ;
31
- const { body } = await container . item ( "test" ) . read ( ) ;
32
- assert . strictEqual ( body . id , "test" ) ;
33
- assert . strictEqual ( body . text , "hi" ) ;
34
- assert ( body . _etag ) ;
28
+ const { resource } = await container . item ( "test" ) . read ( ) ;
29
+
30
+ assert . strictEqual ( resource . id , "test" ) ;
31
+ assert . strictEqual ( resource . text , "hi" ) ;
32
+ assert ( resource . _etag ) ;
35
33
} ) ;
36
34
37
35
export const upsertDocumentUpdate = withTestEnv ( async client => {
@@ -41,19 +39,19 @@ export const upsertDocumentUpdate = withTestEnv(async client => {
41
39
} ) ;
42
40
await container . items . upsert ( { id : "test" , text : "hi" } ) ;
43
41
await container . items . upsert ( { id : "test" , text : "hello" } ) ;
44
- const { body } = await container . item ( "test" ) . read ( ) ;
45
- assert . strictEqual ( body . id , "test" ) ;
46
- assert . strictEqual ( body . text , "hello" ) ;
47
- assert ( body . _etag ) ;
42
+ const { resource } = await container . item ( "test" ) . read ( ) ;
43
+ assert . strictEqual ( resource . id , "test" ) ;
44
+ assert . strictEqual ( resource . text , "hello" ) ;
45
+ assert ( resource . _etag ) ;
48
46
} ) ;
49
47
50
48
export const readDocumentsEmpty = withTestEnv ( async client => {
51
49
const { database } = await client . databases . create ( { id : "test-database" } ) ;
52
50
const { container } = await database . containers . create ( {
53
51
id : "test-collection"
54
52
} ) ;
55
- const { result } = await container . items . readAll ( ) . toArray ( ) ;
56
- assert . deepStrictEqual ( result , [ ] ) ;
53
+ const { resources } = await container . items . readAll ( ) . fetchAll ( ) ;
54
+ assert . deepStrictEqual ( resources , [ ] ) ;
57
55
} ) ;
58
56
59
57
export const readDocuments = withTestEnv ( async client => {
@@ -67,9 +65,9 @@ export const readDocuments = withTestEnv(async client => {
67
65
{ id : "test3" , text : "baz" , n : 3 }
68
66
] ;
69
67
await Promise . all ( data . map ( d => container . items . upsert ( d ) ) ) ;
70
- const { result } = await container . items . readAll ( ) . toArray ( ) ;
71
- assert . strictEqual ( result . length , data . length ) ;
72
- const sortedResult = result . sort (
68
+ const { resources } = await container . items . readAll ( ) . fetchAll ( ) ;
69
+ assert . strictEqual ( resources . length , data . length ) ;
70
+ const sortedResult = resources . sort (
73
71
( a : { n : number } , b : { n : number } ) => a . n - b . n
74
72
) ;
75
73
for ( let i = 0 , l = sortedResult . length ; i < l ; i += 1 ) {
@@ -86,16 +84,16 @@ export const udf = withTestEnv(async client => {
86
84
const { container } = await database . containers . create ( {
87
85
id : "test-collection"
88
86
} ) ;
89
- await container . userDefinedFunctions . create ( {
87
+ await container . scripts . userDefinedFunctions . create ( {
90
88
id : "REGEX_MATCH" ,
91
89
body : `
92
90
function(input, pattern) {
93
91
return input.match(pattern) !== null
94
92
}
95
93
`
96
94
} ) ;
97
- const { result } = await container . items
95
+ const { resources } = await container . items
98
96
. query ( `SELECT VALUE udf.REGEX_MATCH("foobar", ".*bar")` )
99
- . toArray ( ) ;
100
- assert . deepStrictEqual ( result , [ true ] ) ;
97
+ . fetchAll ( ) ;
98
+ assert . deepStrictEqual ( resources , [ true ] ) ;
101
99
} ) ;
0 commit comments