Skip to content

Instantly share code, notes, and snippets.

View ivanbtrujillo's full-sized avatar

Ivanbtrujillo ivanbtrujillo

View GitHub Profile
@ivanbtrujillo
ivanbtrujillo / angular2Testing.MD
Last active October 20, 2019 15:51
Angular2 Testing using AngularCli, Jasmine, Karma, Chai and PhantomJS

Angular2 Testing using AngularCli, Jasmine, Karma, Chai and PhantomJS

Tools

For unit testing in Angular2 we can configure a good environment using:

  • Jasmine: a framework to write test
  • karma: a test runner
  • chai: a bdd assertions library
  • Protractor: used to write end-to-end test. It explore the app as users experience it simulating user behaviour.
  • PhantomJS: a script browser to run the angular code and check if it works properly.
@ivanbtrujillo
ivanbtrujillo / switch-object.md
Created January 4, 2017 09:17
Don't use switch statement, instead use objects

Stop using switch like this:

switch(value){
  case 'a':
    console.log('value a');
    break;
  case 'b':
    console.log('value b');
 break;
@ivanbtrujillo
ivanbtrujillo / angular-boilerplate.MD
Last active March 5, 2017 17:52
Angular Cli with bootstrap 4 alpha

Includes Angular-cli, Bootstrap 4 alpha, Chai, Karma and Protractor

Update node using NVM:

nvm ls-remote
nvm install v7.7.1

Install angular cli:

@ivanbtrujillo
ivanbtrujillo / index.js
Last active June 18, 2017 13:41
GraphQL. 02 - Servidor en Node con Express - 01
// Importamos la librería express
const express = require('express');
// Creamos una aplicación express
const app = express();
/*
Indicamos que escuche en el puerto 4000 y ejecute una funcion callback la cual
mostrará un mensaje de error si lo hubiera, si sino mostrará el mensaje:
Servidor express funcionando en el puerto 4000
@ivanbtrujillo
ivanbtrujillo / index.js
Last active June 18, 2017 13:53
GraphQL. 02 - Servidor en Node con Express - 02
const express = require('express'),
// Llamamos a la librería express-graphql
expressGraphQL = require('express-graphql');
const app = express();
/*
Indicamos a nuestra aplicación express que para las peticiones al
endpoint /graphql, delegaremos la gestion en la libreria expressGraphQL a la cual
habilitamos la interfaz web graphiql, que nos permite operar con graphQL facilmente.
*/
@ivanbtrujillo
ivanbtrujillo / schema.js
Last active June 18, 2017 16:31
GraphQL. 03 — Schemas y GraphiQL - 01
// Importamos la librería GraphQl
const graphql = require('graphql');
/*
Usamos el deestructuring de Javascript Es6 para extraer el objeto GraphQLObjectType del objeto graphql
(el cual es la librería) para poder utilizarlo fuera.
*/
const {
GraphQLObjectType
} = graphql;
@ivanbtrujillo
ivanbtrujillo / schema.js
Last active June 18, 2017 16:31
GraphQL. 03 — Schemas y GraphiQL - 02
// Importamos la librería GraphQl
const graphql = require('graphql');
/*
Usamos el deestructuring de Javascript Es6 para extraer el objeto GraphQLObjectType del objeto graphql
(el cual es la librería) para poder utilizarlo fuera.
*/
const {
GraphQLObjectType,
GraphQLString
} = graphql;
@ivanbtrujillo
ivanbtrujillo / schema.js
Last active June 18, 2017 16:32
GraphQL. 03 — Schemas y GraphiQL - 03
// Importamos la librería GraphQl
const graphql = require('graphql');
/*
Usamos el deestructuring de Javascript Es6 para extraer el objeto GraphQLObjectType del objeto graphql
(el cual es la librería) para poder utilizarlo fuera.
*/
const {
GraphQLObjectType,
GraphQLString
} = graphql;
@ivanbtrujillo
ivanbtrujillo / schema.js
Last active June 18, 2017 16:32
GraphQL. 03 — Schemas y GraphiQL - 04
// Importamos la librería GraphQl
const graphql = require('graphql'),
lodash = require('lodash');
/*
Usamos el deestructuring de Javascript Es6 para extraer el objeto GraphQLObjectType del objeto graphql
(el cual es la librería) para poder utilizarlo fuera.
*/
const {
GraphQLObjectType,
GraphQLString
@ivanbtrujillo
ivanbtrujillo / schema.js
Last active June 18, 2017 16:32
GraphQL. 03 — Schemas y GraphiQL - 05
const graphql = require('graphql');
const {
GraphQLObjectType,
GraphQLString,
// Importamos GraphQL Schema de GraphQL mediante destructuring
GraphQLSchema
} = graphql;
const users = [
{ id: '1', firstName: 'Ivan', lastName: 'Bacallado', country: 'España' },