Skip to content

Commit

Permalink
Add test for primitive dates
Browse files Browse the repository at this point in the history
  • Loading branch information
dvd-z committed Apr 4, 2021
1 parent 2fba04a commit 405b6c4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ describe('#event', () => {
});
});

it('should send proper event format for title, text, and options for primitive dates', done => {
const date = Math.round(Date.now() / 1000);
const dateAsDate = new Date(date);
server = createServer(serverType, opts => {
statsd = createHotShotsClient(opts, clientType);
const options = {
date_happened: date,
hostname: 'host',
aggregation_key: 'ag_key',
priority: 'low',
source_type_name: 'source_type',
alert_type: 'warning'
};
statsd.event('test title', 'another\nmultiline\ndescription', options);
});
server.on('metrics', event => {
assert.strictEqual(event, `_e{10,31}:test title|another\\nmultiline\\ndescription|d:${dateAsDate.getTime()}|h:host|k:ag_key|p:low|s:source_type|t:warning${metricEnd}`
);
done();
});
});

it('should send proper event format for title, text, some options, and tags', done => {
server = createServer(serverType, opts => {
statsd = createHotShotsClient(opts, clientType);
Expand Down

0 comments on commit 405b6c4

Please sign in to comment.