From 9630a1987797cfae2e3448e41c6a7689345227ca Mon Sep 17 00:00:00 2001 From: Maxim N Date: Mon, 14 Nov 2022 08:03:02 +0700 Subject: [PATCH] added tests for ssgulnur, createFolder and parseJSON functions --- test/unit/__snapshots__/options.test.js.snap | 3 +++ test/unit/helper.test.js | 12 +++++++++++- test/unit/options.test.js | 11 +++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/unit/__snapshots__/options.test.js.snap create mode 100644 test/unit/options.test.js diff --git a/test/unit/__snapshots__/options.test.js.snap b/test/unit/__snapshots__/options.test.js.snap new file mode 100644 index 0000000..7b97a80 --- /dev/null +++ b/test/unit/__snapshots__/options.test.js.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test the main function with bad values check if calling a function with bad value will match snapshot 1`] = `undefined`; diff --git a/test/unit/helper.test.js b/test/unit/helper.test.js index ccac4af..3b3db7b 100644 --- a/test/unit/helper.test.js +++ b/test/unit/helper.test.js @@ -1,4 +1,4 @@ -const { checkSource } = require('../../src/helper'); +const { checkSource, createFolder, parseJSON } = require('../../src/helper'); describe('checkSource', () => { test('invalid path should return "none"', () => { @@ -13,3 +13,13 @@ describe('checkSource', () => { expect(checkSource('test/unit/helper.test.js')).toBe('file'); }); }); + +describe('testing functions for output', () => { + test('nothing passed to function should return false', () => { + expect(createFolder()).toBeFalsy(); + }); + + test('wrong path passed to function should return null', () => { + expect(parseJSON('wrong path')).toBe(null); + }); +}); diff --git a/test/unit/options.test.js b/test/unit/options.test.js new file mode 100644 index 0000000..57467aa --- /dev/null +++ b/test/unit/options.test.js @@ -0,0 +1,11 @@ +const ssgulnur = require('../../src/options'); + +describe('test the main function with bad values', () => { + test('return false if bad argument is passed to a function', () => { + expect(ssgulnur('')).toBeFalsy(); + }); + + test('check if calling a function with bad value will match snapshot', () => { + expect(ssgulnur('Bad value')).toMatchSnapshot(); + }); +});