fix: use 0 based index for FSD (#58927)

This commit is contained in:
Oliver Eyton-Williams
2025-02-21 11:20:45 +01:00
committed by GitHub
parent 32eedb35e0
commit e0fc4fa7aa
2 changed files with 3 additions and 3 deletions

View File

@@ -139,7 +139,7 @@ function getBlockOrder(blockName, superBlockStructure) {
`The block "${blockName}" does not appear in the superblock structure.`
);
return index + 1;
return index;
}
exports.createSuperOrder = createSuperOrder;
exports.getSuperOrder = getSuperOrder;

View File

@@ -250,11 +250,11 @@ describe('getBlockOrder', () => {
it('returns the correct order when the chapter only contains one module', () => {
expect(
getBlockOrder('welcome-to-freecodecamp', mockSuperBlockStructure)
).toBe(1);
).toBe(0);
});
it('returns the correct order when the chapter contains multiple modules', () => {
expect(getBlockOrder('block-one-m2', mockSuperBlockStructure)).toBe(4);
expect(getBlockOrder('block-one-m2', mockSuperBlockStructure)).toBe(3);
});
it('throws if a block does not exist', () => {