UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

27 lines (19 loc) 1.09 kB
import fetchMock from 'fetch-mock'; import { googleFontResponse } from './../../TestData/MockGoogleFontResponse'; let mapper = require('../../Mapper'); describe("Mapper", t => { t.it("should map respose properly", t => { fetchMock.get('*', googleFontResponse); // return the promise from the test function, to wait for it resolution return mapper.fetchGoolgeFonts().then(obj => { t.expect(obj.categories).toEqual(["All", "sans-serif", "serif", "display"]); t.expect(Object.keys(obj.fonts).length).toEqual(4); t.expect(obj.fonts["handwriting"]).toBeUndefined(); t.expect(obj.fonts["All"].length).toEqual(8); t.expect(obj.fonts["All"][0]).toEqual({"label": "ABeeZee", "value": "ABeeZee", "variants": [{"label": "regular", "value": "regular"}, {"label": "italic", "value": "italic"}]}); t.expect(obj.fonts["sans-serif"].length).toEqual(5); t.expect(obj.fonts["serif"].length).toEqual(2); t.expect(obj.fonts["display"].length).toEqual(1); }) }) })