Skip to content

Commit

Permalink
Merge pull request #19 from eik-lib/metrics
Browse files Browse the repository at this point in the history
feat: Add .metrics getter
  • Loading branch information
trygve-lie authored Jul 6, 2020
2 parents 892a80e + a5f3584 commit 93f3dc7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ const SinkCustom = class SinkCustom extends Sink {
});
}

get metrics() {
return // Custom metric stream code
}

get [Symbol.toStringTag]() {
return 'SinkCustom';
}
Expand Down
4 changes: 4 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const Sink = class Sink {
throw new Error('.exist method is not implemented');
}

get metrics() {
throw new Error('.metrics getter is not implemented');
}

static validateFilePath(filePath) {
if (typeof filePath !== 'string') throw new TypeError('Argument must be a String');
if (filePath === '') throw new TypeError('Argument can not be an empty String');
Expand Down
8 changes: 8 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ test('Sink() - Call .exist() method', (t) => {
t.end();
});

test('Sink() - Call .metrics getter', (t) => {
const obj = new Sink();
t.throws(() => {
const metric = obj.metrics; // eslint-disable-line no-unused-vars
}, /.metrics getter is not implemented/, 'Should throw');
t.end();
});

test('Sink() - Call .validateFilePath() with legal value', (t) => {
t.equal(Sink.validateFilePath('foo'), 'foo', 'Should return value');
t.end();
Expand Down

0 comments on commit 93f3dc7

Please sign in to comment.