This file contains 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 { Product } from './Product'; | |
import { Price } from './Price'; | |
import { filterProductsByName, addPriceToProduct } from './product-utils'; | |
import { getProductMock } from './Product.mock'; | |
import { getPriceMock } from './Price.mock'; | |
describe('product-utils', () => { | |
test('filterProductsByName', () => { | |
const puffy = getProductMock({name: 'Puffy'}); |
This file contains 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 { Product } from './Product'; | |
const getDefaults = (): Product => ({ | |
name: 'mock name', | |
description: 'mock description', | |
longDescription: 'mock long description', | |
imageOne: 'mock imageOne src', | |
imageTwo: 'mock imageTwo src', | |
imageThree: 'mock imageThree src', | |
price: null |
This file contains 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 { Price } from './Price'; | |
const getDefaults = (): Price => ({ | |
value: 1000, | |
currency: 'EUR', | |
vat: 190, | |
stringRepresentation: '1190 €' | |
}); | |
export const getPriceMock = (p?: Partial<Price>): Price => ({ |
This file contains 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 { getProductMock } from './Product.mock'; | |
const puffy = getProductMock({name: 'Puffy'}); | |
console.log(puffy.description, 'Will print mock description'); |
This file contains 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 express from 'express'; | |
import axios from 'axios'; | |
import parse from 'parse-link-header'; | |
export const gistsRoute = express | |
.Router() | |
.get('/', function (req, res, next) { | |
let gists = []; | |
axios.get('https://api.github.com/users/intojs/gists?per_page=2&page=1') | |
.then(function (response) { |
This file contains 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 express from 'express'; | |
import cors from 'cors'; | |
import bodyParser from 'body-parser'; | |
import {gistsRoute} from './gists.route.2'; | |
const app = express(); | |
const port = process.env.PORT || 3000; | |
const jsonParser = bodyParser.json(); |
This file contains 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 express from 'express'; | |
import {handleGistsRoute} from "./handle-gists.4"; | |
const gistsUrl = 'https://api.github.com/users/intojs/gists?per_page=2&page=1'; | |
export const gistsRoute = express | |
.Router() | |
.get('/', handleGistsRoute(gistsUrl)); |
This file contains 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 axios from "axios"; | |
import parse from 'parse-link-header'; | |
export const handleGistsRouteFactory = (dependencies) => (gistsUrl) => (req, res, next) => { | |
const { | |
axios, | |
parse | |
} = dependencies; | |
let gists = []; | |
axios.get(gistsUrl) |
This file contains 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
export const handleGistsRouteFactory = (dependencies) => (gistsUrl) => (req, res, next) => {... |
This file contains 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 axios from "axios"; | |
import parseLinkHeader from 'parse-link-header'; | |
export const getDescription = (gist) => ({ | |
description: gist.description, | |
url: gist.url | |
}); | |
export const sortByName = (a, b) => { | |
const nameA = a.description.toUpperCase(); |