Commit 18b5aa2e authored by MrMan's avatar MrMan

Add tinder API test

parent ca65c015
import System from "systemjs";
import "../config";
import "should";
import _ from "lodash";
const POST_TEST_URL = "http://nowhere.com/api";
const POST_TEST_PARAMS = {properties: 'present'};
// Mock SystemJS fetch import (mocked fetch will simply return the URL and the options)
const MOCK_FETCH_MODULE = {
fetch: (url, opts) => Promise.resolve({url, opts})
};
System.set("vendor/fetch", System.newModule({default: MOCK_FETCH_MODULE}));
describe("Tinder API", () => {
it("Should perform a fetch-based POST as expected", (done) => {
System.import("./js/tinder-api")
.then(api => {
let tinderAPI = api.default;
// Perform POST with API, manually verify url and opts that are returned
tinderAPI.POST(POST_TEST_URL, POST_TEST_PARAMS)
.then((res) => {
res.url.should.be.exactly(POST_TEST_URL);
res.opts.should.have.keys("body", "headers", "method");
res.opts.body.should.be.exactly(JSON.stringify(POST_TEST_PARAMS));
done();
})
.catch(done);
})
.catch(done);
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment