Skip to content

Commit c423113

Browse files
committed
add unit tests
1 parent 3392c95 commit c423113

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

packages/logging/test/entry.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,29 @@ describe('Entry', function() {
6767
assert.strictEqual(entry.metadata.timestamp, timestamp);
6868
});
6969

70+
it('should assign insertId to metadata', function() {
71+
assert(typeof entry.metadata.insertId === 'string');
72+
});
73+
74+
it('should generate monotonically increasing insertIds', function() {
75+
var entries = Array(256).fill({}).map(() => { return new Entry(); });
76+
entries.reduce((prev, entry) => {
77+
assert(typeof entry.metadata.insertId === 'string');
78+
assert(entry.metadata.insertId > prev);
79+
return entry.metadata.insertId;
80+
}, '');
81+
});
82+
83+
it('should not assign insertId if one is already set', function() {
84+
var insertId = 'fake-insert-id';
85+
86+
var entry = new Entry({
87+
insertId: insertId
88+
});
89+
90+
assert.strictEqual(entry.metadata.insertId, insertId);
91+
});
92+
7093
it('should localize data', function() {
7194
assert.strictEqual(entry.data, DATA);
7295
});

0 commit comments

Comments
 (0)