Skip to content

Commit

Permalink
Adding tests. Resolves #46.
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldenning committed Jun 10, 2020
1 parent 6d2cfe9 commit 5c5c3e2
Show file tree
Hide file tree
Showing 18 changed files with 2,944 additions and 473 deletions.
3 changes: 3 additions & 0 deletions jest.config.js
@@ -0,0 +1,3 @@
module.exports = {
testEnvironment: "node",
};
9 changes: 5 additions & 4 deletions package.json
Expand Up @@ -7,7 +7,7 @@
"import-map-deployer": "./bin/import-map-deployer"
},
"scripts": {
"test": "rm -f sofe-manifest.json && jasmine",
"test": "cross-env NODE_ENV=test jest",
"format": "prettier --write './**/*'",
"start": "node src/web-server.js"
},
Expand Down Expand Up @@ -44,12 +44,13 @@
"rwlock": "^5.0.0"
},
"devDependencies": {
"cross-env": "^7.0.2",
"husky": "^4.2.5",
"jasmine": "^2.4.1",
"node-static": "^0.7.9",
"jest": "^26.0.1",
"jest-cli": "^26.0.1",
"prettier": "^2.0.4",
"pretty-quick": "^2.0.1",
"superagent": "^1.6.1"
"supertest": "^4.0.2"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
Expand Down
11 changes: 0 additions & 11 deletions spec/express.spec.js

This file was deleted.

141 changes: 0 additions & 141 deletions spec/filesystem.spec.js

This file was deleted.

104 changes: 0 additions & 104 deletions spec/get-environments.spec.js

This file was deleted.

61 changes: 0 additions & 61 deletions spec/http-api.js

This file was deleted.

1 change: 0 additions & 1 deletion spec/mockServices/1.js

This file was deleted.

1 change: 0 additions & 1 deletion spec/mockServices/2.js

This file was deleted.

1 change: 0 additions & 1 deletion spec/mockServices/3.js

This file was deleted.

Empty file removed spec/mockServices/4.js
Empty file.
Empty file removed spec/mockServices/5.js
Empty file.
7 changes: 0 additions & 7 deletions spec/support/jasmine.json

This file was deleted.

2 changes: 2 additions & 0 deletions src/auth.js
Expand Up @@ -16,6 +16,8 @@ module.exports = function (req, res, next) {
return next();
}
var user = auth(req);
const unauthenticatedEndpoints = ["/", "/"];

if (
(!user || !admins[user.name] || admins[user.name].password !== user.pass) &&
!publicRoutes.has(req.url)
Expand Down
8 changes: 8 additions & 0 deletions src/io-methods/default.js
Expand Up @@ -31,6 +31,8 @@ exports.readManifest = function (env) {
} else if (useS3(filePath)) {
//use s3
return s3.readManifest(filePath);
} else if (useMemory(filePath)) {
return memory.readManifest(filePath);
} else {
//use local file
return fs.readManifest(filePath);
Expand All @@ -48,6 +50,8 @@ exports.writeManifest = function (data, env) {
} else if (useS3(filePath)) {
//use s3
return s3.writeManifest(filePath, data);
} else if (useMemory(filePath)) {
return memory.writeManifest(filePath, data);
} else {
//use local file
return fs.writeManifest(filePath, data);
Expand All @@ -65,3 +69,7 @@ function useS3(filePath) {
function usesGoogle(filePath) {
return filePath.startsWith("google://");
}

function useMemory(filePath) {
return filePath.startsWith("memory://");
}

0 comments on commit 5c5c3e2

Please sign in to comment.