feat: promisify netLog.stopLogging (#16862)

This commit is contained in:
Milan Burda 2019-02-19 11:48:27 +01:00 committed by Alexey Kuzmin
parent 3b74837020
commit 7e7abc28f5
9 changed files with 78 additions and 35 deletions

View file

@ -60,7 +60,26 @@ describe('netLog module', () => {
}
})
it('should begin and end logging to file when .startLogging() and .stopLogging() is called', done => {
it('should begin and end logging to file when .startLogging() and .stopLogging() is called', async () => {
expect(netLog.currentlyLogging).to.be.false()
expect(netLog.currentlyLoggingPath).to.equal('')
netLog.startLogging(dumpFileDynamic)
expect(netLog.currentlyLogging).to.be.true()
expect(netLog.currentlyLoggingPath).to.equal(dumpFileDynamic)
const path = await netLog.stopLogging()
expect(netLog.currentlyLogging).to.be.false()
expect(netLog.currentlyLoggingPath).to.equal('')
expect(path).to.equal(dumpFileDynamic)
expect(fs.existsSync(dumpFileDynamic)).to.be.true()
})
// TODO(miniak): remove when promisification is complete
it('should begin and end logging to file when .startLogging() and .stopLogging() is called (callback)', done => {
expect(netLog.currentlyLogging).to.be.false()
expect(netLog.currentlyLoggingPath).to.equal('')
@ -80,7 +99,20 @@ describe('netLog module', () => {
})
})
it('should silence when .stopLogging() is called without calling .startLogging()', done => {
it('should silence when .stopLogging() is called without calling .startLogging()', async () => {
expect(netLog.currentlyLogging).to.be.false()
expect(netLog.currentlyLoggingPath).to.equal('')
const path = await netLog.stopLogging()
expect(netLog.currentlyLogging).to.be.false()
expect(netLog.currentlyLoggingPath).to.equal('')
expect(path).to.equal('')
})
// TODO(miniak): remove when promisification is complete
it('should silence when .stopLogging() is called without calling .startLogging() (callback)', done => {
expect(netLog.currentlyLogging).to.be.false()
expect(netLog.currentlyLoggingPath).to.equal('')