Skip to content

Commit cc597ca

Browse files
committed
Replace DOS -> Unix fileformat
Ref globalizejs#81
1 parent b60e114 commit cc597ca

File tree

7 files changed

+182
-182
lines changed

7 files changed

+182
-182
lines changed

test/formatCurrency.spec.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
/*global expect React shallow Globalize*/
2-
import FormatCurrency from "../src/currency";
3-
4-
describe("formatCurrency Component", () => {
5-
it("renders as a <span>", () => {
6-
const wrapper = shallow(<FormatCurrency currency="USD">{150}</FormatCurrency>);
7-
expect(wrapper.type()).to.equal("span");
8-
});
9-
10-
it("formats 150 as $150.00", () => {
11-
const wrapper = shallow(<FormatCurrency currency="USD">{150}</FormatCurrency>);
12-
expect(wrapper.text()).to.equal("$150.00");
13-
});
14-
});
1+
/*global expect React shallow Globalize*/
2+
import FormatCurrency from "../src/currency";
3+
4+
describe("formatCurrency Component", () => {
5+
it("renders as a <span>", () => {
6+
const wrapper = shallow(<FormatCurrency currency="USD">{150}</FormatCurrency>);
7+
expect(wrapper.type()).to.equal("span");
8+
});
9+
10+
it("formats 150 as $150.00", () => {
11+
const wrapper = shallow(<FormatCurrency currency="USD">{150}</FormatCurrency>);
12+
expect(wrapper.text()).to.equal("$150.00");
13+
});
14+
});

test/formatDate.spec.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
/*global expect React shallow Globalize*/
2-
import FormatDate from "../src/date";
3-
4-
describe("formatDate Component", () => {
5-
it("renders as a <span>", () => {
6-
const wrapper = shallow(<FormatDate options={{date: "medium"}}>{new Date()}</FormatDate>);
7-
expect(wrapper.type()).to.equal("span");
8-
});
9-
10-
it("formats date using default pattern as 1/1/2016", () => {
11-
const wrapper = shallow(<FormatDate>{new Date("Jan 01 2016")}</FormatDate>);
12-
expect(wrapper.text()).to.equal("1/1/2016");
13-
});
14-
15-
it("formats date using options 'Jan 1, 2016'", () => {
16-
const wrapper = shallow(<FormatDate options={{date: "medium"}}>{new Date(2016, 0, 1)}</FormatDate>);
17-
expect(wrapper.text()).to.equal("Jan 1, 2016");
18-
});
19-
});
1+
/*global expect React shallow Globalize*/
2+
import FormatDate from "../src/date";
3+
4+
describe("formatDate Component", () => {
5+
it("renders as a <span>", () => {
6+
const wrapper = shallow(<FormatDate options={{date: "medium"}}>{new Date()}</FormatDate>);
7+
expect(wrapper.type()).to.equal("span");
8+
});
9+
10+
it("formats date using default pattern as 1/1/2016", () => {
11+
const wrapper = shallow(<FormatDate>{new Date("Jan 01 2016")}</FormatDate>);
12+
expect(wrapper.text()).to.equal("1/1/2016");
13+
});
14+
15+
it("formats date using options 'Jan 1, 2016'", () => {
16+
const wrapper = shallow(<FormatDate options={{date: "medium"}}>{new Date(2016, 0, 1)}</FormatDate>);
17+
expect(wrapper.text()).to.equal("Jan 1, 2016");
18+
});
19+
});

test/formatMessage.spec.js

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
1-
/*global expect React shallow Globalize*/
2-
import FormatMessage from "../src/message";
3-
4-
Globalize.loadMessages({
5-
en: {
6-
salutations: {
7-
hi: "Hi"
8-
},
9-
variables: {
10-
hello: "Hello, {0} {1} {2}"
11-
},
12-
party: [
13-
"{hostGender, select,",
14-
" female {{host} invites {guest} to her party}",
15-
" male {{host} invites {guest} to his party}",
16-
" other {{host} invites {guest} to their party}",
17-
"}"
18-
],
19-
task: [
20-
"You have {count, plural,",
21-
" =0 {no tasks}",
22-
" one {one task}",
23-
" other {{formattedCount} tasks}",
24-
"} remaining"
25-
]
26-
}
27-
});
28-
29-
[ "development", "production" ].forEach((env) => {
30-
describe(`formatMessage Component (${env})`, () => {
31-
var originalEnv = process.env.NODE_ENV;
32-
33-
before(() => {
34-
process.env.NODE_ENV = env;
35-
});
36-
37-
after(() => {
38-
process.env.NODE_ENV = originalEnv;
39-
});
40-
41-
it("renders as a <span>", () => {
42-
const wrapper = shallow(<FormatMessage path="salutations/hi" />);
43-
expect(wrapper.type()).to.equal("span");
44-
});
45-
46-
it("uses default message and prints 'Hi'", () => {
47-
const wrapper = shallow(<FormatMessage>Hi</FormatMessage>);
48-
expect(wrapper.text()).to.equal("Hi");
49-
});
50-
51-
it("resolves path and prints 'Hi'", () => {
52-
const wrapper = shallow(<FormatMessage path="salutations/hi" />);
53-
expect(wrapper.text()).to.equal("Hi");
54-
});
55-
56-
it("properly replaces variables", () => {
57-
const wrapper = shallow(<FormatMessage path="variables/hello" variables={["Wolfgang", "Amadeus", "Mozart"]} />);
58-
expect(wrapper.text()).to.equal("Hello, Wolfgang Amadeus Mozart");
59-
});
60-
61-
it("uses proper gender inflection", () => {
62-
const wrapper = shallow(<FormatMessage path="party" variables={{guest:"Mozart", guestGender:"male", host:"Beethoven", hostGender:"other"}} />);
63-
expect(wrapper.text()).to.equal("Beethoven invites Mozart to their party");
64-
});
65-
66-
it("uses proper plural inflection", () => {
67-
const wrapper = shallow(<FormatMessage path="task" variables={{count: 1}} />);
68-
expect(wrapper.text()).to.equal("You have one task remaining");
69-
});
70-
71-
it("updates when children change", () => {
72-
const wrapper = shallow(<FormatMessage>Hello</FormatMessage>);
73-
wrapper.setProps({ children: "Goodbye" });
74-
expect(wrapper.text()).to.equal("Goodbye");
75-
});
76-
});
77-
});
1+
/*global expect React shallow Globalize*/
2+
import FormatMessage from "../src/message";
3+
4+
Globalize.loadMessages({
5+
en: {
6+
salutations: {
7+
hi: "Hi"
8+
},
9+
variables: {
10+
hello: "Hello, {0} {1} {2}"
11+
},
12+
party: [
13+
"{hostGender, select,",
14+
" female {{host} invites {guest} to her party}",
15+
" male {{host} invites {guest} to his party}",
16+
" other {{host} invites {guest} to their party}",
17+
"}"
18+
],
19+
task: [
20+
"You have {count, plural,",
21+
" =0 {no tasks}",
22+
" one {one task}",
23+
" other {{formattedCount} tasks}",
24+
"} remaining"
25+
]
26+
}
27+
});
28+
29+
[ "development", "production" ].forEach((env) => {
30+
describe(`formatMessage Component (${env})`, () => {
31+
var originalEnv = process.env.NODE_ENV;
32+
33+
before(() => {
34+
process.env.NODE_ENV = env;
35+
});
36+
37+
after(() => {
38+
process.env.NODE_ENV = originalEnv;
39+
});
40+
41+
it("renders as a <span>", () => {
42+
const wrapper = shallow(<FormatMessage path="salutations/hi" />);
43+
expect(wrapper.type()).to.equal("span");
44+
});
45+
46+
it("uses default message and prints 'Hi'", () => {
47+
const wrapper = shallow(<FormatMessage>Hi</FormatMessage>);
48+
expect(wrapper.text()).to.equal("Hi");
49+
});
50+
51+
it("resolves path and prints 'Hi'", () => {
52+
const wrapper = shallow(<FormatMessage path="salutations/hi" />);
53+
expect(wrapper.text()).to.equal("Hi");
54+
});
55+
56+
it("properly replaces variables", () => {
57+
const wrapper = shallow(<FormatMessage path="variables/hello" variables={["Wolfgang", "Amadeus", "Mozart"]} />);
58+
expect(wrapper.text()).to.equal("Hello, Wolfgang Amadeus Mozart");
59+
});
60+
61+
it("uses proper gender inflection", () => {
62+
const wrapper = shallow(<FormatMessage path="party" variables={{guest:"Mozart", guestGender:"male", host:"Beethoven", hostGender:"other"}} />);
63+
expect(wrapper.text()).to.equal("Beethoven invites Mozart to their party");
64+
});
65+
66+
it("uses proper plural inflection", () => {
67+
const wrapper = shallow(<FormatMessage path="task" variables={{count: 1}} />);
68+
expect(wrapper.text()).to.equal("You have one task remaining");
69+
});
70+
71+
it("updates when children change", () => {
72+
const wrapper = shallow(<FormatMessage>Hello</FormatMessage>);
73+
wrapper.setProps({ children: "Goodbye" });
74+
expect(wrapper.text()).to.equal("Goodbye");
75+
});
76+
});
77+
});

test/formatNumber.spec.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
/*global expect React shallow Globalize*/
2-
import FormatNumber from "../src/number";
3-
4-
describe("formatNumber Component", () => {
5-
it("renders as a <span>", () => {
6-
const wrapper = shallow(<FormatNumber options={{ round: "floor" }}>{Math.PI}</FormatNumber>);
7-
expect(wrapper.type()).to.equal("span");
8-
});
9-
10-
it("formats pi as 3.141", () => {
11-
const wrapper = shallow(<FormatNumber options={{ round: "floor" }}>{Math.PI}</FormatNumber>);
12-
expect(wrapper.text()).to.equal("3.141");
13-
});
14-
});
1+
/*global expect React shallow Globalize*/
2+
import FormatNumber from "../src/number";
3+
4+
describe("formatNumber Component", () => {
5+
it("renders as a <span>", () => {
6+
const wrapper = shallow(<FormatNumber options={{ round: "floor" }}>{Math.PI}</FormatNumber>);
7+
expect(wrapper.type()).to.equal("span");
8+
});
9+
10+
it("formats pi as 3.141", () => {
11+
const wrapper = shallow(<FormatNumber options={{ round: "floor" }}>{Math.PI}</FormatNumber>);
12+
expect(wrapper.text()).to.equal("3.141");
13+
});
14+
});

test/formatRelativeTime.spec.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
/*global expect React shallow Globalize*/
2-
import FormatRelativeTime from "../src/relative-time";
3-
4-
describe("formatRelativeTime Component", () => {
5-
it("renders as a <span>", () => {
6-
const wrapper = shallow(<FormatRelativeTime unit="week">{1}</FormatRelativeTime>);
7-
expect(wrapper.type()).to.equal("span");
8-
});
9-
10-
it("formats value of 1 week from now as 'next week'", () => {
11-
const wrapper = shallow(<FormatRelativeTime unit="week">{1}</FormatRelativeTime>);
12-
expect(wrapper.text()).to.equal("next week");
13-
});
14-
});
1+
/*global expect React shallow Globalize*/
2+
import FormatRelativeTime from "../src/relative-time";
3+
4+
describe("formatRelativeTime Component", () => {
5+
it("renders as a <span>", () => {
6+
const wrapper = shallow(<FormatRelativeTime unit="week">{1}</FormatRelativeTime>);
7+
expect(wrapper.type()).to.equal("span");
8+
});
9+
10+
it("formats value of 1 week from now as 'next week'", () => {
11+
const wrapper = shallow(<FormatRelativeTime unit="week">{1}</FormatRelativeTime>);
12+
expect(wrapper.text()).to.equal("next week");
13+
});
14+
});

test/general.spec.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
/*global expect React shallow Globalize*/
2-
import FormatCurrency from "../src/currency";
3-
import FormatMessage from "../src/message";
4-
5-
describe("Any Component", () => {
6-
it("doesn't forward ReactGlobalize specific props to underlying DOM component", () => {
7-
let wrapper = shallow(<FormatCurrency locale="de" currency="EUR">{150}</FormatCurrency>);
8-
expect(wrapper.props()).to.contain.all.keys(["children"]);
9-
expect(wrapper.props()).to.not.contain.any.keys(["locale", "currency"]);
10-
11-
wrapper = shallow(<FormatMessage className="a-class-name" style={{aStyle: 1}} elements={{foo: 1}} variables={{bar: 2}}>Hello</FormatMessage>);
12-
expect(wrapper.props()).to.contain.all.keys(["children", "className", "style"]);
13-
expect(wrapper.props()).to.not.contain.any.keys(["elements", "variables"]);
14-
});
15-
16-
it("overrides default locale to format 150 as 150,00 €", () => {
17-
const wrapper = shallow(<FormatCurrency locale="de" currency="EUR">{150}</FormatCurrency>);
18-
expect(wrapper.text()).to.equal("150,00 €");
19-
});
20-
21-
it("updates when props change", () => {
22-
const wrapper = shallow(<FormatCurrency locale="de" currency="EUR">{150}</FormatCurrency>);
23-
expect(wrapper.text()).to.equal("150,00 €");
24-
wrapper.setProps({ children: 200, currency: "USD" });
25-
expect(wrapper.text()).to.equal("200,00 $");
26-
});
27-
});
1+
/*global expect React shallow Globalize*/
2+
import FormatCurrency from "../src/currency";
3+
import FormatMessage from "../src/message";
4+
5+
describe("Any Component", () => {
6+
it("doesn't forward ReactGlobalize specific props to underlying DOM component", () => {
7+
let wrapper = shallow(<FormatCurrency locale="de" currency="EUR">{150}</FormatCurrency>);
8+
expect(wrapper.props()).to.contain.all.keys(["children"]);
9+
expect(wrapper.props()).to.not.contain.any.keys(["locale", "currency"]);
10+
11+
wrapper = shallow(<FormatMessage className="a-class-name" style={{aStyle: 1}} elements={{foo: 1}} variables={{bar: 2}}>Hello</FormatMessage>);
12+
expect(wrapper.props()).to.contain.all.keys(["children", "className", "style"]);
13+
expect(wrapper.props()).to.not.contain.any.keys(["elements", "variables"]);
14+
});
15+
16+
it("overrides default locale to format 150 as 150,00 €", () => {
17+
const wrapper = shallow(<FormatCurrency locale="de" currency="EUR">{150}</FormatCurrency>);
18+
expect(wrapper.text()).to.equal("150,00 €");
19+
});
20+
21+
it("updates when props change", () => {
22+
const wrapper = shallow(<FormatCurrency locale="de" currency="EUR">{150}</FormatCurrency>);
23+
expect(wrapper.text()).to.equal("150,00 €");
24+
wrapper.setProps({ children: 200, currency: "USD" });
25+
expect(wrapper.text()).to.equal("200,00 $");
26+
});
27+
});

test/test_setup.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import { expect } from "chai";
2-
import React from "react";
3-
import { shallow } from "enzyme";
4-
import Globalize from "globalize";
5-
6-
global.expect = expect;
7-
global.React = React;
8-
global.shallow = shallow;
9-
global.Globalize = Globalize;
10-
11-
Globalize.load(
12-
require( "cldr-data" ).entireSupplemental(),
13-
require( "cldr-data" ).entireMainFor("en"),
14-
require( "cldr-data" ).entireMainFor("de")
15-
);
16-
17-
Globalize.locale("en");
1+
import { expect } from "chai";
2+
import React from "react";
3+
import { shallow } from "enzyme";
4+
import Globalize from "globalize";
5+
6+
global.expect = expect;
7+
global.React = React;
8+
global.shallow = shallow;
9+
global.Globalize = Globalize;
10+
11+
Globalize.load(
12+
require( "cldr-data" ).entireSupplemental(),
13+
require( "cldr-data" ).entireMainFor("en"),
14+
require( "cldr-data" ).entireMainFor("de")
15+
);
16+
17+
Globalize.locale("en");

0 commit comments

Comments
 (0)