Skip to content

Commit ecc6802

Browse files
committed
Primer commit y primera versión OK
1 parent 166e650 commit ecc6802

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
package-lock.json

index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module.exports = {
2+
ok,
3+
info,
4+
error,
5+
aviso,
6+
mensajeBienvenida
7+
};
8+
9+
function ok(mensaje) {
10+
const estilos = 'background-color: green; color: white; font-size: 30px; display:block; text-align: center; text-decoration: underline';
11+
mostrarLog(mensaje, estilos);
12+
}
13+
14+
function info(mensaje) {
15+
const estilos = 'background-color: #80bfff; color: white; font-size: 30px; display:block; text-align: center; text-decoration: underline';
16+
mostrarLog(mensaje, estilos);
17+
}
18+
19+
function error(mensaje) {
20+
const estilos = 'background-color: #ff3300; color: white; font-size: 30px; display:block; text-align: center; text-decoration: underline';
21+
mostrarLog(mensaje, estilos);
22+
}
23+
24+
function aviso(mensaje) {
25+
const estilos = 'background-color: #ff9900; color: white; font-size: 30px; display:block; text-align: center; text-decoration: underline';
26+
mostrarLog(mensaje, estilos);
27+
}
28+
29+
function mostrarLog(mensaje, estilos) {
30+
console.log('%c%s', estilos, mensaje);
31+
}
32+
33+
function mensajeBienvenida() {
34+
return 'Hola!!!';
35+
}

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "custom-console-log",
3+
"version": "1.0.0",
4+
"description": "Log para consola personalizado.",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "mocha"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/npm-js-ts-angular-modules-course/proyecto-1c-custom-console-log.git"
12+
},
13+
"keywords": [
14+
"console",
15+
"log",
16+
"custom"
17+
],
18+
"author": "Anartz Mugika Ledo <mugan86@gmail.com>",
19+
"license": "MIT",
20+
"bugs": {
21+
"url": "https://github.com/npm-js-ts-angular-modules-course/proyecto-1c-custom-console-log/issues"
22+
},
23+
"homepage": "https://github.com/npm-js-ts-angular-modules-course/proyecto-1c-custom-console-log#readme",
24+
"devDependencies": {
25+
"chai": "^4.2.0",
26+
"mocha": "^5.2.0",
27+
"sinon": "^7.2.2",
28+
"sinon-chai": "^3.3.0"
29+
}
30+
}

test/index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const log = require('./../index');
2+
3+
var chai = require('chai'),
4+
expect = chai.expect,
5+
sinonChai = require('sinon-chai'),
6+
sinon = require('sinon');
7+
8+
chai.use(sinonChai);
9+
const MENSAJE = 'Hola, estamos en el curso de NPM!!';
10+
describe('Test de las funciones', () => {
11+
beforeEach( function() {
12+
sinon.spy(console, 'log');
13+
});
14+
afterEach( function() {
15+
console.log.restore();
16+
});
17+
it('Función ok', () => {
18+
log.ok(MENSAJE);
19+
expect(console.log).to.be.called;
20+
});
21+
it('Función info', () => {
22+
log.info(MENSAJE);
23+
expect(console.log).to.be.called;
24+
});
25+
it('Función aviso', () => {
26+
log.aviso(MENSAJE);
27+
expect(console.log).to.be.called;
28+
});
29+
it('Función error', () => {
30+
log.error(MENSAJE);
31+
expect(console.log).to.be.called;
32+
});
33+
34+
it('No llama al console log', () => {
35+
log.mensajeBienvenida();
36+
expect(console.log).to.not.be.called;
37+
});
38+
});

0 commit comments

Comments
 (0)