Skip to content

Commit 893d0bd

Browse files
authored
Merge pull request #141 from AnggieAlava/iss-1551
[ID:1551] Exercise 21.2 now works correctly
2 parents b442390 + 21e20b4 commit 893d0bd

File tree

2 files changed

+42
-38
lines changed

2 files changed

+42
-38
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
let tasks = [
2-
{ label: 'Eat my lunch', done: true },
3-
{ label: 'Make the bed', done: false },
4-
{ label: 'Have some fun', done: false },
5-
{ label: 'Finish the replits', done: false },
6-
{ label: 'Finish my exercises', done: true },
7-
{ label: 'Ask for a raise', done: false },
8-
{ label: 'Read a book', done: true },
9-
{ label: 'Make a trip', done: false }
2+
{ label: "Eat my lunch", done: true },
3+
{ label: "Make the bed", done: false },
4+
{ label: "Have some fun", done: false },
5+
{ label: "Finish the replits", done: false },
6+
{ label: "Finish my exercises", done: true },
7+
{ label: "Ask for a raise", done: false },
8+
{ label: "Read a book", done: true },
9+
{ label: "Make a trip", done: false },
1010
];
1111

1212
// Your code here
Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
1-
const fs = require('fs');
2-
const path = require('path');
1+
const { error } = require("console");
2+
const fs = require("fs");
3+
const path = require("path");
34
const rewire = require("rewire");
45

56
let _log = console.log;
6-
let _buffer = '';
7-
global.console.log = console.log = jest.fn((text) => _buffer += text + "\n");
7+
let _buffer = "";
8+
global.console.log = console.log = jest.fn((text) => (_buffer += text));
89

9-
const app_content = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8');
10+
const app_content = fs.readFileSync(
11+
path.resolve(__dirname, "./app.js"),
12+
"utf8"
13+
);
1014

11-
test('You have to use the console.log function to print the correct output', function () {
12-
const app = require('./app.js');
13-
expect(console.log.mock.calls.length > 0).toBe(true);
15+
test("You have to use the console.log function to print the correct output", function () {
16+
const app = require("./app.js");
17+
expect(console.log.mock.calls.length > 0).toBe(true);
1418
});
1519

16-
test('The output in the console should match the one in the instructions', function () {
17-
const _app = rewire('./app.js');
18-
let _tasks = [
19-
{ label: 'Eat my lunch', done: true },
20-
{ label: 'Make the bed', done: false },
21-
{ label: 'Have some fun', done: false },
22-
{ label: 'Finish the replits', done: false },
23-
{ label: 'Replit the finishes', done: true },
24-
{ label: 'Ask for a raise', done: false },
25-
{ label: 'Read a book', done: true },
26-
{ label: 'Make a trip', done: false }
27-
];
28-
let _test = _tasks.filter(item => item.done === true)
29-
30-
expect(_buffer).toMatch(_test.map(n => n).join(","));
31-
// expect(_buffer).toMatch(_test.map(n => n).join("\n"));
32-
33-
});
34-
35-
36-
37-
20+
test("The output in the console should match the one in the instructions", function () {
21+
const _app = rewire("./app.js");
22+
let _tasks = [
23+
{ label: "Eat my lunch", done: true },
24+
{ label: "Make the bed", done: false },
25+
{ label: "Have some fun", done: false },
26+
{ label: "Finish the replits", done: false },
27+
{ label: "Replit the finishes", done: true },
28+
{ label: "Ask for a raise", done: false },
29+
{ label: "Read a book", done: true },
30+
{ label: "Make a trip", done: false },
31+
];
32+
let _test = _tasks.filter((item) => item.done === true);
33+
34+
expect(_buffer.length).toBe(
35+
[
36+
{ label: "Eat my lunch", done: true },
37+
{ label: "Finish my exercises", done: true },
38+
{ label: "Read a book", done: true },
39+
].join("\n").length
40+
);
41+
});

0 commit comments

Comments
 (0)