| Total Complexity | 6 |
| Complexity/F | 1.5 |
| Lines of Code | 55 |
| Function Count | 4 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 1 | Features | 0 |
| 1 | // spec/index.spec.js |
||
| 2 | "use strict"; |
||
| 3 | |||
| 4 | // :: DEPENDENCIES |
||
| 5 | |||
| 6 | // load native dependencies |
||
| 7 | const path = require("path"); |
||
| 8 | |||
| 9 | // load local dependencies |
||
| 10 | const root = path.dirname(__dirname); |
||
| 11 | const ejsception = require(path.join(root, "index.js")); |
||
| 12 | const Throwable = require(path.join(root, "Throwable.js")); |
||
| 13 | const Exception = require(path.join(root, "Exception.js")); |
||
| 14 | |||
| 15 | // All accessible 'classes' |
||
| 16 | const classes = [ |
||
| 17 | "Throwable", |
||
| 18 | "Exception" |
||
| 19 | ]; |
||
| 20 | |||
| 21 | // wrap them in a plain object |
||
| 22 | const local = { |
||
| 23 | Throwable, |
||
| 24 | Exception |
||
| 25 | }; |
||
| 26 | |||
| 27 | // :: TESTING |
||
| 28 | |||
| 29 | // test the module |
||
| 30 | describe("ejsception | @egalabs/exception", () => { |
||
| 31 | |||
| 32 | // :: VARIABLES |
||
| 33 | |||
| 34 | let key; |
||
| 35 | const test = (() => ejsception[key] = 0); |
||
| 36 | const suite = (() => { |
||
| 37 | expect(ejsception[key]).toEqual(local[key]); |
||
| 38 | expect(ejsception[key].prototype).toEqual(local[key].prototype); |
||
| 39 | }); |
||
| 40 | |||
| 41 | // :: TESTING |
||
| 42 | |||
| 43 | it("should me immutable", () => { |
||
| 44 | for (let i = 0; i < classes.length; i += 1) { |
||
| 45 | key = classes[i]; |
||
| 46 | expect(test).toThrowErrorOfType("TypeError"); |
||
| 47 | } |
||
| 48 | }); |
||
| 49 | |||
| 50 | // test all 'classes' |
||
| 51 | for (let i = 0; i < classes.length; i += 1) { |
||
| 52 | key = classes[i]; |
||
| 53 | it("should have a " + key + " 'class'", suite); |
||
| 54 | } |
||
| 55 | |||
| 56 | }); |