I'm testing a the ContentType header returned from a Dart server.
test('Return type is JSON', () async {
final client = HttpClient();
final url = Uri.parse('$baseUrl/api/v1/playlists');
final request = await client.getUrl(url);
final response = await request.close();
final contentType = response.headers.contentType;
expect(contentType, ContentType.json);
});
When I run that it fails:
Expected: _ContentType:<application/json; charset=utf-8>
Actual: _ContentType:<application/json; charset=utf-8>
But if I convert them to strings it passes:
expect(contentType.toString(), ContentType.json.toString());
Why didn't the original pass?
question from:
https://stackoverflow.com/questions/65557666/expecting-contenttype-json-from-server-in-dart-testing 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…