Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
fix(timing): skip warning for falsy value
Browse files Browse the repository at this point in the history
  • Loading branch information
dantam authored and SimeonC committed Jul 4, 2020
1 parent dcd7311 commit bf46430
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core.js
Expand Up @@ -272,7 +272,7 @@ export function timing(
trackerNames
) {
if (typeof ga === 'function') {
if (!category || !variable || !value || typeof value !== 'number') {
if (!category || !variable || typeof value !== 'number') {
warn(
'args.category, args.variable ' +
'AND args.value are required in timing() ' +
Expand Down
14 changes: 14 additions & 0 deletions test/functionality/timing.test.js
Expand Up @@ -79,6 +79,20 @@ describe('timing()', () => {
);
});

it('should not warn if value arg is 0, a falsy number', () => {
ReactGA.initialize('foo');
ReactGA.timing({
category: 'Test',
variable: 'Timing test',
value: 0
});
expect(spies.warn).not.toHaveBeenCalledWith(
'[react-ga]',
'args.category, args.variable AND args.value are required in timing() ' +
'AND args.value has to be a number'
);
});

it('should warn if value arg is not a number', () => {
ReactGA.initialize('foo');
ReactGA.timing({
Expand Down

0 comments on commit bf46430

Please sign in to comment.