[tests][perf] added perf() tests -> 100% coverage
This commit is contained in:
parent
042b4bd736
commit
548086db7a
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue