Skip to content

Instantly share code, notes, and snippets.

View gpincheiraa's full-sized avatar

Gonzalo Pincheira Arancibia gpincheiraa

View GitHub Profile
@gpincheiraa
gpincheiraa / routes.js
Last active September 23, 2017 05:58
routes.js - First Impressions using jest for TDD over AngularJS > 1.5.x — Part I
import '@uirouter/angularjs'
export function routes($stateProvider, $locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
})
$stateProvider
.state("home", {
url: "/",
@gpincheiraa
gpincheiraa / index.js
Created July 16, 2017 03:05
index.js - First Impressions using jest for TDD over AngularJS > 1.5.x — Part I
import angular from 'angular';
import { routes } from './routes'
import { TodoListComponent } from "./components/todoList.component"
angular
.module('App', ['ngRoute'])
.config(routes)
.component('todoList', TodoListComponent)
@gpincheiraa
gpincheiraa / webpack.config.js
Last active September 26, 2017 22:47
webpack.config.js - First Impressions using jest for TDD over AngularJS > 1.5.x — Part I
module.exports = {
entry: [
"./src/index.js"
],
output: {
path: __dirname + "/dist",
filename: "index.bundle.js"
},
module: {
rules: [
@gpincheiraa
gpincheiraa / todoList.component.js
Last active September 26, 2017 23:53
todoList.component.js - 5 First Impressions using jest for TDD over AngularJS > 1.5.x — Part I Raw
class TodoListController {
constructor(){
this.todosList = [
{
name: "Learn Programming using component based approach",
completed: true
},
{
name: "Learn Machine Learning",
completed: false
@gpincheiraa
gpincheiraa / TodoService.js
Last active September 22, 2017 04:04
TodoService_1.js
export class TodoService {
constructor($http, BASE_URL) {
this.http = $http;
this.url = `${BASE_URL}/todos`
}
getTodos() {
return this.http.get(this.url)
.then(res => res.data.todos)
.catch(error => error.message)
}
@gpincheiraa
gpincheiraa / index.js
Created September 23, 2017 05:36
index.js_2_2nd_article
import angular from "angular"
import { routes } from "./routes"
import { TodoListComponent } from "./components/todoList.component"
import { TodoService } from "./services/todo.service"
angular
.module("App", [
"ui.router"
])
.config(routes)
@gpincheiraa
gpincheiraa / routes.js
Created September 23, 2017 05:56
routes.js_2_2nd_article
import '@uirouter/angularjs'
export function routes($stateProvider, $locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
})
$stateProvider
.state("home", {
url: "/",
@gpincheiraa
gpincheiraa / todoList.component.js
Created September 23, 2017 06:21
todoList.component.js_1_2nd_article
class TodoListController {
addTodo(todo){
this.todosList.push(todo)
}
toggleCheckTodo(index){
this.todosList[index].completed = !this.todosList[index].completed
}
deleteTodo(index){
this.todosList.splice(index, 1)
}
@gpincheiraa
gpincheiraa / package.json
Last active October 8, 2017 00:31
package.json_2_2nd_article
{
"name": "angularjs-tdd-jest",
"version": "0.1.0",
"scripts": {
"server": "webpack-dev-server",
"start": "npm-run-all -p stubs server",
"stubs": "stubby -w -d stubs/fakeserver.yml -s 5000",
"tdd": "cross-env NODE_PATH=./src jest --watch --verbose",
"test": "cross-env NODE_PATH=./src jest --coverage --verbose"
},
@gpincheiraa
gpincheiraa / fakeserver.yml
Created September 25, 2017 02:35
fakeserver.yml_1_2nd_article
- request:
url: ^/api/todos
response:
headers:
content-type: application/json
status: 200
file: todos_get.json