Skip to content

Commit

Permalink
⬆️ test: add coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed May 25, 2016
1 parent 2d683d8 commit f8ab51c
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 13 deletions.
22 changes: 14 additions & 8 deletions config/webpack.test.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var webpack = require("webpack");
var path = require("path");
var version = require("../package.json").version;

var merge = require("webpack-merge");
Expand All @@ -8,14 +9,19 @@ module.exports = merge(wpBaseConfig, {
entry: null,
output: null,
devtool: '#inline-source-map',
preLoaders: [
{
test: /\.js$/,
loader: 'isparta',
include: './lib',
exclude: /node_modules/
}
]
module: {
preLoaders: [
{
test: /\.js$/,
include: path.resolve('lib'),
loader: 'babel-istanbul',
query: {
cacheDirectory: true
}
}
]
}

});

delete module.exports.entry;
Expand Down
4 changes: 1 addition & 3 deletions lib/locales/default/address/geoLocationNearBy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function(coordinate, radius, isMetric) {
module.exports = function(coordinate, radius = 10.0, isMetric = true) {

function degreesToRadians(degrees) {
return degrees * (Math.PI / 180.0);
Expand Down Expand Up @@ -39,8 +39,6 @@ module.exports = function(coordinate, radius, isMetric) {
if (coordinate === undefined) {
return this.address.geoLocation();
}
radius = radius || 10.0;
isMetric = isMetric || true;

// TODO: implement either a gaussian/uniform distribution of points in cicular region.
// Possibly include param to function that allows user to choose between distributions.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"homepage": "https://github.com/icebob/fakerator#readme",
"devDependencies": {
"babel-core": "6.8.0",
"babel-istanbul-loader": "0.1.0",
"babel-loader": "6.2.4",
"babel-plugin-transform-runtime": "6.8.0",
"babel-preset-es2015": "6.6.0",
Expand All @@ -53,7 +54,6 @@
"eslint": "2.9.0",
"eslint-friendly-formatter": "2.0.4",
"inject-loader": "2.0.1",
"isparta-loader": "2.0.0",
"karma": "0.13.9",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "1.0.1",
Expand Down
19 changes: 19 additions & 0 deletions test/specs/locales/default/address.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ describe("Default address", () => {
expect(res.longitude).to.be.closeTo(-131.9741, 0.01);
});

it("check address.geoLocationNearBy without coordinates", () => {
let res = fakerator.address.geoLocationNearBy();
expect(res).to.be.an("Object");
expect(res.latitude).to.be.closeTo(40.4233, 0.01);
expect(res.longitude).to.be.closeTo(-131.9741, 0.01);

});

it("check address.geoLocationNearBy", () => {
let res = fakerator.address.geoLocationNearBy({
latitude: 40,
Expand All @@ -86,6 +94,17 @@ describe("Default address", () => {

});

it("check address.geoLocationNearBy with miles", () => {
let res = fakerator.address.geoLocationNearBy({
latitude: 40,
longitude: 19
}, 100, false);
expect(res).to.be.an("Object");
expect(res.latitude).to.be.closeTo(39.9104, 0.01);
expect(res.longitude).to.be.closeTo(18.2812, 0.01);

});

it("check address.altitude", () => {
expect(fakerator.populate("#{address.altitude}")).to.be.equal("6411");
expect(fakerator.address.altitude()).to.be.equal(1180);
Expand Down
5 changes: 5 additions & 0 deletions test/specs/seed.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ describe("Fakerator.seed", () => {
expect(fakerator.random.number(100)).to.be.equal(50);
});

it("check seed with array", () => {
fakerator.seed([42, 78]);
expect(fakerator.random.number(100)).to.be.equal(92);
});

})
7 changes: 7 additions & 0 deletions test/specs/times.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ describe("Fakerator.utimes", () => {
expect(res).to.be.deep.equal( [5, 6, 4, 1, 7, 3] );
});

it("check utimes function with min max", () => {
let res = fakerator.utimes(fakerator.random.number, { min: 3, max: 8}, 1, 10);
expect(res).to.be.an("Array");
expect(res).to.be.length(5);
expect(res).to.be.deep.equal( [5, 6, 4, 1, 7] );
});

it("check utimes function with 10 random.number between 1 to 10", () => {
let res = fakerator.utimes(fakerator.random.number, 10, 1, 10);
expect(res).to.be.an("Array");
Expand Down
2 changes: 1 addition & 1 deletion vendor/mersenne.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function MersenneTwister19937()
this.init_by_array = function (init_key, key_length)
{
//c//int i, j, k;
var i, j, k;
var i, j, k, dbg;
//c//init_genrand(19650218);
this.init_genrand(19650218);
i=1; j=0;
Expand Down

0 comments on commit f8ab51c

Please sign in to comment.