-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π pull request #15 from devnetkc:addPkgEntryTest
β Adds testing to pkg main entry file
- Loading branch information
Showing
18 changed files
with
375 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/** | ||
* @format | ||
* @module customModule_CS-test | ||
*/ | ||
|
||
import customJestStubs from '../customJestStubs'; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
// eslint-disable-next-line import/no-amd | ||
describe('customJestStubs.js Tests', () => { | ||
describe('customStubs method should ', () => { | ||
describe('ExcludeStubs param', () => {}); | ||
// * GIVEN | ||
test('return an array when passed empty array', () => { | ||
// * GIVEN | ||
const ExcludeStubs = []; | ||
// * WHEN | ||
const CustomStubsList = customJestStubs.customStubs(ExcludeStubs); | ||
// * THEN | ||
expect(CustomStubsList).toEqual(expect.any(Array)); | ||
expect(jest.fn(() => CustomStubsList)).not.toThrow(Error); | ||
}); | ||
test('throw an error if NOT given an array', () => { | ||
// * GIVEN | ||
const ExcludeStubs = {}; | ||
// * THEN | ||
expect(jest.fn(() => customJestStubs.customStubs(ExcludeStubs))).toThrow( | ||
'EXCLUDED_STUBS_TYPEERROR' | ||
); | ||
}); | ||
describe('useMinified is false', () => { | ||
test('return array with excluded module path instead of stub path', () => { | ||
// * GIVEN | ||
const ExcludeStubs = [ | ||
{ | ||
name: '/SuiteScripts/Modules/aModule', | ||
path: `<rootDir>/src/FileCabinet`, | ||
useMinified: { | ||
value: false, | ||
}, | ||
}, | ||
]; | ||
const ExpectedResult = [ | ||
{ | ||
module: '/SuiteScripts/Modules/aModule', | ||
path: `<rootDir>/src/FileCabinet/SuiteScripts/Modules/aModule.js`, | ||
}, | ||
{ | ||
module: '/SuiteScripts/Modules/aModule.min', | ||
path: `<rootDir>/src/FileCabinet/SuiteScripts/Modules/aModule.js`, | ||
}, | ||
{ | ||
module: '/SuiteScripts/Modules/bModule', | ||
path: `<rootDir>/node_modules/@vnetwork-solutions/ns-custom-stubs-template/stubs/SuiteScripts/Modules/bModule`, | ||
}, | ||
{ | ||
module: '/SuiteScripts/Modules/bModule.min', | ||
path: `<rootDir>/node_modules/@vnetwork-solutions/ns-custom-stubs-template/stubs/SuiteScripts/Modules/bModule`, | ||
}, | ||
]; | ||
// * WHEN | ||
const CustomStubsList = customJestStubs.customStubs(ExcludeStubs); | ||
// * THEN | ||
expect(CustomStubsList).toEqual(expect.arrayContaining(ExpectedResult)); | ||
}); | ||
}); | ||
describe('useMinified is true', () => { | ||
/* test.todo( | ||
'should return array with minified excluded module path instead of stub path ' | ||
); */ | ||
test('return array with excluded module path instead of stub path', () => { | ||
// * GIVEN | ||
const ExcludeStubs = [ | ||
{ | ||
name: '/SuiteScripts/Modules/aModule', | ||
path: `<rootDir>/src/FileCabinet`, | ||
useMinified: { | ||
value: true, | ||
}, | ||
}, | ||
{ | ||
name: '/SuiteScripts/Modules/bModule.min', | ||
path: `<rootDir>/src/FileCabinet`, | ||
useMinified: { | ||
value: false, | ||
}, | ||
}, | ||
]; | ||
const ExpectedResult = [ | ||
{ | ||
module: '/SuiteScripts/Modules/aModule', | ||
path: `<rootDir>/src/FileCabinet/SuiteScripts/Modules/aModule.js`, | ||
}, | ||
{ | ||
module: '/SuiteScripts/Modules/aModule.min', | ||
path: `<rootDir>/src/FileCabinet/SuiteScripts/Modules/aModule.min.js`, | ||
}, | ||
{ | ||
module: '/SuiteScripts/Modules/bModule', | ||
path: `<rootDir>/node_modules/@vnetwork-solutions/ns-custom-stubs-template/stubs/SuiteScripts/Modules/bModule`, | ||
}, | ||
{ | ||
module: '/SuiteScripts/Modules/bModule.min', | ||
path: `<rootDir>/src/FileCabinet/SuiteScripts/Modules/bModule.js`, | ||
}, | ||
]; | ||
// * WHEN | ||
const CustomStubsList = customJestStubs.customStubs(ExcludeStubs); | ||
// * THEN | ||
expect(CustomStubsList).toEqual(expect.arrayContaining(ExpectedResult)); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>JSDoc: Source: __tests__/customJestStubs-test.js</title> | ||
|
||
<script src="scripts/prettify/prettify.js"> </script> | ||
<script src="scripts/prettify/lang-css.js"> </script> | ||
<!--[if lt IE 9]> | ||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> | ||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> | ||
</head> | ||
|
||
<body> | ||
|
||
<div id="main"> | ||
|
||
<h1 class="page-title">Source: __tests__/customJestStubs-test.js</h1> | ||
|
||
|
||
|
||
|
||
|
||
|
||
<section> | ||
<article> | ||
<pre class="prettyprint source linenums"><code>/** | ||
* @format | ||
* @module customModule_CS-test | ||
*/ | ||
|
||
import customJestStubs from '../customJestStubs'; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
// eslint-disable-next-line import/no-amd | ||
describe('customJestStubs.js Tests', () => { | ||
describe('customStubs method should ', () => { | ||
describe('ExcludeStubs param', () => {}); | ||
// * GIVEN | ||
test('return an array when passed empty array', () => { | ||
// * GIVEN | ||
const ExcludeStubs = []; | ||
// * WHEN | ||
const CustomStubsList = customJestStubs.customStubs(ExcludeStubs); | ||
// * THEN | ||
expect(CustomStubsList).toEqual(expect.any(Array)); | ||
expect(jest.fn(() => CustomStubsList)).not.toThrow(Error); | ||
}); | ||
test('throw an error if NOT given an array', () => { | ||
// * GIVEN | ||
const ExcludeStubs = {}; | ||
// * THEN | ||
expect(jest.fn(() => customJestStubs.customStubs(ExcludeStubs))).toThrow( | ||
'EXCLUDED_STUBS_TYPEERROR' | ||
); | ||
}); | ||
describe('useMinified is false', () => { | ||
test('return array with excluded module path instead of stub path', () => { | ||
// * GIVEN | ||
const ExcludeStubs = [ | ||
{ | ||
name: '/SuiteScripts/Modules/aModule', | ||
path: `<rootDir>/src/FileCabinet`, | ||
useMinified: { | ||
value: false, | ||
}, | ||
}, | ||
]; | ||
const ExpectedResult = [ | ||
{ | ||
module: '/SuiteScripts/Modules/aModule', | ||
path: `<rootDir>/src/FileCabinet/SuiteScripts/Modules/aModule.js`, | ||
}, | ||
{ | ||
module: '/SuiteScripts/Modules/aModule.min', | ||
path: `<rootDir>/src/FileCabinet/SuiteScripts/Modules/aModule.js`, | ||
}, | ||
{ | ||
module: '/SuiteScripts/Modules/bModule', | ||
path: `<rootDir>/node_modules/@vnetwork-solutions/ns-custom-stubs-template/stubs/SuiteScripts/Modules/bModule`, | ||
}, | ||
{ | ||
module: '/SuiteScripts/Modules/bModule.min', | ||
path: `<rootDir>/node_modules/@vnetwork-solutions/ns-custom-stubs-template/stubs/SuiteScripts/Modules/bModule`, | ||
}, | ||
]; | ||
// * WHEN | ||
const CustomStubsList = customJestStubs.customStubs(ExcludeStubs); | ||
// * THEN | ||
expect(CustomStubsList).toEqual(expect.arrayContaining(ExpectedResult)); | ||
}); | ||
}); | ||
describe('useMinified is true', () => { | ||
/* test.todo( | ||
'should return array with minified excluded module path instead of stub path ' | ||
); */ | ||
test('return array with excluded module path instead of stub path', () => { | ||
// * GIVEN | ||
const ExcludeStubs = [ | ||
{ | ||
name: '/SuiteScripts/Modules/aModule', | ||
path: `<rootDir>/src/FileCabinet`, | ||
useMinified: { | ||
value: true, | ||
}, | ||
}, | ||
{ | ||
name: '/SuiteScripts/Modules/bModule.min', | ||
path: `<rootDir>/src/FileCabinet`, | ||
useMinified: { | ||
value: false, | ||
}, | ||
}, | ||
]; | ||
const ExpectedResult = [ | ||
{ | ||
module: '/SuiteScripts/Modules/aModule', | ||
path: `<rootDir>/src/FileCabinet/SuiteScripts/Modules/aModule.js`, | ||
}, | ||
{ | ||
module: '/SuiteScripts/Modules/aModule.min', | ||
path: `<rootDir>/src/FileCabinet/SuiteScripts/Modules/aModule.min.js`, | ||
}, | ||
{ | ||
module: '/SuiteScripts/Modules/bModule', | ||
path: `<rootDir>/node_modules/@vnetwork-solutions/ns-custom-stubs-template/stubs/SuiteScripts/Modules/bModule`, | ||
}, | ||
{ | ||
module: '/SuiteScripts/Modules/bModule.min', | ||
path: `<rootDir>/src/FileCabinet/SuiteScripts/Modules/bModule.js`, | ||
}, | ||
]; | ||
// * WHEN | ||
const CustomStubsList = customJestStubs.customStubs(ExcludeStubs); | ||
// * THEN | ||
expect(CustomStubsList).toEqual(expect.arrayContaining(ExpectedResult)); | ||
}); | ||
}); | ||
}); | ||
}); | ||
</code></pre> | ||
</article> | ||
</section> | ||
|
||
|
||
|
||
|
||
</div> | ||
|
||
<nav> | ||
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-aModule.html">aModule</a></li><li><a href="module-bModule.html">bModule</a></li><li><a href="module-CustomJestStubs.html">CustomJestStubs</a></li><li><a href="module-customModule_CS-test.html">customModule_CS-test</a></li><li><a href="module-JestConfig.html">JestConfig</a></li></ul> | ||
</nav> | ||
|
||
<br class="clear"> | ||
|
||
<footer> | ||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Nov 28 2022 14:49:55 GMT+0000 (Coordinated Universal Time) | ||
</footer> | ||
|
||
<script> prettyPrint(); </script> | ||
<script src="scripts/linenumber.js"> </script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.