|
| 1 | +const uuid = require('uuid'); |
| 2 | +const { |
| 3 | + NIL: NIL_UUID, |
| 4 | + parse: uuidParse, |
| 5 | + stringify: uuidStringify, |
| 6 | + v1: uuidv1, |
| 7 | + v3: uuidv3, |
| 8 | + v4: uuidv4, |
| 9 | + v5: uuidv5, |
| 10 | + validate: uuidValidate, |
| 11 | + version: uuidVersion, |
| 12 | +} = uuid; |
| 13 | + |
| 14 | +const { default: testpage } = require('../utils/testpage'); |
| 15 | + |
| 16 | +testpage(function (addTest, done) { |
| 17 | + addTest('Named exports'); |
| 18 | + |
| 19 | + addTest('uuidv1()', uuidv1()); |
| 20 | + |
| 21 | + addTest('uuidv4()', uuidv4()); |
| 22 | + |
| 23 | + // ... using predefined DNS namespace (for domain names) |
| 24 | + addTest('uuidv3() DNS', uuidv3('hello.example.com', uuidv3.DNS)); |
| 25 | + |
| 26 | + // ... using predefined URL namespace (for, well, URLs) |
| 27 | + addTest('uuidv3() URL', uuidv3('http://example.com/hello', uuidv3.URL)); |
| 28 | + |
| 29 | + // ... using a custom namespace |
| 30 | + // |
| 31 | + // Note: Custom namespaces should be a UUID string specific to your application! |
| 32 | + // E.g. the one here was generated using this modules `uuid` CLI. |
| 33 | + const MY_NAMESPACE = '55238d15-c926-4598-b49d-cf4e913ba13c'; |
| 34 | + addTest('uuidv3() MY_NAMESPACE', uuidv3('Hello, World!', MY_NAMESPACE)); |
| 35 | + |
| 36 | + // ... using predefined DNS namespace (for domain names) |
| 37 | + addTest('uuidv5() DNS', uuidv5('hello.example.com', uuidv5.DNS)); |
| 38 | + |
| 39 | + // ... using predefined URL namespace (for, well, URLs) |
| 40 | + addTest('uuidv5() URL', uuidv5('http://example.com/hello', uuidv5.URL)); |
| 41 | + |
| 42 | + // ... using a custom namespace |
| 43 | + // |
| 44 | + // Note: Custom namespaces should be a UUID string specific to your application! |
| 45 | + // E.g. the one here was generated using this modules `uuid` CLI. |
| 46 | + // const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341'; |
| 47 | + addTest('uuidv5() MY_NAMESPACE', uuidv5('Hello, World!', MY_NAMESPACE)); |
| 48 | + |
| 49 | + // Utility functions |
| 50 | + addTest('NIL_UUID', NIL_UUID); |
| 51 | + addTest('uuidParse()', uuidParse(MY_NAMESPACE)); |
| 52 | + addTest('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE))); |
| 53 | + addTest('uuidValidate()', uuidValidate(MY_NAMESPACE)); |
| 54 | + addTest('uuidVersion()', uuidVersion(MY_NAMESPACE)); |
| 55 | + |
| 56 | + addTest('Default export'); |
| 57 | + |
| 58 | + addTest('uuid.v1()', uuid.v1()); |
| 59 | + addTest('uuid.v4()', uuid.v4()); |
| 60 | + addTest('uuid.v3() DNS', uuid.v3('hello.example.com', uuid.v3.DNS)); |
| 61 | + addTest('uuid.v3() URL', uuid.v3('http://example.com/hello', uuid.v3.URL)); |
| 62 | + addTest('uuid.v3() MY_NAMESPACE', uuid.v3('Hello, World!', MY_NAMESPACE)); |
| 63 | + addTest('uuid.v5() DNS', uuid.v5('hello.example.com', uuid.v5.DNS)); |
| 64 | + addTest('uuid.v5() URL', uuid.v5('http://example.com/hello', uuid.v5.URL)); |
| 65 | + addTest('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE)); |
| 66 | + |
| 67 | + addTest('uuid.NIL', uuid.NIL); |
| 68 | + addTest('uuid.parse()', uuid.parse(MY_NAMESPACE)); |
| 69 | + addTest('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE))); |
| 70 | + addTest('uuid.validate()', uuid.validate(MY_NAMESPACE)); |
| 71 | + addTest('uuid.version()', uuid.version(MY_NAMESPACE)); |
| 72 | + |
| 73 | + done(); |
| 74 | +}); |
5 commit comments
monsieurnebo commentedon Aug 3, 2022
@ctavan @SimenB Thanks for that guys π
Is a release planned soon to publish this fix?
ctavan commentedon Aug 3, 2022
I hope I will be able to finish up the release this week.
SimenB commentedon Aug 3, 2022
FWIW a stable release of
jest@29
will also come this weekmonsieurnebo commentedon Aug 3, 2022
Glad to hear. I'm tracking this as well.
ctavan commentedon Aug 5, 2022
I have released
uuid@9.0.0-beta.0
that contains this patch. Please try it out and let me know if it fixes the Jest interoperability (to be tested withjest@29.0.0-alpha.1
).