Skip to content

Commit 0900685

Browse files
committed
chapter 02: adding state logAnalyzer
1 parent 7e50568 commit 0900685

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

chapter_02-a-first-unit-test/LogAn/logAnalyzer.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
const ArgumentError = require('./ArgumentError');
22

33
function logAnalyzer() {
4+
/**
5+
* @type {boolean}
6+
*/
7+
let wasLastFileNameValid;
8+
9+
/**
10+
* @return {boolean}
11+
*/
12+
function getWasLastFilenameValid() {
13+
return wasLastFileNameValid;
14+
}
15+
416
/**
517
* @param {string} fileName
618
* @return {boolean}
719
*/
820
function isValidLogFileName(fileName) {
21+
wasLastFileNameValid = false;
22+
923
if (fileName === '') {
1024
throw new ArgumentError('filename has to be provided');
1125
}
@@ -14,10 +28,12 @@ function logAnalyzer() {
1428
return false;
1529
}
1630

31+
wasLastFileNameValid = true;
1732
return true;
1833
}
1934

2035
return {
36+
getWasLastFilenameValid,
2137
isValidLogFileName,
2238
};
2339
}

0 commit comments

Comments
 (0)