diff --git a/Unit Tests/package.json b/Unit Tests/package.json new file mode 100644 index 0000000..9f8606d --- /dev/null +++ b/Unit Tests/package.json @@ -0,0 +1,20 @@ +{ + "name": "tests", + "version": "1.0.0", + "description": "", + "main": "server.js", + "dependencies": { + "cors": "^2.8.5", + "express": "^4.17.1" + }, + "devDependencies": { + "jest": "^26.6.3" + }, + "scripts": { + "test": "npx jest", + "start": "node server.js" + }, + "keywords": [], + "author": "", + "license": "ISC" +} diff --git a/Unit Tests/validatepreviousURL.js b/Unit Tests/validatepreviousURL.js new file mode 100644 index 0000000..3ba4054 --- /dev/null +++ b/Unit Tests/validatepreviousURL.js @@ -0,0 +1,8 @@ +var validatePreviousURL = function (url) { +//document.referrer +const urlBefore = url.indexOf('codepen') > -1; + +return urlBefore +} + +validatePreviousURL(document.referrer); \ No newline at end of file diff --git a/Unit Tests/validatepreviousURL.test.js b/Unit Tests/validatepreviousURL.test.js new file mode 100644 index 0000000..b80cd56 --- /dev/null +++ b/Unit Tests/validatepreviousURL.test.js @@ -0,0 +1,11 @@ +var validatepreviousURL = function (url) { + //document.referrer + const urlBefore = url.indexOf('codepen') > -1; + + return urlBefore +} + +//Tests +test('Retuns False cause previous URL does not match with the regex', () => { +expect(validatepreviousURL("google.com")).toBe(false) +}) \ No newline at end of file