test(mobile): blindage contrat API — suite apiClient + durcissement INVALID_RESPONSE
- tests/apiClient.test.ts (tsx/node:test, fetch stubbé) : paths/méthodes/query/body de tous les endpoints, multipart FormData sans Content-Type manuel, enveloppe {data,meta}, Bearer (présent/absent/fusion)
- cas hostiles : 2xx HTML/corps vide/JSON invalide/objet sans data/error → ApiError INVALID_RESPONSE (jamais de TypeError ni data indéfini) ; bare 5xx → HTTP_<status> ; fetch rejeté (dont AbortError) → NETWORK_ERROR ; [] toléré en data
- client.ts : parse d'enveloppe stricte dans request() (nouveau code client INVALID_RESPONSE)
- package.json : scripts test:api + test (db + api)
This commit is contained in:
+3
-1
@@ -34,7 +34,9 @@
|
||||
"ios": "expo run:ios",
|
||||
"web": "expo start --web",
|
||||
"test:db": "tsx --test tests/migrations.test.ts tests/repositories.test.ts",
|
||||
"test:migrations": "tsx --test tests/migrations.test.ts"
|
||||
"test:migrations": "tsx --test tests/migrations.test.ts",
|
||||
"test:api": "tsx --test tests/apiClient.test.ts",
|
||||
"test": "npm run test:db && npm run test:api"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user