@@ -23,6 +23,10 @@ const credentials = {
23
23
} ;
24
24
let session = null ;
25
25
26
+ function getTestUsername ( ) {
27
+ return `testName-${ uuidV4 ( ) } ` ; // Use the same test user name format as the E2E tests. Simplifies cleanup if running the tests against a real server.
28
+ }
29
+
26
30
beforeAll ( ( ) => {
27
31
session = new Session (
28
32
credentials . serverUrl ,
@@ -62,7 +66,7 @@ describe("Session", () => {
62
66
63
67
it ( "Should allow creating a User" , ( ) => {
64
68
const promise = session . create ( "User" , {
65
- username : uuidV4 ( ) ,
69
+ username : getTestUsername ( ) ,
66
70
} ) ;
67
71
68
72
return expect (
@@ -71,7 +75,7 @@ describe("Session", () => {
71
75
} ) ;
72
76
73
77
it ( "Should allow deleting a User" , async ( ) => {
74
- const username = uuidV4 ( ) ;
78
+ const username = getTestUsername ( ) ;
75
79
let promise = session . create ( "User" , {
76
80
username,
77
81
} ) ;
@@ -88,24 +92,24 @@ describe("Session", () => {
88
92
} ) ;
89
93
90
94
it ( "Should allow updating a User" , async ( ) => {
91
- const username = "new user" ;
92
- const newUsername = "3e21c60e-33ac-4242-aaf8-b04a089821c7" ;
95
+ const username = getTestUsername ( ) ;
96
+ const shortUsername = username . slice ( 0 , - 30 ) ;
93
97
let promise = session . create ( "User" , {
94
- username ,
98
+ shortUsername ,
95
99
} ) ;
96
100
97
101
promise = promise . then ( ( newUserResponse ) => {
98
102
const userId = newUserResponse . data . id ;
99
103
const updatePromise = session . update ( "User" , userId , {
100
- username : newUsername ,
104
+ username : username ,
101
105
} ) ;
102
106
103
107
return updatePromise ;
104
108
} ) ;
105
-
109
+ // Checks a regex matching the username generated by getTestUsername()
106
110
await expect (
107
111
promise . then ( ( response ) => response . data . username )
108
- ) . resolves . toEqual ( newUsername ) ;
112
+ ) . resolves . toMatch ( / ^ t e s t N a m e - [ 0 - 9 a - f - ] { 36 } $ / ) ;
109
113
} ) ;
110
114
111
115
it ( "Should support merging 0-level nested data" , async ( ) => {
0 commit comments