Skip to content

Instantly share code, notes, and snippets.

View ddialar's full-sized avatar

Dailos Rafael Díaz Lara ddialar

View GitHub Profile
{
"films": [
{
"id": 1,
"title": "Star Trek: The motion picture",
"year": "1979",
"director_id": 1
},
{
"id": 2,
@ddialar
ddialar / src.config.index.js
Last active August 7, 2017 18:17
log4js - configuration index.js file content
import SERVER_ENV from './server.config';
var environment = process.env.NODE_ENV || 'development';
var serverConf = SERVER_ENV[environment];
export {
serverConf
};
@ddialar
ddialar / src.config.server.config.js
Created August 7, 2017 18:18
log4js - basic server configuration
const SERVER_ENV = {
'production': { port: process.env.SERVER_PORT },
'development': { port: 4850 }
};
export default SERVER_ENV;
@ddialar
ddialar / src.server.js
Last active August 7, 2017 18:20
log4js - basic server configuration
import { serverConf } from './config';
import express from 'express';
import bodyParser from 'body-parser';
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
@ddialar
ddialar / src.server.js
Last active August 7, 2017 20:06
log4js - Server file including the Log4JS module.
import log4js from 'log4js';
var logger = log4js.getLogger('server.js');
logger.level = 'all';
import { serverConf } from './config';
import express from 'express';
import bodyParser from 'body-parser';
var app = express();
const sum = (a, b) => {
return a + b;
};
const dif = (a, b) => {
return a - b;
};
export {
sum,
{
"name": "jest.testing.manual.mocking",
"version": "1.0.0",
"description": "Basic script in order to test the Jest Testing Framework manual mocking.",
"main": "src/app.js",
"scripts": {
"dev": "NODE_ENV=development nodemon --watch src --exec babel-node src/app.js",
"test": "jest --watch"
},
"repository": {
import * as calculator from './utils/calculator';
const doASum = () => {
let a = 5;
let b = 10;
return calculator.sum(a, b);
};
const doADif = () => {
import 'jest';
import * as app from '../src/app';
describe('Testing the use of the \'calculator\' module', () => {
test('Testing doASum ...', () => {
expect(app.doASum()).toEqual(15);
});
});
import 'jest';
var sum = jest.fn().mockReturnValue(20);
var dif = jest.fn().mockReturnValue(-20);
const calculator = jest.mock('../calculator', () => {
return {
sum,
dif
};