test-filesystem 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +163 -0
  3. package/browser/test-fs.js +2856 -0
  4. package/browser/test-fs.min.js +1 -0
  5. package/dist/cjs/functions/circularObject.js +54 -0
  6. package/dist/cjs/functions/circularObject.min.js +1 -0
  7. package/dist/cjs/functions/countMatches.js +17 -0
  8. package/dist/cjs/functions/countMatches.min.js +1 -0
  9. package/dist/cjs/functions/deepReferenceObject.js +24 -0
  10. package/dist/cjs/functions/deepReferenceObject.min.js +1 -0
  11. package/dist/cjs/functions/domItem.js +37 -0
  12. package/dist/cjs/functions/domItem.min.js +1 -0
  13. package/dist/cjs/functions/jsonDom.js +24 -0
  14. package/dist/cjs/functions/jsonDom.min.js +1 -0
  15. package/dist/cjs/functions/linkedList.js +27 -0
  16. package/dist/cjs/functions/linkedList.min.js +1 -0
  17. package/dist/cjs/functions/logObject.js +24 -0
  18. package/dist/cjs/functions/logObject.min.js +1 -0
  19. package/dist/cjs/functions/multiReferenceObject.js +24 -0
  20. package/dist/cjs/functions/multiReferenceObject.min.js +1 -0
  21. package/dist/cjs/functions/nodeTree.js +32 -0
  22. package/dist/cjs/functions/nodeTree.min.js +1 -0
  23. package/dist/cjs/functions/removeDirectory.js +19 -0
  24. package/dist/cjs/functions/removeDirectory.min.js +1 -0
  25. package/dist/cjs/functions/setUp.js +87 -0
  26. package/dist/cjs/functions/setUp.min.js +1 -0
  27. package/dist/cjs/main.js +58 -0
  28. package/dist/cjs/main.min.js +1 -0
  29. package/dist/mjs/functions/circularObject.d.ts +14 -0
  30. package/dist/mjs/functions/circularObject.min.mjs +1 -0
  31. package/dist/mjs/functions/circularObject.mjs +33 -0
  32. package/dist/mjs/functions/countMatches.d.ts +10 -0
  33. package/dist/mjs/functions/countMatches.min.mjs +1 -0
  34. package/dist/mjs/functions/countMatches.mjs +10 -0
  35. package/dist/mjs/functions/deepReferenceObject.d.ts +18 -0
  36. package/dist/mjs/functions/deepReferenceObject.min.mjs +1 -0
  37. package/dist/mjs/functions/deepReferenceObject.mjs +24 -0
  38. package/dist/mjs/functions/domItem.d.ts +24 -0
  39. package/dist/mjs/functions/domItem.min.mjs +1 -0
  40. package/dist/mjs/functions/domItem.mjs +30 -0
  41. package/dist/mjs/functions/jsonDom.d.ts +8 -0
  42. package/dist/mjs/functions/jsonDom.min.mjs +1 -0
  43. package/dist/mjs/functions/jsonDom.mjs +15 -0
  44. package/dist/mjs/functions/linkedList.d.ts +12 -0
  45. package/dist/mjs/functions/linkedList.min.mjs +1 -0
  46. package/dist/mjs/functions/linkedList.mjs +9 -0
  47. package/dist/mjs/functions/logObject.d.ts +11 -0
  48. package/dist/mjs/functions/logObject.min.mjs +1 -0
  49. package/dist/mjs/functions/logObject.mjs +17 -0
  50. package/dist/mjs/functions/multiReferenceObject.d.ts +18 -0
  51. package/dist/mjs/functions/multiReferenceObject.min.mjs +1 -0
  52. package/dist/mjs/functions/multiReferenceObject.mjs +24 -0
  53. package/dist/mjs/functions/nodeTree.d.ts +12 -0
  54. package/dist/mjs/functions/nodeTree.min.mjs +1 -0
  55. package/dist/mjs/functions/nodeTree.mjs +10 -0
  56. package/dist/mjs/functions/removeDirectory.d.ts +9 -0
  57. package/dist/mjs/functions/removeDirectory.min.mjs +1 -0
  58. package/dist/mjs/functions/removeDirectory.mjs +12 -0
  59. package/dist/mjs/functions/setUp.d.ts +30 -0
  60. package/dist/mjs/functions/setUp.min.mjs +1 -0
  61. package/dist/mjs/functions/setUp.mjs +56 -0
  62. package/dist/mjs/main.d.ts +93 -0
  63. package/dist/mjs/main.min.mjs +1 -0
  64. package/dist/mjs/main.mjs +50 -0
  65. package/gulpfile.js +221 -0
  66. package/package.json +58 -0
package/README.md ADDED
@@ -0,0 +1,163 @@
1
+ # test-fs
2
+ Set up and tear down a temp directory for running filesystem tests.
3
+
4
+ There are three options for accessing these functions:
5
+ 1. CommonJs modules: dist/cjs (default)
6
+ 2. ES6 modules: dist/mjs
7
+ 3. Bundles Browser file: browser/test-fs.js
8
+
9
+ ## Usage
10
+ To use the temporary directory in tests. Do the following in your tests:
11
+ ```js
12
+ import { setUp } from './setUp'
13
+
14
+ // Setup the name for your temporary directory
15
+ const dirName = 'test-temp/'
16
+
17
+ // Use the name
18
+ setUp.setDefaults(dirName)
19
+
20
+ // use the beforeEach and afterEach methods of jest to run the setup and teardown functions
21
+ beforeEach(
22
+ () => setUp.beforeEach()
23
+ .then(
24
+ () => {
25
+ // Put any additional setup logic here
26
+ }
27
+ )
28
+ )
29
+
30
+ afterEach(
31
+ () => setUp.afterEach()
32
+ .then(
33
+ () => {
34
+ // Put any additional teardown logic here
35
+ }
36
+ )
37
+ )
38
+ ```
39
+
40
+ <a name="module_test-fs"></a>
41
+
42
+ ## test-fs
43
+ An assortment of objects that can be used in tests and some functions to help debug and write tests.
44
+
45
+ **Version**: 1.0.0
46
+ **Author**: Joshua Heagle <joshuaheagle@gmail.com>
47
+
48
+ * [test-fs](#module_test-fs)
49
+ * [.nodeTree](#module_test-fs.nodeTree) : <code>Object.&lt;string, (string\|Object\|Array)&gt;</code>
50
+ * [.multiReferenceObject](#module_test-fs.multiReferenceObject) : <code>Object.&lt;string, (string\|number\|Object)&gt;</code>
51
+ * [.linkedList](#module_test-fs.linkedList) : <code>Object.&lt;string, (string\|Object)&gt;</code>
52
+ * [.jsonDom](#module_test-fs.jsonDom) : <code>Object.&lt;string, (string\|number\|Array\|Object)&gt;</code>
53
+ * [.domItem](#module_test-fs.domItem) : <code>Object.&lt;string, (string\|number\|Array\|Object)&gt;</code>
54
+ * [.deepReferenceObject](#module_test-fs.deepReferenceObject) : <code>Object.&lt;string, (string\|number\|Object)&gt;</code>
55
+ * [.circularObject](#module_test-fs.circularObject) : <code>Object.&lt;string, (string\|Object\|Array)&gt;</code>
56
+ * [.afterEach()](#module_test-fs.afterEach) ⇒ <code>Promise.&lt;\*&gt;</code>
57
+ * [.exports.afterEach([exists])](#module_test-fs.exports.afterEach) ⇒ <code>Promise.&lt;(\*\|void)&gt;</code>
58
+ * [.exports.createTempDir()](#module_test-fs.exports.createTempDir) ⇒ <code>Promise.&lt;(\*\|void)&gt;</code>
59
+ * [.removeDirectory(dirPath)](#module_test-fs.removeDirectory) ⇒ <code>Promise.&lt;\*&gt;</code>
60
+ * [.logObject(object, [label], [outputType])](#module_test-fs.logObject) ⇒ <code>string</code> \| <code>undefined</code>
61
+ * [.countMatches(content, search)](#module_test-fs.countMatches) ⇒ <code>number</code>
62
+
63
+ <a name="module_test-fs.nodeTree"></a>
64
+
65
+ ### test-fs.nodeTree : <code>Object.&lt;string, (string\|Object\|Array)&gt;</code>
66
+ Sample NodeTree for testing circular references and arrays.
67
+
68
+ **Kind**: static constant of [<code>test-fs</code>](#module_test-fs)
69
+ <a name="module_test-fs.multiReferenceObject"></a>
70
+
71
+ ### test-fs.multiReferenceObject : <code>Object.&lt;string, (string\|number\|Object)&gt;</code>
72
+ Sample of an object containing multiple references.
73
+
74
+ **Kind**: static constant of [<code>test-fs</code>](#module_test-fs)
75
+ <a name="module_test-fs.linkedList"></a>
76
+
77
+ ### test-fs.linkedList : <code>Object.&lt;string, (string\|Object)&gt;</code>
78
+ Sample LinkedList for testing circular references.
79
+
80
+ **Kind**: static constant of [<code>test-fs</code>](#module_test-fs)
81
+ <a name="module_test-fs.jsonDom"></a>
82
+
83
+ ### test-fs.jsonDom : <code>Object.&lt;string, (string\|number\|Array\|Object)&gt;</code>
84
+ Sample of jsonDom object containing an empty nested array and objects
85
+
86
+ **Kind**: static constant of [<code>test-fs</code>](#module_test-fs)
87
+ <a name="module_test-fs.domItem"></a>
88
+
89
+ ### test-fs.domItem : <code>Object.&lt;string, (string\|number\|Array\|Object)&gt;</code>
90
+ Sample of domItem child with nested child and optional details
91
+
92
+ **Kind**: static constant of [<code>test-fs</code>](#module_test-fs)
93
+ <a name="module_test-fs.deepReferenceObject"></a>
94
+
95
+ ### test-fs.deepReferenceObject : <code>Object.&lt;string, (string\|number\|Object)&gt;</code>
96
+ Sample object with deep references.
97
+
98
+ **Kind**: static constant of [<code>test-fs</code>](#module_test-fs)
99
+ <a name="module_test-fs.circularObject"></a>
100
+
101
+ ### test-fs.circularObject : <code>Object.&lt;string, (string\|Object\|Array)&gt;</code>
102
+ Multilayered node tree-like structure with parent references
103
+
104
+ **Kind**: static constant of [<code>test-fs</code>](#module_test-fs)
105
+ <a name="module_test-fs.afterEach"></a>
106
+
107
+ ### test-fs.afterEach() ⇒ <code>Promise.&lt;\*&gt;</code>
108
+ In the Jest.afterEach function call this one to clean up and remove the temp directory.
109
+
110
+ **Kind**: static method of [<code>test-fs</code>](#module_test-fs)
111
+ <a name="module_test-fs.exports.afterEach"></a>
112
+
113
+ ### test-fs.exports.afterEach([exists]) ⇒ <code>Promise.&lt;(\*\|void)&gt;</code>
114
+ Ensure that the del has completed, recursively attempt to delete and recreate
115
+
116
+ **Kind**: static method of [<code>test-fs</code>](#module_test-fs)
117
+
118
+ | Param | Type | Default |
119
+ | --- | --- | --- |
120
+ | [exists] | <code>boolean</code> | <code>true</code> |
121
+
122
+ <a name="module_test-fs.exports.createTempDir"></a>
123
+
124
+ ### test-fs.exports.createTempDir() ⇒ <code>Promise.&lt;(\*\|void)&gt;</code>
125
+ In the Jest.beforeEach function call this one to set up the temp directory.
126
+
127
+ **Kind**: static method of [<code>test-fs</code>](#module_test-fs)
128
+ <a name="module_test-fs.removeDirectory"></a>
129
+
130
+ ### test-fs.removeDirectory(dirPath) ⇒ <code>Promise.&lt;\*&gt;</code>
131
+ Return a promise to be completed once the specified directory is deleted.
132
+
133
+ **Kind**: static method of [<code>test-fs</code>](#module_test-fs)
134
+
135
+ | Param | Type |
136
+ | --- | --- |
137
+ | dirPath | <code>string</code> |
138
+
139
+ <a name="module_test-fs.logObject"></a>
140
+
141
+ ### test-fs.logObject(object, [label], [outputType]) ⇒ <code>string</code> \| <code>undefined</code>
142
+ Log out an object in a nicely formatted way.
143
+
144
+ **Kind**: static method of [<code>test-fs</code>](#module_test-fs)
145
+
146
+ | Param | Type | Default |
147
+ | --- | --- | --- |
148
+ | object | <code>Object</code> | |
149
+ | [label] | <code>string</code> | <code>&quot;logging&quot;</code> |
150
+ | [outputType] | <code>string</code> | <code>&quot;log&quot;</code> |
151
+
152
+ <a name="module_test-fs.countMatches"></a>
153
+
154
+ ### test-fs.countMatches(content, search) ⇒ <code>number</code>
155
+ Simple way to count string occurrences for testing.
156
+
157
+ **Kind**: static method of [<code>test-fs</code>](#module_test-fs)
158
+
159
+ | Param | Type |
160
+ | --- | --- |
161
+ | content | <code>string</code> |
162
+ | search | <code>string</code> |
163
+