From 9055d97bd15749236f3f76b61ca89d94484190ea Mon Sep 17 00:00:00 2001 From: Naseem Date: Mon, 5 Oct 2020 20:09:37 -0400 Subject: [PATCH] fix: make test read better Signed-off-by: Naseem --- .../test/mysql.test.ts | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/plugins/node/opentelemetry-plugin-mysql/test/mysql.test.ts b/plugins/node/opentelemetry-plugin-mysql/test/mysql.test.ts index acf971547a..d1cb4909cf 100644 --- a/plugins/node/opentelemetry-plugin-mysql/test/mysql.test.ts +++ b/plugins/node/opentelemetry-plugin-mysql/test/mysql.test.ts @@ -124,30 +124,34 @@ describe('mysql@2.x', () => { assert.strictEqual(plugin.moduleName, 'mysql'); }); - it('should name the span correctly when the query is a string', done => { - const span = provider.getTracer('default').startSpan('test span'); - provider.getTracer('default').withSpan(span, () => { - const sql = 'SELECT 1+1 as solution'; - const query = connection.query(sql); - - query.on('end', () => { - const spans = memoryExporter.getFinishedSpans(); - assert.strictEqual(spans[0].name, 'SELECT'); - done(); + describe('when the query is a string', () => { + it('should name the span accordingly ', done => { + const span = provider.getTracer('default').startSpan('test span'); + provider.getTracer('default').withSpan(span, () => { + const sql = 'SELECT 1+1 as solution'; + const query = connection.query(sql); + + query.on('end', () => { + const spans = memoryExporter.getFinishedSpans(); + assert.strictEqual(spans[0].name, 'SELECT'); + done(); + }); }); }); }); - it('should name the span correctly when the query is an object', done => { - const span = provider.getTracer('default').startSpan('test span'); - provider.getTracer('default').withSpan(span, () => { - const sql = 'SELECT 1+? as solution'; - const query = connection.query({ sql, values: [1] }); + describe('when the query is an object', () => { + it('should name the span accordingly ', done => { + const span = provider.getTracer('default').startSpan('test span'); + provider.getTracer('default').withSpan(span, () => { + const sql = 'SELECT 1+? as solution'; + const query = connection.query({ sql, values: [1] }); - query.on('end', () => { - const spans = memoryExporter.getFinishedSpans(); - assert.strictEqual(spans[0].name, sql); - done(); + query.on('end', () => { + const spans = memoryExporter.getFinishedSpans(); + assert.strictEqual(spans[0].name, sql); + done(); + }); }); }); });