From caca4cdb2b665924873bf34d59e096006ccae529 Mon Sep 17 00:00:00 2001 From: inventionpro <109528211+inventionpro@users.noreply.github.com> Date: Mon, 16 Dec 2024 20:58:25 +0100 Subject: [PATCH] More --- tests/md5.test.js | 2 +- tests/reverse.test.js | 27 +++++++++++++++++++++++++++ tests/sha256.test.js | 2 +- tests/sha512.test.js | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 tests/reverse.test.js diff --git a/tests/md5.test.js b/tests/md5.test.js index 09a5493..70eaeff 100644 --- a/tests/md5.test.js +++ b/tests/md5.test.js @@ -2,7 +2,7 @@ const { describe, it } = require('node:test'); const assert = require('node:assert'); const api = require('../apis/md5.js'); -describe('Hex api', () => { +describe('MD5 api', () => { it('should error on empty', async () => { let req = {query:{}}; let errored = false; diff --git a/tests/reverse.test.js b/tests/reverse.test.js new file mode 100644 index 0000000..b07c15b --- /dev/null +++ b/tests/reverse.test.js @@ -0,0 +1,27 @@ +const { describe, it } = require('node:test'); +const assert = require('node:assert'); +const api = require('../apis/reverse.js'); + +describe('Hex api', () => { + it('should error on empty', async () => { + let req = {query:{}}; + let errored = false; + let res = { + error: function(){errored=true} + }; + api.execute(req,res); + assert.strictEqual(errored, true); + }); + it('should transform hello to olleh', async () => { + let req = {query:{type:'encode',text:'hello'}}; + let errored = false; + let json = null; + let res = { + error: function(){errored=true}, + json: function(j){json=j} + }; + api.execute(req,res); + assert.strictEqual(errored, false); + assert.strictEqual(json.text, 'olleh'); + }); +}); \ No newline at end of file diff --git a/tests/sha256.test.js b/tests/sha256.test.js index 38acbe6..6e8631c 100644 --- a/tests/sha256.test.js +++ b/tests/sha256.test.js @@ -2,7 +2,7 @@ const { describe, it } = require('node:test'); const assert = require('node:assert'); const api = require('../apis/sha256.js'); -describe('Hex api', () => { +describe('Sha256 api', () => { it('should error on empty', async () => { let req = {query:{}}; let errored = false; diff --git a/tests/sha512.test.js b/tests/sha512.test.js index db9f427..d5c7bd4 100644 --- a/tests/sha512.test.js +++ b/tests/sha512.test.js @@ -2,7 +2,7 @@ const { describe, it } = require('node:test'); const assert = require('node:assert'); const api = require('../apis/sha512.js'); -describe('Hex api', () => { +describe('Sha512 api', () => { it('should error on empty', async () => { let req = {query:{}}; let errored = false;