This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"first": "John", | |
"last": "Smith" | |
}, | |
{ | |
"first": "Jane", | |
"last": "Doe" | |
} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const t = require('tcomb'); | |
const Employee = t.struct({ | |
first: t.String, | |
last: t.String | |
}, 'Employee'); | |
module.exports = Employee; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Employee = './employee.js'; | |
const t = require('tcomb'); | |
const Employees = t.list(Employee); | |
module.exports = Employees; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Employee = require('./employee.js'); | |
const t = require('tcomb'); | |
const ExtendedEmployee = Employee.extend({ | |
selected: t.Bool | |
}, 'ExtendedEmployee'); | |
module.exports = ExtendedEmployee; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const t = require('tcomb'); | |
const Employee = t.struct({ | |
first: t.String, | |
last: t.String | |
}, 'Employee'); | |
const employee = new Employee({ | |
first: 'Rodo', | |
last: 'Abad' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'isomorphic-fetch'; | |
export const getFruits = () => { | |
const endPoint = '/fruits'; | |
return fetch(endPoint) | |
.then(response => response.json()) | |
.catch(error => error.json()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'isomorphic-fetch'; | |
import {expect} from 'code'; | |
import {getFruits} from '../../src/fruits-repository'; | |
import sinon from 'sinon'; | |
describe('Given the fruits repository', () => { | |
let fetchStub, | |
sandbox; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'isomorphic-fetch'; | |
import {expect} from 'code'; | |
import {getFruits} from '../../src/fruits-repository'; | |
import sinon from 'sinon'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
beforeEach(() => { | |
sandbox = sinon.sandbox.create(); | |
fetchStub = sandbox.stub(global, 'fetch'); | |
}); | |
afterEach(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('when getting a collection of fruits', () => { | |
it('should call fetch', () => { | |
const expectedEndPoint = '/fruits'; | |
fetchStub.returns(Promise.resolve()); | |
getFruits(); | |
OlderNewer