[tests][perf] added perf() tests -> 100% coverage

This commit is contained in:
Salakar 2018-04-11 03:42:25 +01:00
parent 042b4bd736
commit 548086db7a
2 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,34 @@
describe('perf()', () => {
describe('setPerformanceCollectionEnabled()', () => {
it('true', async () => {
await firebase.perf().setPerformanceCollectionEnabled(true);
});
it('false', async () => {
await firebase.perf().setPerformanceCollectionEnabled(false);
});
xit('errors if not boolean', async () => {
// TODO add validations to lib
await firebase.perf().setPerformanceCollectionEnabled();
});
});
describe('newTrace()', () => {
it('returns an instance of Trace', async () => {
const trace = firebase.perf().newTrace('foo');
trace.constructor.name.should.be.equal('Trace');
});
xit('errors if identifier not a string', async () => {
// TODO add validations to lib
try {
firebase.perf().newTrace([1, 2, 3, 4]);
} catch (e) {
return undefined;
}
throw new Error('Trace did not error on invalid identifier');
});
});
});

View File

@ -0,0 +1,28 @@
describe('perf()', () => {
describe('Trace', () => {
it('start() & stop()', async () => {
const trace = firebase.perf().newTrace('bar');
await trace.start();
await trace.stop();
});
describe('incrementCounter()', () => {
it('accepts a string event', async () => {
const trace = firebase.perf().newTrace('bar');
await trace.start();
await trace.incrementCounter('fooby');
await trace.incrementCounter('fooby');
await trace.incrementCounter('fooby');
await trace.incrementCounter('fooby');
await trace.stop();
});
xit('errors if event is not a string', async () => {
const trace = firebase.perf().newTrace('bar');
await trace.start();
await trace.incrementCounter([1, 2, 3, 4]);
await trace.stop();
});
});
});
});