Files
kami-parse-server/spec/batch.spec.js

63 lines
1.8 KiB
JavaScript
Raw Normal View History

const batch = require('../lib/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', () => {
const internalURL = batch.makeBatchRoutingPathFunction(originalURL)(
'/parse/classes/Object'
);
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';
const 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', () => {
2016-12-07 15:17:05 -08:00
const originalURL = '/parse/batch';
const internalURL = batch.makeBatchRoutingPathFunction(
originalURL,
serverURL1,
publicServerURL
)('/parse/classes/Object');
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';
const internalURL = batch.makeBatchRoutingPathFunction(
originalURL,
serverURL,
publicServerURLNaked
)('/classes/Object');
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';
const internalURL = batch.makeBatchRoutingPathFunction(
originalURL,
serverURLNaked,
publicServerURL
)('/parse/classes/Object');
expect(internalURL).toEqual('/classes/Object');
});
});