Enhanced support for batch endpoints (#3042)

* Allow to have different endpoint on publicserverURL and serverURL when batching

* nits
This commit is contained in:
Florent Vilmart
2016-11-24 20:14:12 -05:00
committed by GitHub
parent 8c2c76dd26
commit d800ff85e2
2 changed files with 96 additions and 14 deletions

44
spec/batch.spec.js Normal file
View File

@@ -0,0 +1,44 @@
var batch = require('../src/batch');
const originalURL = '/parse/batch';
const serverURL = 'http://localhost:1234/parse';
const serverURL1 = 'http://localhost:1234/1';
const serverURLNaked = 'http://localhost:1234/';
const publicServerURL = 'http://domain.com/parse';
const publicServerURLNaked = 'http://domain.com/';
describe('batch', () => {
it('should return the proper url', () => {
let internalURL = batch.makeBatchRoutingPathFunction(originalURL)('/parse/classes/Object');
expect(internalURL).toEqual('/classes/Object');
});
it('should return the proper url same public/local endpoint', () => {
let originalURL = '/parse/batch';
let internalURL = batch.makeBatchRoutingPathFunction(originalURL, serverURL, publicServerURL)('/parse/classes/Object');
expect(internalURL).toEqual('/classes/Object');
});
it('should return the proper url with different public/local mount', () => {
let originalURL = '/parse/batch';
let internalURL = batch.makeBatchRoutingPathFunction(originalURL, serverURL1, publicServerURL)('/parse/classes/Object');
expect(internalURL).toEqual('/classes/Object');
});
it('should return the proper url with naked public', () => {
let originalURL = '/batch';
let internalURL = batch.makeBatchRoutingPathFunction(originalURL, serverURL, publicServerURLNaked)('/classes/Object');
expect(internalURL).toEqual('/classes/Object');
});
it('should return the proper url with naked local', () => {
let originalURL = '/parse/batch';
let internalURL = batch.makeBatchRoutingPathFunction(originalURL, serverURLNaked, publicServerURL)('/parse/classes/Object');
expect(internalURL).toEqual('/classes/Object');
});
});