From e0fc4fa7aa4828e909d7d0c0cb0a176778e6c773 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Fri, 21 Feb 2025 11:20:45 +0100 Subject: [PATCH] fix: use 0 based index for FSD (#58927) --- curriculum/utils.js | 2 +- curriculum/utils.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/curriculum/utils.js b/curriculum/utils.js index f4532cd5d5b..c2eb12da97e 100644 --- a/curriculum/utils.js +++ b/curriculum/utils.js @@ -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; diff --git a/curriculum/utils.test.ts b/curriculum/utils.test.ts index 6e44def8739..5d826d5d1ab 100644 --- a/curriculum/utils.test.ts +++ b/curriculum/utils.test.ts @@ -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', () => {