2 Commits 7ca5c10900 ... caefae5b25

Author SHA1 Message Date
  Herton caefae5b25 Updating readme 4 years ago
  Herton 0b3d4bb8b6 Adding a basic test init 4 years ago
5 changed files with 35 additions and 4 deletions
  1. 9 1
      README.md
  2. 2 2
      package.json
  3. 1 1
      public/index.html
  4. 0 0
      server.js
  5. 23 0
      test.js

+ 9 - 1
README.md

@@ -1,4 +1,4 @@
-# Simple Node Server for a Single Page App
+# Simple Node Server For A Single Page App
 
 This is a very simple node web server with 0 dependencies but a clean structure ready to be built upon.
 
@@ -9,6 +9,14 @@ This is a very simple node web server with 0 dependencies but a clean structure
 * 100% scores across-the-board on lighhouse out of the box
 * Basic PWA setup
 
+## To install
+
+Just run `npm start` no need to install anything...
+
+## To test
+
+Just add some tests to the test file and run `npm test`
+
 ## License
 
 This is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

+ 2 - 2
package.json

@@ -4,8 +4,8 @@
   "description": "Single page node server with no dependencies",
   "main": "htmlServer.js",
   "scripts": {
-    "start": "node htmlServer.js",
-    "test": "echo \"Error: no test specified\" && exit 1"
+    "start": "node server.js",
+    "test": "node test.js"
   },
   "keywords": [
     "server",

+ 1 - 1
public/index.html

@@ -16,7 +16,7 @@
 <body>
     <div class="wrapper">
         <img src="favicon-32x32.png" width="16" height="16" alt="icon"/>
-        <p>Basic Node Single file Server Setup</p>
+        <h2>Simple Node Server For A Single Page App</h2>
     </div>
 </body>
 </html>

htmlServer.js → server.js


+ 23 - 0
test.js

@@ -0,0 +1,23 @@
+// Add your own test cases here
+let testNumber = 1;
+const rightTick = "\u2713";
+const wrongTick = "\u2717";
+function test(params, expected, method) {
+    try {
+        var output = method(params);
+    } catch(error) {
+        console.error(error.toString());
+    }
+    let out = '';
+    if (output == expected) {
+        out = `${rightTick} Test #${testNumber}`;
+    } else {
+        out = `${wrongTick} Test #${testNumber}`
+        + ` Expected [${expected.toString()}]`
+        + ` Your output: [${output}]`;
+    }
+    console.log(out);
+    testNumber++;
+}
+
+test('param', true, param => Boolean(param));