From 4c6d21687a40a1982088dcae167627f63dbc4e47 Mon Sep 17 00:00:00 2001 From: Icebob Date: Wed, 25 May 2016 10:09:30 +0200 Subject: [PATCH] Add uuid generator --- lib/locales/default/index.js | 3 ++- lib/locales/default/misc/index.js | 5 +++++ package.json | 9 +++++---- test/specs/locales/default/misc.spec.js | 26 +++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 lib/locales/default/misc/index.js create mode 100644 test/specs/locales/default/misc.spec.js diff --git a/lib/locales/default/index.js b/lib/locales/default/index.js index b82b8d3c..b8902290 100644 --- a/lib/locales/default/index.js +++ b/lib/locales/default/index.js @@ -13,5 +13,6 @@ module.exports = { company: require("./company"), internet: require("./internet"), lorem: require("./lorem"), - date: require("./date") + date: require("./date"), + misc: require("./misc") }; \ No newline at end of file diff --git a/lib/locales/default/misc/index.js b/lib/locales/default/misc/index.js new file mode 100644 index 00000000..4340a34c --- /dev/null +++ b/lib/locales/default/misc/index.js @@ -0,0 +1,5 @@ +import uuid from "uuid"; + +module.exports = { + uuid: uuid.v4 +}; \ No newline at end of file diff --git a/package.json b/package.json index 5d6edaee..765c769e 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "src", "vendor", "test" - ], + ], "keywords": [ "fake", "contextual", @@ -53,7 +53,7 @@ "eslint": "2.9.0", "eslint-friendly-formatter": "2.0.4", "inject-loader": "2.0.1", - "isparta-loader": "2.0.0", + "isparta-loader": "2.0.0", "karma": "0.13.9", "karma-chai": "0.1.0", "karma-chrome-launcher": "1.0.1", @@ -66,14 +66,15 @@ "karma-spec-reporter": "0.0.26", "karma-webpack": "1.7.0", "lodash": "4.12.0", - "lolex": "1.4.0", + "lolex": "1.4.0", "mocha": "2.4.5", "mocha-generators": "1.2.0", - "mocha-loader": "0.7.1", + "mocha-loader": "0.7.1", "password-generator": "2.0.2", "phantomjs-prebuilt": "2.1.3", "sinon": "1.17.4", "sinon-chai": "2.8.0", + "uuid": "2.0.2", "webpack": "1.13.0", "webpack-merge": "0.12.0" } diff --git a/test/specs/locales/default/misc.spec.js b/test/specs/locales/default/misc.spec.js new file mode 100644 index 00000000..3eb69de5 --- /dev/null +++ b/test/specs/locales/default/misc.spec.js @@ -0,0 +1,26 @@ +import { expect } from "chai"; + +import Fakerator from "lib/fakerator"; + +describe("Default misc", () => { + + let fakerator; + + beforeEach( () => { + fakerator = new Fakerator(); + fakerator.seed(8080); + }); + + it("check misc.uuid", () => { + expect(fakerator.populate("#{misc.uuid}")).to.be + .an("String") + .length(36) + .match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/); + + expect(fakerator.misc.uuid()).to.be + .an("String") + .length(36) + .match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/); + }); + +}) \ No newline at end of file