2018-07-02 23:30:14 -04:00
|
|
|
const batch = require('../lib/batch');
|
2016-11-24 20:14:12 -05:00
|
|
|
|
|
|
|
|
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', () => {
|
2018-09-01 13:58:06 -04:00
|
|
|
const internalURL = batch.makeBatchRoutingPathFunction(originalURL)(
|
|
|
|
|
'/parse/classes/Object'
|
|
|
|
|
);
|
2016-11-24 20:14:12 -05:00
|
|
|
|
|
|
|
|
expect(internalURL).toEqual('/classes/Object');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return the proper url same public/local endpoint', () => {
|
2016-12-07 15:17:05 -08:00
|
|
|
const originalURL = '/parse/batch';
|
2018-09-01 13:58:06 -04:00
|
|
|
const internalURL = batch.makeBatchRoutingPathFunction(
|
|
|
|
|
originalURL,
|
|
|
|
|
serverURL,
|
|
|
|
|
publicServerURL
|
|
|
|
|
)('/parse/classes/Object');
|
2016-11-24 20:14:12 -05:00
|
|
|
|
|
|
|
|
expect(internalURL).toEqual('/classes/Object');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return the proper url with different public/local mount', () => {
|
2016-12-07 15:17:05 -08:00
|
|
|
const originalURL = '/parse/batch';
|
2018-09-01 13:58:06 -04:00
|
|
|
const internalURL = batch.makeBatchRoutingPathFunction(
|
|
|
|
|
originalURL,
|
|
|
|
|
serverURL1,
|
|
|
|
|
publicServerURL
|
|
|
|
|
)('/parse/classes/Object');
|
2016-11-24 20:14:12 -05:00
|
|
|
|
|
|
|
|
expect(internalURL).toEqual('/classes/Object');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return the proper url with naked public', () => {
|
2016-12-07 15:17:05 -08:00
|
|
|
const originalURL = '/batch';
|
2018-09-01 13:58:06 -04:00
|
|
|
const internalURL = batch.makeBatchRoutingPathFunction(
|
|
|
|
|
originalURL,
|
|
|
|
|
serverURL,
|
|
|
|
|
publicServerURLNaked
|
|
|
|
|
)('/classes/Object');
|
2016-11-24 20:14:12 -05:00
|
|
|
|
|
|
|
|
expect(internalURL).toEqual('/classes/Object');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return the proper url with naked local', () => {
|
2016-12-07 15:17:05 -08:00
|
|
|
const originalURL = '/parse/batch';
|
2018-09-01 13:58:06 -04:00
|
|
|
const internalURL = batch.makeBatchRoutingPathFunction(
|
|
|
|
|
originalURL,
|
|
|
|
|
serverURLNaked,
|
|
|
|
|
publicServerURL
|
|
|
|
|
)('/parse/classes/Object');
|
2016-11-24 20:14:12 -05:00
|
|
|
|
|
|
|
|
expect(internalURL).toEqual('/classes/Object');
|
|
|
|
|
});
|
|
|
|
|
});
|