Skip to content

Commit

Permalink
add local en-CA
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Jun 3, 2016
1 parent 6969491 commit b076585
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lib/locales/en-CA/address/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {

state: [
"Alberta",
"British Columbia",
"Manitoba",
"New Brunswick",
"Newfoundland and Labrador",
"Nova Scotia",
"Northwest Territories",
"Nunavut",
"Ontario",
"Prince Edward Island",
"Quebec",
"Saskatchewan",
"Yukon"
],
stateAbbr: [
"AB",
"BC",
"MB",
"NB",
"NL",
"NS",
"NU",
"NT",
"ON",
"PE",
"QC",
"SK",
"YT"
],

postCode: [
"?#? #?#"
]

};
39 changes: 39 additions & 0 deletions lib/locales/en-CA/address/streetSuffix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = [
"Avenue",
"Boulevard",
"Circle",
"Circuit",
"Court",
"Crescent",
"Crest",
"Drive",
"Estate Dr",
"Grove",
"Hill",
"Island",
"Junction",
"Knoll",
"Lane",
"Loop",
"Mall",
"Manor",
"Meadow",
"Mews",
"Parade",
"Parkway",
"Pass",
"Place",
"Plaza",
"Ridge",
"Road",
"Run",
"Square",
"Station St",
"Street",
"Summit",
"Terrace",
"Track",
"Trail",
"View Rd",
"Way"
];
24 changes: 24 additions & 0 deletions lib/locales/en-CA/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import isNil from "lodash/isNil";
import isArray from "lodash/isArray";
import isFunction from "lodash/isFunction";
import isObject from "lodash/isObject";
import mergeWith from "lodash/mergeWith";

import Fakerator from "lib/fakerator";

module.exports = function() {
let locale = require("lib/locales/en-CA");
let fbLocale = require("lib/locales/default");

// Merge locale and fallback
locale = mergeWith(locale, fbLocale, (objValue) => {
// DON'T MERGE ARRAYS
if (isArray(objValue) || isFunction(objValue))
return objValue;

if (!isNil(objValue) && !isObject(objValue))
return objValue;
});

return new Fakerator(locale);
};
12 changes: 12 additions & 0 deletions lib/locales/en-CA/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
_meta: {
id: "en-AU",
fallback: null,
language: "English (Canada)",
country: "Canada",
countryCode: "CA"
},

address: require("./address"),
internet: require("./internet")
};
12 changes: 12 additions & 0 deletions lib/locales/en-CA/internet/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
tld: [
"ca",
"com",
"biz",
"info",
"name",
"net",
"org"
]

};
8 changes: 8 additions & 0 deletions lib/locales/en-CA/phone/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
number: [
"0# #### ####",
"+61 # #### ####",
"04## ### ###",
"+61 4## ### ###"
]
};
31 changes: 31 additions & 0 deletions test/specs/locales/en-CA/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { expect } from "chai";

import Fakerator from "lib";

describe("Locale en-CA", () => {

let fakerator;

beforeEach( () => {
fakerator = new Fakerator("en-CA");
fakerator.seed(1111);
});

it("check locale definitions", () => {
expect(fakerator.locale.names).to.be.an("Object");
expect(fakerator.locale.phone).to.be.an("Object");
expect(fakerator.locale.address).to.be.an("Object");
expect(fakerator.locale.company).to.be.an("Object");
expect(fakerator.locale.internet).to.be.an("Object");
});

it("check address definitions", () => {
expect(fakerator.address.postCode()).to.be.equal("i4g 9i2");
expect(fakerator.address.state()).to.be.equal("Prince Edward Island");
});

it("check internet definitions", () => {
expect(fakerator.internet.domain()).to.be.equal("rolando.net");
});

});

0 comments on commit b076585

Please sign in to comment.