Skip to content

Commit

Permalink
chore(babel-plugin-react-intl): add more test to enforceDefaultM… (#104)
Browse files Browse the repository at this point in the history
* chore(babel-plugin-react-intl): add more test to enforceDefaultMessage

* fix(intl-utils): fix tests
  • Loading branch information
longlho committed Apr 26, 2020
1 parent f68ad8f commit e843274
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React, { Component } from 'react';
import { FormattedMessage } from 'react-intl';
import { FormattedMessage, defineMessages } from 'react-intl';

defineMessages({
test: {
id: 'TRANSLATION_KEY'
},
})

export default class Foo extends Component {
render() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[
{
"id": "TRANSLATION_KEY"
},
{
"id": "foo.bar.baz"
}
]
]
16 changes: 2 additions & 14 deletions packages/formatjs/packages/intl-utils/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ function future(v?: number) {
return Date.now() + (v || 0);
}

function early() {
return new Date().setHours(1);
}

function late() {
return new Date().setHours(23);
}

function expectNoNumberInOutput(output: string) {
expect(/\d+/.test(output)).to.be.false;
}

const SEC = 1e3;
const MIN = SEC * 60;
const HOUR = MIN * 60;
Expand Down Expand Up @@ -79,11 +67,11 @@ describe('selectUnit', function() {
});
});
it('should work for day', function() {
expect(selectUnit(past(23 * HOUR), Date.now())).to.deep.equal({
expect(selectUnit(new Date(2019, 1, 5), new Date(2019, 1, 6))).to.deep.equal({
value: -1,
unit: 'day'
});
expect(selectUnit(future(26 * HOUR), Date.now())).to.deep.equal({
expect(selectUnit(new Date(2019, 1, 6), new Date(2019, 1, 5))).to.deep.equal({
value: 1,
unit: 'day'
});
Expand Down

0 comments on commit e843274

Please sign in to comment.