Skip to content

Commit b076585

Browse files
committed
add local en-CA
1 parent 6969491 commit b076585

File tree

7 files changed

+164
-0
lines changed

7 files changed

+164
-0
lines changed

lib/locales/en-CA/address/index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module.exports = {
2+
3+
state: [
4+
"Alberta",
5+
"British Columbia",
6+
"Manitoba",
7+
"New Brunswick",
8+
"Newfoundland and Labrador",
9+
"Nova Scotia",
10+
"Northwest Territories",
11+
"Nunavut",
12+
"Ontario",
13+
"Prince Edward Island",
14+
"Quebec",
15+
"Saskatchewan",
16+
"Yukon"
17+
],
18+
stateAbbr: [
19+
"AB",
20+
"BC",
21+
"MB",
22+
"NB",
23+
"NL",
24+
"NS",
25+
"NU",
26+
"NT",
27+
"ON",
28+
"PE",
29+
"QC",
30+
"SK",
31+
"YT"
32+
],
33+
34+
postCode: [
35+
"?#? #?#"
36+
]
37+
38+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module.exports = [
2+
"Avenue",
3+
"Boulevard",
4+
"Circle",
5+
"Circuit",
6+
"Court",
7+
"Crescent",
8+
"Crest",
9+
"Drive",
10+
"Estate Dr",
11+
"Grove",
12+
"Hill",
13+
"Island",
14+
"Junction",
15+
"Knoll",
16+
"Lane",
17+
"Loop",
18+
"Mall",
19+
"Manor",
20+
"Meadow",
21+
"Mews",
22+
"Parade",
23+
"Parkway",
24+
"Pass",
25+
"Place",
26+
"Plaza",
27+
"Ridge",
28+
"Road",
29+
"Run",
30+
"Square",
31+
"Station St",
32+
"Street",
33+
"Summit",
34+
"Terrace",
35+
"Track",
36+
"Trail",
37+
"View Rd",
38+
"Way"
39+
];

lib/locales/en-CA/build.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import isNil from "lodash/isNil";
2+
import isArray from "lodash/isArray";
3+
import isFunction from "lodash/isFunction";
4+
import isObject from "lodash/isObject";
5+
import mergeWith from "lodash/mergeWith";
6+
7+
import Fakerator from "lib/fakerator";
8+
9+
module.exports = function() {
10+
let locale = require("lib/locales/en-CA");
11+
let fbLocale = require("lib/locales/default");
12+
13+
// Merge locale and fallback
14+
locale = mergeWith(locale, fbLocale, (objValue) => {
15+
// DON'T MERGE ARRAYS
16+
if (isArray(objValue) || isFunction(objValue))
17+
return objValue;
18+
19+
if (!isNil(objValue) && !isObject(objValue))
20+
return objValue;
21+
});
22+
23+
return new Fakerator(locale);
24+
};

lib/locales/en-CA/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
_meta: {
3+
id: "en-AU",
4+
fallback: null,
5+
language: "English (Canada)",
6+
country: "Canada",
7+
countryCode: "CA"
8+
},
9+
10+
address: require("./address"),
11+
internet: require("./internet")
12+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
tld: [
3+
"ca",
4+
"com",
5+
"biz",
6+
"info",
7+
"name",
8+
"net",
9+
"org"
10+
]
11+
12+
};

lib/locales/en-CA/phone/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
number: [
3+
"0# #### ####",
4+
"+61 # #### ####",
5+
"04## ### ###",
6+
"+61 4## ### ###"
7+
]
8+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { expect } from "chai";
2+
3+
import Fakerator from "lib";
4+
5+
describe("Locale en-CA", () => {
6+
7+
let fakerator;
8+
9+
beforeEach( () => {
10+
fakerator = new Fakerator("en-CA");
11+
fakerator.seed(1111);
12+
});
13+
14+
it("check locale definitions", () => {
15+
expect(fakerator.locale.names).to.be.an("Object");
16+
expect(fakerator.locale.phone).to.be.an("Object");
17+
expect(fakerator.locale.address).to.be.an("Object");
18+
expect(fakerator.locale.company).to.be.an("Object");
19+
expect(fakerator.locale.internet).to.be.an("Object");
20+
});
21+
22+
it("check address definitions", () => {
23+
expect(fakerator.address.postCode()).to.be.equal("i4g 9i2");
24+
expect(fakerator.address.state()).to.be.equal("Prince Edward Island");
25+
});
26+
27+
it("check internet definitions", () => {
28+
expect(fakerator.internet.domain()).to.be.equal("rolando.net");
29+
});
30+
31+
});

0 commit comments

Comments
 (0)