Skip to content

Commit

Permalink
Add JavaScript code sample for tests (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
miles170 authored Oct 4, 2022
1 parent e32353b commit 1ce5828
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/analyzer/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@ func TestMatchingFiles(t *testing.T) {
Extension: ".html",
Language: "HTML",
},

{
FilePath: filepath.Join(codeSamplesDir, "main.go"),
Extension: ".go",
Language: "Golang",
},
{
FilePath: filepath.Join(codeSamplesDir, "main.js"),
Extension: ".js",
Language: "JavaScript",
},
},
},
{
Expand All @@ -85,6 +89,11 @@ func TestMatchingFiles(t *testing.T) {
Extension: ".html",
Language: "HTML",
},
{
FilePath: filepath.Join(codeSamplesDir, "main.js"),
Extension: ".js",
Language: "JavaScript",
},
},
},
{
Expand All @@ -107,6 +116,11 @@ func TestMatchingFiles(t *testing.T) {
Extension: ".html",
Language: "HTML",
},
{
FilePath: filepath.Join(codeSamplesDir, "main.js"),
Extension: ".js",
Language: "JavaScript",
},
},
},
{
Expand Down
7 changes: 7 additions & 0 deletions pkg/scanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ func TestScan(t *testing.T) {
BlankLines: 5,
Comments: 6,
},
{
Metadata: files[3],
Lines: 13,
CodeLines: 8,
BlankLines: 3,
Comments: 2,
},
}

result, err := scanner.Scan(files)
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/code_samples/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// main function
const main = () => {
console.log("Hello, World!");

const a = 2;
const b = 3;
// Sum a + b
const total = a + b;

console.log(total);
};

main();

0 comments on commit 1ce5828

Please sign in to comment.