Updating mechanics for OS protocols
This commit is contained in:
@@ -183,4 +183,56 @@ describe('Builder Skill Chip save validation', () => {
|
||||
});
|
||||
expect(mocks.insertBuild).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('rejects an equipment Talent tier without canonical tier data', async () => {
|
||||
const loadout = createDraft();
|
||||
loadout.buildName = 'Invalid Talent Tier';
|
||||
loadout.gear.Holster.itemId = 'gear-1';
|
||||
loadout.gear.Holster.talentId = 'talent-1';
|
||||
loadout.gear.Holster.talentTier = 2;
|
||||
mocks.database.prepare.mockImplementation(async (sql: string) => ({
|
||||
all: vi.fn(async () => {
|
||||
if (sql.includes('FROM gear_talents'))
|
||||
return [{ gear_id: 'gear-1', talent_id: 'talent-1' }];
|
||||
if (sql.includes('FROM talent_tiers'))
|
||||
return [{ talent_id: 'talent-1', tier: 'I' }];
|
||||
return [];
|
||||
}),
|
||||
run: mocks.insertBuild,
|
||||
}));
|
||||
|
||||
const result = await runSave(loadout);
|
||||
|
||||
expect(result).toMatchObject({
|
||||
status: 400,
|
||||
data: { buildError: 'Holster Talent T2 is not configured.' },
|
||||
});
|
||||
expect(mocks.insertBuild).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('saves an equipment Talent with an authored Tier II', async () => {
|
||||
const loadout = createDraft();
|
||||
loadout.buildName = 'Tier Two Talent';
|
||||
loadout.gear.Holster.itemId = 'gear-1';
|
||||
loadout.gear.Holster.talentId = 'talent-1';
|
||||
loadout.gear.Holster.talentTier = 2;
|
||||
mocks.database.prepare.mockImplementation(async (sql: string) => ({
|
||||
all: vi.fn(async () => {
|
||||
if (sql.includes('FROM gear_talents'))
|
||||
return [{ gear_id: 'gear-1', talent_id: 'talent-1' }];
|
||||
if (sql.includes('FROM talent_tiers'))
|
||||
return [
|
||||
{ talent_id: 'talent-1', tier: 'I' },
|
||||
{ talent_id: 'talent-1', tier: 'II' },
|
||||
];
|
||||
return [];
|
||||
}),
|
||||
run: mocks.insertBuild,
|
||||
}));
|
||||
|
||||
const result = await runSave(loadout);
|
||||
|
||||
expect(result).toMatchObject({ buildSaved: true });
|
||||
expect(mocks.insertBuild).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user