Skip to content

Commit 323b294

Browse files
Add test for .js file
1 parent 4ec1e45 commit 323b294

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ in a text editor, Code-Counting will not read it. This was discovered through th
9191
- ~~Switch to pytest for unit testing~~
9292
- ~~Add test that goes through every file in 'test-code' directory~~
9393
- Make test code files and tests for the following languages:
94-
- Javascript
94+
- ~~Javascript~~
9595
- ~~HTML~~
9696
- ~~CSS~~
9797
- C/C++

tests/constants.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@
88
PYTHON_FILE = os.path.join(TEST_CODE_DIR, 'Person.py')
99
HTML_FILE = os.path.join(TEST_CODE_DIR, 'test.html')
1010
CSS_FILE = os.path.join(TEST_CODE_DIR, 'test.css')
11+
JAVASCRIPT_FILE = os.path.join(TEST_CODE_DIR, 'test.js')
1112

1213
JAVA_LINE_COUNT = 39
1314
PYTHON_LINE_COUNT = 16
1415
HTML_LINE_COUNT = 29
1516
CSS_LINE_COUNT = 9
17+
JAVASCRIPT_FILE_COUNT = 8
1618

17-
TEST_CODE_DIR_LINE_COUNT = JAVA_LINE_COUNT + PYTHON_LINE_COUNT + HTML_LINE_COUNT + CSS_LINE_COUNT
19+
TEST_CODE_DIR_LINE_COUNT = JAVA_LINE_COUNT + PYTHON_LINE_COUNT + HTML_LINE_COUNT + CSS_LINE_COUNT + \
20+
JAVASCRIPT_FILE_COUNT
21+
22+
TEST_CODE_DIR_FILE_COUNT = 5

tests/each_language_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@ def test_html_line_count():
3333
def test_css_line_count():
3434

3535
assert get_line_count(CSS_FILE, '.css') == CSS_LINE_COUNT
36+
37+
38+
def test_javascript_line_count():
39+
40+
assert get_line_count(JAVASCRIPT_FILE, '.js') == JAVASCRIPT_FILE_COUNT

tests/misc_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from .constants import CURRENT_PATH, TEST_CODE_DIR, TEST_CODE_DIR_LINE_COUNT
3+
from .constants import CURRENT_PATH, TEST_CODE_DIR, TEST_CODE_DIR_LINE_COUNT, TEST_CODE_DIR_FILE_COUNT
44

55
from code_counting.lang_controller import LanguagesController
66
from code_counting.util import explore_folder
@@ -30,4 +30,4 @@ def test_the_test_code_dir_file_count():
3030
for file in files:
3131
lang_controller.check(file)
3232

33-
assert lang_controller.total_files() == 4
33+
assert lang_controller.total_files() == TEST_CODE_DIR_FILE_COUNT

tests/test-code/test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function sum(a, b) {
2+
return a + b;
3+
}
4+
5+
console.log('Hello, World!')
6+
7+
console.log('Wonder what 2 + 2 equals?')
8+
console.log('It equals', sum(2, 2), "!")

0 commit comments

Comments
 (0)