Skip to content

Commit

Permalink
KSTAT-182: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RobLoach committed Apr 30, 2024
1 parent 0d0a07e commit b443e2e
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 1 deletion.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
},
"bin": {
"kalastatic": "./bin/kalastatic.js"
},
"devDependencies": {
"assert-dir-equal": "^1.1.0"
}
}
Binary file added test/expected/assets/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions test/expected/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
<link href="/styles.css" rel="stylesheet">
</head>
<body>
<h1>Hello World!</h1>
<img src="assets/image.png" />



<script src="/sampleJavaScript.js" ></script>
</body>
</html>
1 change: 1 addition & 0 deletions test/expected/sampleJavaScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("Sample JavaScript Loaded");
5 changes: 5 additions & 0 deletions test/expected/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/expected/styles.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"private": true,
"scripts": {
"build": "kalastatic",
"test": "npm run build",
"pretest": "npm run build",
"test": "node ./test.js",
"preinstall": "npm install --prefix=.."
},
"kalastatic": {
Expand Down
12 changes: 12 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Dependencies
const assertDir = require('assert-dir-equal');
const path = require('path');

// Get the current directory
const directory = path.dirname(__filename);

// Assert that the build directory matches what's expected
assertDir(path.join(directory, 'build_directory'), path.join(directory, 'expected'));

// Output test result
console.log("Tests passed!");

0 comments on commit b443e2e

Please sign in to comment.