Skip to content

Instantly share code, notes, and snippets.

View rodoabad's full-sized avatar
😝
Changing the world through JavaScript (and TypeScript)!

Rodo Abad rodoabad

😝
Changing the world through JavaScript (and TypeScript)!
View GitHub Profile
[
{
"first": "John",
"last": "Smith"
},
{
"first": "Jane",
"last": "Doe"
}
]
const t = require('tcomb');
const Employee = t.struct({
first: t.String,
last: t.String
}, 'Employee');
module.exports = Employee;
const Employee = './employee.js';
const t = require('tcomb');
const Employees = t.list(Employee);
module.exports = Employees;
const Employee = require('./employee.js');
const t = require('tcomb');
const ExtendedEmployee = Employee.extend({
selected: t.Bool
}, 'ExtendedEmployee');
module.exports = ExtendedEmployee;
const t = require('tcomb');
const Employee = t.struct({
first: t.String,
last: t.String
}, 'Employee');
const employee = new Employee({
first: 'Rodo',
last: 'Abad'
describe('when getting a collection of fruits', () => {
it('should call fetch', () => {
const expectedEndPoint = '/fruits';
fetchStub.returns(Promise.resolve());
getFruits();
beforeEach(() => {
sandbox = sinon.sandbox.create();
fetchStub = sandbox.stub(global, 'fetch');
});
afterEach(() => {
import 'isomorphic-fetch';
export const getFruits = () => {
const endPoint = '/fruits';
return fetch(endPoint)
.then(response => response.json())
.catch(error => error.json());
import 'isomorphic-fetch';
import {expect} from 'code';
import {getFruits} from '../../src/fruits-repository';
import sinon from 'sinon';
import 'isomorphic-fetch';
export const getFruits = async() => {
const endPoint = '/fruits';
try {
const response = await fetch(endPoint);