test-fns 1.4.2 → 1.5.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.
- package/dist/genTestUuid.d.ts +11 -0
- package/dist/genTestUuid.js +20 -0
- package/dist/genTestUuid.js.map +1 -0
- package/dist/genTestUuid.test.d.ts +1 -0
- package/dist/genTestUuid.test.js +20 -0
- package/dist/genTestUuid.test.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* generates a random uuid namespaced for tests, pattern `beef****-****-****-****-********beef`
|
|
3
|
+
*
|
|
4
|
+
* usecase
|
|
5
|
+
* - produces a uuid that can be clearly identified as one produced for tests
|
|
6
|
+
*/
|
|
7
|
+
export declare const genTestUuid: () => string;
|
|
8
|
+
/**
|
|
9
|
+
* decides whether a uuid is namespaced for tests
|
|
10
|
+
*/
|
|
11
|
+
export declare const isTestUuid: (userUuid: string) => boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTestUuid = exports.genTestUuid = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
/**
|
|
6
|
+
* generates a random uuid namespaced for tests, pattern `beef****-****-****-****-********beef`
|
|
7
|
+
*
|
|
8
|
+
* usecase
|
|
9
|
+
* - produces a uuid that can be clearly identified as one produced for tests
|
|
10
|
+
*/
|
|
11
|
+
const genTestUuid = () => {
|
|
12
|
+
return ['beef', (0, uuid_1.v4)().slice(4, -4), 'beef'].join('');
|
|
13
|
+
};
|
|
14
|
+
exports.genTestUuid = genTestUuid;
|
|
15
|
+
/**
|
|
16
|
+
* decides whether a uuid is namespaced for tests
|
|
17
|
+
*/
|
|
18
|
+
const isTestUuid = (userUuid) => /^beef.{4}-.{4}-.{4}-.{4}-.{8}beef$/.test(userUuid);
|
|
19
|
+
exports.isTestUuid = isTestUuid;
|
|
20
|
+
//# sourceMappingURL=genTestUuid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genTestUuid.js","sourceRoot":"","sources":["../src/genTestUuid.ts"],"names":[],"mappings":";;;AAAA,+BAAkC;AAElC;;;;;GAKG;AACI,MAAM,WAAW,GAAG,GAAW,EAAE;IACtC,OAAO,CAAC,MAAM,EAAE,IAAA,SAAI,GAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxD,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB;AAEF;;GAEG;AACI,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAW,EAAE,CACtD,oCAAoC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AADzC,QAAA,UAAU,cAC+B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const genTestUuid_1 = require("./genTestUuid");
|
|
4
|
+
describe('genTestUuid', () => {
|
|
5
|
+
it('should generate a uuid', () => {
|
|
6
|
+
const uuid = (0, genTestUuid_1.genTestUuid)();
|
|
7
|
+
expect(uuid).toBeTruthy();
|
|
8
|
+
});
|
|
9
|
+
it('should generate a uuid that is namespaced for testing by whodis', () => {
|
|
10
|
+
const uuid = (0, genTestUuid_1.genTestUuid)();
|
|
11
|
+
expect(uuid).toMatch(/^beef.*-.*-.*-.*-.*beef$/);
|
|
12
|
+
expect((0, genTestUuid_1.isTestUuid)(uuid)).toEqual(true);
|
|
13
|
+
});
|
|
14
|
+
it('should generate a uuid that is different every time', () => {
|
|
15
|
+
const uuid1 = (0, genTestUuid_1.genTestUuid)();
|
|
16
|
+
const uuid2 = (0, genTestUuid_1.genTestUuid)();
|
|
17
|
+
expect(uuid1).not.toEqual(uuid2);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=genTestUuid.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genTestUuid.test.js","sourceRoot":"","sources":["../src/genTestUuid.test.ts"],"names":[],"mappings":";;AAAA,+CAAwD;AAExD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,MAAM,IAAI,GAAG,IAAA,yBAAW,GAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,IAAI,GAAG,IAAA,yBAAW,GAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;QACjD,MAAM,CAAC,IAAA,wBAAU,EAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,MAAM,KAAK,GAAG,IAAA,yBAAW,GAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,IAAA,yBAAW,GAAE,CAAC;QAC5B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getError = exports.then = exports.when = exports.given = void 0;
|
|
3
|
+
exports.getError = exports.genTestUuid = exports.then = exports.when = exports.given = void 0;
|
|
4
4
|
var givenWhenThen_1 = require("./givenWhenThen");
|
|
5
5
|
Object.defineProperty(exports, "given", { enumerable: true, get: function () { return givenWhenThen_1.given; } });
|
|
6
6
|
Object.defineProperty(exports, "when", { enumerable: true, get: function () { return givenWhenThen_1.when; } });
|
|
7
7
|
Object.defineProperty(exports, "then", { enumerable: true, get: function () { return givenWhenThen_1.then; } });
|
|
8
|
+
var genTestUuid_1 = require("./genTestUuid");
|
|
9
|
+
Object.defineProperty(exports, "genTestUuid", { enumerable: true, get: function () { return genTestUuid_1.genTestUuid; } });
|
|
8
10
|
// forward the getError method since it is almost always needed with tests
|
|
9
11
|
var error_fns_1 = require("@ehmpathy/error-fns");
|
|
10
12
|
Object.defineProperty(exports, "getError", { enumerable: true, get: function () { return error_fns_1.getError; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAoD;AAA3C,sGAAA,KAAK,OAAA;AAAE,qGAAA,IAAI,OAAA;AAAE,qGAAA,IAAI,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAoD;AAA3C,sGAAA,KAAK,OAAA;AAAE,qGAAA,IAAI,OAAA;AAAE,qGAAA,IAAI,OAAA;AAC1B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AAEpB,0EAA0E;AAC1E,iDAA+C;AAAtC,qGAAA,QAAQ,OAAA"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "test-fns",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "write usecase driven tests systematically for simpler, safer, and more readable code",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.5.0",
|
|
6
6
|
"repository": "ehmpathy/test-fns",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/test-fns",
|
|
8
8
|
"keywords": [
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@trivago/prettier-plugin-sort-imports": "2.0.4",
|
|
55
55
|
"@tsconfig/node-lts-strictest": "18.12.1",
|
|
56
56
|
"@types/jest": "29.2.4",
|
|
57
|
+
"@types/uuid": "10.0.0",
|
|
57
58
|
"@typescript-eslint/eslint-plugin": "5.46.1",
|
|
58
59
|
"@typescript-eslint/parser": "5.46.1",
|
|
59
60
|
"core-js": "3.26.1",
|
|
@@ -80,6 +81,7 @@
|
|
|
80
81
|
},
|
|
81
82
|
"license": "MIT",
|
|
82
83
|
"dependencies": {
|
|
83
|
-
"@ehmpathy/error-fns": "1.3.1"
|
|
84
|
+
"@ehmpathy/error-fns": "1.3.1",
|
|
85
|
+
"uuid": "10.0.0"
|
|
84
86
|
}
|
|
85
87
|
}
|