mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
27 lines
633 B
TypeScript
27 lines
633 B
TypeScript
import assert from 'node:assert';
|
|
import { _, stubA } from './utils';
|
|
|
|
describe('now', () => {
|
|
it('should return the number of milliseconds that have elapsed since the Unix epoch', (done) => {
|
|
const stamp = +new Date(),
|
|
actual = _.now();
|
|
|
|
assert.ok(actual >= stamp);
|
|
|
|
setTimeout(() => {
|
|
assert.ok(_.now() > actual);
|
|
done();
|
|
}, 32);
|
|
});
|
|
|
|
it('should work with mocked `Date.now`', () => {
|
|
const now = Date.now;
|
|
Date.now = stubA;
|
|
|
|
const actual = _.now();
|
|
Date.now = now;
|
|
|
|
assert.strictEqual(actual, 'a');
|
|
});
|
|
});
|