Reputation: 21
and thanks for the support.
i am haveing prbolem to compare two obj of City, one created and one read and hopefully "converted" from a json file.
The one imported:
import * as citiesJson from '../resources/cities.json';
const cities_test: City[] = citiesJson as City[];
The one created:
const milan: City = { name: 'Milan', population: 1371498 };
const napels: City = { name: 'Napels', population: 911000 };
const rome: City = { name: 'Rome', population: 2758334 };
const resultSort: City[] = [milan, napels, rome];
the test result expect(getSortedItems(cities_imported)).toEqual(city_created);
failed and the console.log of them both is:
Imported
console.log
{
'0': [Getter],
'1': [Getter],
'2': [Getter],
default: [
{ name: 'Milan', population: 1371498 },
{ name: 'Naples', population: 911000 },
{ name: 'Rome', population: 2758334 }
]
}
at Object.<anonymous> (dao/sortAlg.test.ts:30:17)
Created
console.log
[
{ name: 'Milan', population: 1371498 },
{ name: 'Napels', population: 911000 },
{ name: 'Rome', population: 2758334 }
]
at Object.<anonymous> (dao/sortAlg.test.ts:31:17)
i am doing something wrong but is not clear where. the first idea is about the printing of the imported json file and this part:
{
'0': [Getter],
'1': [Getter],
'2': [Getter],
default:
is there a way to manipulate json file in order to make the comparison succesfull?
Upvotes: 1
Views: 31