mapRequestToAsset.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const ava_1 = require("ava");
  4. const mocks_1 = require("../mocks");
  5. (0, mocks_1.mockGlobalScope)();
  6. const index_1 = require("../index");
  7. (0, ava_1.default)('mapRequestToAsset() correctly changes /about -> /about/index.html', async (t) => {
  8. (0, mocks_1.mockRequestScope)();
  9. let path = '/about';
  10. let request = new Request(`https://foo.com${path}`);
  11. let newRequest = (0, index_1.mapRequestToAsset)(request);
  12. t.is(newRequest.url, request.url + '/index.html');
  13. });
  14. (0, ava_1.default)('mapRequestToAsset() correctly changes /about/ -> /about/index.html', async (t) => {
  15. (0, mocks_1.mockRequestScope)();
  16. let path = '/about/';
  17. let request = new Request(`https://foo.com${path}`);
  18. let newRequest = (0, index_1.mapRequestToAsset)(request);
  19. t.is(newRequest.url, request.url + 'index.html');
  20. });
  21. (0, ava_1.default)('mapRequestToAsset() correctly changes /about.me/ -> /about.me/index.html', async (t) => {
  22. (0, mocks_1.mockRequestScope)();
  23. let path = '/about.me/';
  24. let request = new Request(`https://foo.com${path}`);
  25. let newRequest = (0, index_1.mapRequestToAsset)(request);
  26. t.is(newRequest.url, request.url + 'index.html');
  27. });
  28. (0, ava_1.default)('mapRequestToAsset() correctly changes /about -> /about/default.html', async (t) => {
  29. (0, mocks_1.mockRequestScope)();
  30. let path = '/about';
  31. let request = new Request(`https://foo.com${path}`);
  32. let newRequest = (0, index_1.mapRequestToAsset)(request, { defaultDocument: 'default.html' });
  33. t.is(newRequest.url, request.url + '/default.html');
  34. });