@qoretechnologies/reqore 0.19.2 → 0.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ReqoreContent, ReqoreLayoutContent, ReqoreP, ReqoreUIProvider } from '../src';
|
|
4
|
+
import { TimeAgo } from '../src/components/TimeAgo';
|
|
5
|
+
|
|
6
|
+
test('Renders <TimeAgo /> data properly', () => {
|
|
7
|
+
render(
|
|
8
|
+
<ReqoreUIProvider>
|
|
9
|
+
<ReqoreLayoutContent>
|
|
10
|
+
<ReqoreContent>
|
|
11
|
+
<ReqoreP>
|
|
12
|
+
<TimeAgo time={Date.now()} />
|
|
13
|
+
</ReqoreP>
|
|
14
|
+
<ReqoreP>
|
|
15
|
+
<TimeAgo time='2021-11-29T14:48:35.846576+01:00' />
|
|
16
|
+
</ReqoreP>
|
|
17
|
+
</ReqoreContent>
|
|
18
|
+
</ReqoreLayoutContent>
|
|
19
|
+
</ReqoreUIProvider>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const firstPara = document.querySelectorAll('.reqore-paragraph')[0];
|
|
23
|
+
const secondPara = document.querySelectorAll('.reqore-paragraph')[1];
|
|
24
|
+
|
|
25
|
+
expect(firstPara.textContent).toBe('just now');
|
|
26
|
+
expect(secondPara.textContent).not.toBe('NaN');
|
|
27
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TimeAgo/index.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO;UAAsB,MAAM;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TimeAgo/index.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO;UAAsB,MAAM,GAAG,MAAM;SASxD,CAAC"}
|
|
@@ -11,10 +11,11 @@ var time_1 = require("../../helpers/time");
|
|
|
11
11
|
var TimeAgo = function (_a) {
|
|
12
12
|
var time = _a.time;
|
|
13
13
|
var _b = (0, react_1.useState)(Date.now()), _lastUpdate = _b[0], _setLastUpdate = _b[1];
|
|
14
|
+
var _time = typeof time === 'number' ? time : Date.parse(time);
|
|
14
15
|
(0, react_use_1.useInterval)(function () {
|
|
15
16
|
_setLastUpdate(Date.now());
|
|
16
|
-
}, (0, time_1.getTimeAgoIntervalDelay)(
|
|
17
|
-
return (0, epoch_timeago_1["default"])(
|
|
17
|
+
}, (0, time_1.getTimeAgoIntervalDelay)(_time));
|
|
18
|
+
return (0, epoch_timeago_1["default"])(_time);
|
|
18
19
|
};
|
|
19
20
|
exports.TimeAgo = TimeAgo;
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TimeAgo/index.tsx"],"names":[],"mappings":";;;;;;AAAA,gEAAoC;AACpC,+BAAiC;AACjC,uCAAwC;AACxC,2CAA6D;AAEtD,IAAM,OAAO,GAAG,UAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TimeAgo/index.tsx"],"names":[],"mappings":";;;;;;AAAA,gEAAoC;AACpC,+BAAiC;AACjC,uCAAwC;AACxC,2CAA6D;AAEtD,IAAM,OAAO,GAAG,UAAC,EAAmC;QAAjC,IAAI,UAAA;IACtB,IAAA,KAAgC,IAAA,gBAAQ,EAAS,IAAI,CAAC,GAAG,EAAE,CAAC,EAA3D,WAAW,QAAA,EAAE,cAAc,QAAgC,CAAC;IACnE,IAAM,KAAK,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEjE,IAAA,uBAAW,EAAC;QACV,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7B,CAAC,EAAE,IAAA,8BAAuB,EAAC,KAAK,CAAC,CAAC,CAAC;IAEnC,OAAO,IAAA,0BAAO,EAAC,KAAK,CAAC,CAAC;AACxB,CAAC,CAAC;AATW,QAAA,OAAO,WASlB"}
|