UNPKG

@alu0101240374/addlogging

Version:
50 lines (46 loc) 1.67 kB
/** * Universidad de La Laguna * Escuela Superior de Ingenieria y Tecnologia * Grado de Ingenieri Informatica * @author Gabriel Garcia Jaubert * @date 10 mar 2020 * @brief This file provides code for testing the module */ let should = require('chai').should(); let {addLogging} = require('../index.js'); const FOO_FUNCTION = `let a = 0; function foo(name){}`; const FOO_FUNCTION_RESULT = `let a = 0; function foo(name) { console.log(\`Entering foo(\${ name }) at line 2\`); }`; const ARROW_FUNCTION = `let a = 0; hello = (a) => {};`; const ARROW_FUNCTION_RESULT = `let a = 0; hello = a => { console.log(\`Entering <anonymous function>(\${ a }) at line 2\`); };`; const ANONYMOUS_FUNCTION = `let a = (function() {});`; const ANONYMOS_FUNCTION_RESULT = `let a = function () { console.log(\`Entering <anonymous function>() at line 1\`); };`; const FOO_FUNCTION_PATTERN = `let a = 0; function foo(name){}`; const FOO_FUNCTION_PATTERN_RESULT = `let a = 0; function foo(name) { console.log(\`Entering foo(\${ name }) at line 2\`); }`; describe('-> addLogging', function() { it('Crea mensaje en una funcion foo', function() { addLogging(FOO_FUNCTION, 'foo').should.equal(FOO_FUNCTION_RESULT); }); it('Crea mensaje en una funcion arrow', function() { addLogging(ARROW_FUNCTION, 'foo').should.equal(ARROW_FUNCTION_RESULT); }); it('Crea mensaje en una funcion anonima', function() { addLogging(ANONYMOUS_FUNCTION, 'foo').should.equal(ANONYMOS_FUNCTION_RESULT); }); it('Crea mensaje en una funcion \'foo\' con pattern', function() { addLogging(FOO_FUNCTION_PATTERN, '.*').should.equal(FOO_FUNCTION_PATTERN_RESULT); }); });