@@ -3,12 +3,12 @@ import fetchMock from 'fetch-mock';
33
44describe ( 'users' , ( ) => {
55 const baseUrl = 'samples.auth0.com' ;
6- const telemetry = { name : 'react-native-auth0' , version : '1.0.0' } ;
6+ const telemetry = { name : 'react-native-auth0' , version : '1.0.0' } ;
77 const token = 'a.token.from.the.user' ;
88 const unexpectedError = {
99 status : 500 ,
1010 body : 'Internal Server Error....' ,
11- headers : { 'Content-Type' : 'text/plain' } ,
11+ headers : { 'Content-Type' : 'text/plain' } ,
1212 } ;
1313 const auth0Error = {
1414 status : 403 ,
@@ -18,25 +18,25 @@ describe('users', () => {
1818 message : 'User to be acted on does not match subject in bearer token.' ,
1919 statusCode : 403 ,
2020 } ,
21- headers : { 'Content-Type' : 'application/json' } ,
21+ headers : { 'Content-Type' : 'application/json' } ,
2222 } ;
2323
24- const users = new Users ( { baseUrl, telemetry, token} ) ;
24+ const users = new Users ( { baseUrl, telemetry, token } ) ;
2525
26- beforeEach ( fetchMock . restore ) ;
26+ beforeEach ( ( ) => fetchMock . restore ( ) ) ;
2727
2828 describe ( 'constructor' , ( ) => {
2929 it ( 'should build with domain' , ( ) => {
30- const users = new Users ( { baseUrl, token} ) ;
30+ const users = new Users ( { baseUrl, token } ) ;
3131 expect ( users . client . bearer ) . toContain ( token ) ;
3232 } ) ;
3333
3434 it ( 'should fail without token' , ( ) => {
35- expect ( ( ) => new Users ( { baseUrl} ) ) . toThrowErrorMatchingSnapshot ( ) ;
35+ expect ( ( ) => new Users ( { baseUrl } ) ) . toThrowErrorMatchingSnapshot ( ) ;
3636 } ) ;
3737
3838 it ( 'should fail without domain' , ( ) => {
39- expect ( ( ) => new Users ( { token} ) ) . toThrowErrorMatchingSnapshot ( ) ;
39+ expect ( ( ) => new Users ( { token } ) ) . toThrowErrorMatchingSnapshot ( ) ;
4040 } ) ;
4141 } ) ;
4242
@@ -46,83 +46,83 @@ describe('users', () => {
4646 it ( 'should send correct payload' , async ( ) => {
4747 fetchMock . getOnce (
4848 `https://samples.auth0.com/api/v2/users/${ encodeURIComponent ( userId ) } ` ,
49- user ,
49+ user
5050 ) ;
5151 expect . assertions ( 1 ) ;
52- await users . getUser ( { id : userId } ) ;
52+ await users . getUser ( { id : userId } ) ;
5353 expect ( fetchMock . lastCall ( ) ) . toMatchSnapshot ( ) ;
5454 } ) ;
5555
5656 it ( 'should return successful response' , async ( ) => {
5757 fetchMock . getOnce (
5858 `https://samples.auth0.com/api/v2/users/${ encodeURIComponent ( userId ) } ` ,
59- user ,
59+ user
6060 ) ;
6161 expect . assertions ( 1 ) ;
62- await expect ( users . getUser ( { id : userId } ) ) . resolves . toMatchSnapshot ( ) ;
62+ await expect ( users . getUser ( { id : userId } ) ) . resolves . toMatchSnapshot ( ) ;
6363 } ) ;
6464
6565 it ( 'should handle oauth error' , async ( ) => {
6666 fetchMock . getOnce (
6767 `https://samples.auth0.com/api/v2/users/${ encodeURIComponent ( userId ) } ` ,
68- auth0Error ,
68+ auth0Error
6969 ) ;
7070 expect . assertions ( 1 ) ;
71- await expect ( users . getUser ( { id : userId } ) ) . rejects . toMatchSnapshot ( ) ;
71+ await expect ( users . getUser ( { id : userId } ) ) . rejects . toMatchSnapshot ( ) ;
7272 } ) ;
7373
7474 it ( 'should handle unexpected error' , async ( ) => {
7575 fetchMock . getOnce (
7676 `https://samples.auth0.com/api/v2/users/${ encodeURIComponent ( userId ) } ` ,
77- unexpectedError ,
77+ unexpectedError
7878 ) ;
7979 expect . assertions ( 1 ) ;
80- await expect ( users . getUser ( { id : userId } ) ) . rejects . toMatchSnapshot ( ) ;
80+ await expect ( users . getUser ( { id : userId } ) ) . rejects . toMatchSnapshot ( ) ;
8181 } ) ;
8282 } ) ;
8383
8484 describe ( 'PATCH user' , ( ) => {
85- const metadata = { first_name : 'Mike' , lastName : 'Doe' } ;
85+ const metadata = { first_name : 'Mike' , lastName : 'Doe' } ;
8686 it ( 'should send correct payload' , async ( ) => {
8787 fetchMock . patchOnce (
8888 `https://samples.auth0.com/api/v2/users/${ encodeURIComponent ( userId ) } ` ,
89- user ,
89+ user
9090 ) ;
9191 expect . assertions ( 1 ) ;
92- await users . patchUser ( { id : userId , metadata} ) ;
92+ await users . patchUser ( { id : userId , metadata } ) ;
9393 expect ( fetchMock . lastCall ( ) ) . toMatchSnapshot ( ) ;
9494 } ) ;
9595
9696 it ( 'should return successful response' , async ( ) => {
9797 fetchMock . patchOnce (
9898 `https://samples.auth0.com/api/v2/users/${ encodeURIComponent ( userId ) } ` ,
99- user ,
99+ user
100100 ) ;
101101 expect . assertions ( 1 ) ;
102102 await expect (
103- users . patchUser ( { id : userId , metadata} ) ,
103+ users . patchUser ( { id : userId , metadata } )
104104 ) . resolves . toMatchSnapshot ( ) ;
105105 } ) ;
106106
107107 it ( 'should handle oauth error' , async ( ) => {
108108 fetchMock . patchOnce (
109109 `https://samples.auth0.com/api/v2/users/${ encodeURIComponent ( userId ) } ` ,
110- auth0Error ,
110+ auth0Error
111111 ) ;
112112 expect . assertions ( 1 ) ;
113113 await expect (
114- users . patchUser ( { id : userId , metadata} ) ,
114+ users . patchUser ( { id : userId , metadata } )
115115 ) . rejects . toMatchSnapshot ( ) ;
116116 } ) ;
117117
118118 it ( 'should handle unexpected error' , async ( ) => {
119119 fetchMock . patchOnce (
120120 `https://samples.auth0.com/api/v2/users/${ encodeURIComponent ( userId ) } ` ,
121- unexpectedError ,
121+ unexpectedError
122122 ) ;
123123 expect . assertions ( 1 ) ;
124124 await expect (
125- users . patchUser ( { id : userId , metadata} ) ,
125+ users . patchUser ( { id : userId , metadata } )
126126 ) . rejects . toMatchSnapshot ( ) ;
127127 } ) ;
128128 } ) ;
0 commit comments