Skip to content

Commit 4776180

Browse files
committed
fix(check): new counts were adding non task list items, added test to make sure this doesnt happen again
1 parent 20d20a0 commit 4776180

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ module.exports = (app) => {
7575
};
7676

7777
// all finished?
78-
console.log(outstandingTasks);
7978
if (outstandingTasks.remaining === 0) {
8079
check.status = 'completed';
8180
check.conclusion = 'success';

src/check-outstanding-tasks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = function (body) {
1313

1414
// return counts of task list items and how many are left to be completed
1515
return {
16-
total: listItems.length,
16+
total: listItems.filter(item => item.checked !== undefined).length,
1717
remaining: listItems.filter(item => item.checked === false).length
1818
};
1919
};

tests/index.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Hello World
1212
expect(results.total).toBe(2);
1313
expect(results.remaining).toBe(1);
1414
});
15+
1516
test('Test no outstanding tasks', () => {
1617
let markdown = `
1718
Hello World
@@ -22,3 +23,24 @@ Hello World
2223
expect(results.total).toBe(2);
2324
expect(results.remaining).toBe(0);
2425
});
26+
27+
test('Test no tasks', () => {
28+
let markdown = `
29+
Hello World
30+
`;
31+
let results = checkOutstandingTasks(markdown);
32+
expect(results.total).toBe(0);
33+
expect(results.remaining).toBe(0);
34+
});
35+
36+
test('Test dont count normal lists', () => {
37+
let markdown = `
38+
Hello World
39+
- normal
40+
- [x] task 1
41+
- [ ] task 2
42+
`;
43+
let results = checkOutstandingTasks(markdown);
44+
expect(results.total).toBe(2);
45+
expect(results.remaining).toBe(1);
46+
});

0 commit comments

Comments
 (0)