Skip to content

Commit 4eaafc4

Browse files
committed
Add tests for contentModel/helpers
1 parent 41c96d4 commit 4eaafc4

File tree

3 files changed

+610
-4
lines changed

3 files changed

+610
-4
lines changed

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
- Avoid semicolons unless it's absolutely necessary
33
- Always use block statements even if it could be a one-liner
44
- Always use curly braces {} for control structures (if, for, while, etc.), even if the body is a single statement
5+
- Keep lines shorter than 80 columns
6+
- For multiple expressions with logical operators (&&, ||), break lines after each operator
57

68
## Test Assertions Formatting
79
- Assertion function call on one line (e.g., `t.ok(`, `t.equal(`, `t.notOk(`)
@@ -10,5 +12,10 @@
1012
- Add blank line between consecutive assertions
1113
- Only use `t.plan()` for async or non-deterministic tests where assertions might be skipped; omit for sync tests
1214

15+
## Test File Naming
16+
- Create test files with the same name and casing as the module being tested, with `.spec.js` appended
17+
- Example: `FileSystemParser.js``FileSystemParser.spec.js`
18+
- Test files use the glob pattern `src/**/*.spec.js`
19+
1320
## Test File Operations
1421
- Use `Promise.all()` to parallelize independent async file operations (mkdir, writeFile, etc.) instead of awaiting them serially

src/compiler/contentModel/helpers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ const makeDateSlug = (date) => {
3333
}
3434

3535
const _sortableValue = (value) => {
36-
return typeof value === 'string' ? value.charCodeAt(0) * -1 : value
36+
return typeof value === 'string' ? value.toLowerCase().charCodeAt(0) : value
3737
}
3838

3939
const sort = (items, sortBy, sortOrder) => {
4040
items.sort((a, b) => {
4141
const sortableA = _sortableValue(a[sortBy])
4242
const sortableB = _sortableValue(b[sortBy])
4343
if (sortOrder === -1) {
44-
return sortableA - sortableB
44+
return sortableB - sortableA
4545
}
46-
return sortableB - sortableA
46+
return sortableA - sortableB
4747
})
4848
}
4949

@@ -98,4 +98,4 @@ module.exports = {
9898
sort,
9999
Markdown,
100100
safeStringify
101-
}
101+
}

0 commit comments

Comments
 (0)