fix/add tests, update heatmap range, finish android release, add readme
Stop tracking gradle.properties
This commit is contained in:
@@ -178,7 +178,7 @@ describe('Sync Service', () => {
|
||||
});
|
||||
|
||||
it('should sync items in chunks', async () => {
|
||||
const manyIds = Array.from({ length: 150 }, (_, i) => i + 1);
|
||||
const manyIds = Array.from({ length: 100 }, (_, i) => i + 1);
|
||||
const subjectData = manyIds.map(id => ({ data: { subject_id: id } }));
|
||||
|
||||
fetch.mockResolvedValueOnce({
|
||||
@@ -202,11 +202,90 @@ describe('Sync Service', () => {
|
||||
});
|
||||
|
||||
StudyItem.insertMany.mockResolvedValue(true);
|
||||
StudyItem.countDocuments.mockResolvedValue(150);
|
||||
StudyItem.countDocuments.mockResolvedValue(100);
|
||||
|
||||
await syncWithWaniKani(mockUser);
|
||||
|
||||
expect(fetch).toHaveBeenCalledTimes(3);
|
||||
expect(StudyItem.insertMany).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('should fetch and map radicals for items, handling missing meanings', async () => {
|
||||
fetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: [{ data: { subject_id: 500 } }],
|
||||
pages: { next_url: null }
|
||||
})
|
||||
});
|
||||
|
||||
StudyItem.find.mockReturnValue({ select: vi.fn().mockResolvedValue([]) });
|
||||
|
||||
fetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: [{
|
||||
id: 500,
|
||||
data: {
|
||||
characters: 'Kanji',
|
||||
meanings: [{ primary: true, meaning: 'K_Mean' }],
|
||||
level: 5,
|
||||
readings: [],
|
||||
component_subject_ids: [10, 11, 12]
|
||||
}
|
||||
}]
|
||||
})
|
||||
});
|
||||
|
||||
fetch.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: [
|
||||
{
|
||||
id: 10,
|
||||
data: {
|
||||
characters: 'R1',
|
||||
meanings: [{ primary: true, meaning: 'Rad1' }],
|
||||
character_images: []
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
data: {
|
||||
characters: null,
|
||||
meanings: [{ primary: true, meaning: 'Rad2' }],
|
||||
character_images: [
|
||||
{ content_type: 'image/png', url: 'bad.png', metadata: {} },
|
||||
{ content_type: 'image/svg+xml', url: 'good.svg', metadata: { inline_styles: false } }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
data: {
|
||||
characters: 'R2',
|
||||
meanings: [{ primary: false, meaning: 'Secondary' }],
|
||||
character_images: []
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
});
|
||||
|
||||
StudyItem.insertMany.mockResolvedValue(true);
|
||||
StudyItem.countDocuments.mockResolvedValue(1);
|
||||
|
||||
await syncWithWaniKani(mockUser);
|
||||
|
||||
expect(StudyItem.insertMany).toHaveBeenCalledWith(expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
wkSubjectId: 500,
|
||||
radicals: expect.arrayContaining([
|
||||
expect.objectContaining({ meaning: 'Rad1', char: 'R1' }),
|
||||
expect.objectContaining({ meaning: 'Rad2', image: 'good.svg' }),
|
||||
expect.objectContaining({ meaning: 'Unknown', char: 'R2' })
|
||||
])
|
||||
})
|
||||
]));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user