2020-04-29 18:44:27 +03:00
|
|
|
const should = require('should');
|
|
|
|
const sinon = require('sinon');
|
|
|
|
const getPaginatedUrl = require('../../../../core/frontend/meta/paginated_url');
|
|
|
|
const urlUtils = require('../../../utils/urlUtils');
|
2016-03-21 00:48:15 +03:00
|
|
|
|
|
|
|
describe('getPaginatedUrl', function () {
|
2020-04-29 18:44:27 +03:00
|
|
|
let data;
|
2016-03-21 00:48:15 +03:00
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
data = {};
|
|
|
|
});
|
|
|
|
|
2020-10-19 07:45:26 +03:00
|
|
|
const getTestUrls = function getTestUrls() {
|
2016-03-21 00:48:15 +03:00
|
|
|
return {
|
|
|
|
next: getPaginatedUrl('next', data, true),
|
|
|
|
prev: getPaginatedUrl('prev', data, true),
|
|
|
|
page1: getPaginatedUrl(1, data),
|
|
|
|
page5: getPaginatedUrl(5, data),
|
|
|
|
page10: getPaginatedUrl(10, data)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
it('should be a function', function () {
|
|
|
|
should.exist(getPaginatedUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('index', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
it('should calculate correct urls for the first page of an index collection', function () {
|
2016-03-21 00:48:15 +03:00
|
|
|
// Setup tests
|
|
|
|
data.relativeUrl = '/';
|
|
|
|
data.pagination = {prev: null, next: 2};
|
|
|
|
|
|
|
|
// Execute test
|
2020-04-29 18:44:27 +03:00
|
|
|
const urls = getTestUrls();
|
2016-03-21 00:48:15 +03:00
|
|
|
|
|
|
|
// Check results
|
|
|
|
urls.should.have.property('next', 'http://127.0.0.1:2369/page/2/');
|
|
|
|
urls.should.have.property('prev', null);
|
|
|
|
urls.should.have.property('page1', '/');
|
|
|
|
urls.should.have.property('page5', '/page/5/');
|
|
|
|
urls.should.have.property('page10', '/page/10/');
|
|
|
|
});
|
|
|
|
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
it('should calculate correct urls for the second page of an index collection', function () {
|
2016-03-21 00:48:15 +03:00
|
|
|
// Setup tests
|
|
|
|
data.relativeUrl = '/page/2/';
|
|
|
|
data.pagination = {prev: 1, next: 3};
|
|
|
|
|
|
|
|
// Execute test
|
2020-04-29 18:44:27 +03:00
|
|
|
const urls = getTestUrls();
|
2016-03-21 00:48:15 +03:00
|
|
|
|
|
|
|
// Check results
|
|
|
|
urls.should.have.property('next', 'http://127.0.0.1:2369/page/3/');
|
|
|
|
urls.should.have.property('prev', 'http://127.0.0.1:2369/');
|
|
|
|
urls.should.have.property('page1', '/');
|
|
|
|
urls.should.have.property('page5', '/page/5/');
|
|
|
|
urls.should.have.property('page10', '/page/10/');
|
|
|
|
});
|
|
|
|
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
it('should calculate correct urls for the last page of an index collection', function () {
|
2016-03-21 00:48:15 +03:00
|
|
|
// Setup tests
|
|
|
|
data.relativeUrl = '/page/10/';
|
|
|
|
data.pagination = {prev: 9, next: null};
|
|
|
|
|
|
|
|
// Execute test
|
2020-04-29 18:44:27 +03:00
|
|
|
const urls = getTestUrls();
|
2016-03-21 00:48:15 +03:00
|
|
|
|
|
|
|
// Check results
|
|
|
|
urls.should.have.property('next', null);
|
|
|
|
urls.should.have.property('prev', 'http://127.0.0.1:2369/page/9/');
|
|
|
|
urls.should.have.property('page1', '/');
|
|
|
|
urls.should.have.property('page5', '/page/5/');
|
|
|
|
urls.should.have.property('page10', '/page/10/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('other', function () {
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
it('should calculate correct urls for the first page of another collection', function () {
|
2016-03-21 00:48:15 +03:00
|
|
|
// Setup tests
|
|
|
|
data.relativeUrl = '/featured/';
|
|
|
|
data.pagination = {prev: null, next: 2};
|
|
|
|
|
|
|
|
// Execute test
|
2020-04-29 18:44:27 +03:00
|
|
|
const urls = getTestUrls();
|
2016-03-21 00:48:15 +03:00
|
|
|
|
|
|
|
// Check results
|
|
|
|
urls.should.have.property('next', 'http://127.0.0.1:2369/featured/page/2/');
|
|
|
|
urls.should.have.property('prev', null);
|
|
|
|
urls.should.have.property('page1', '/featured/');
|
|
|
|
urls.should.have.property('page5', '/featured/page/5/');
|
|
|
|
urls.should.have.property('page10', '/featured/page/10/');
|
|
|
|
});
|
|
|
|
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
it('should calculate correct urls for the second page of another collection', function () {
|
2016-03-21 00:48:15 +03:00
|
|
|
// Setup tests
|
|
|
|
data.relativeUrl = '/featured/page/2/';
|
|
|
|
data.pagination = {prev: 1, next: 3};
|
|
|
|
|
|
|
|
// Execute test
|
2020-04-29 18:44:27 +03:00
|
|
|
const urls = getTestUrls();
|
2016-03-21 00:48:15 +03:00
|
|
|
|
|
|
|
// Check results
|
|
|
|
urls.should.have.property('next', 'http://127.0.0.1:2369/featured/page/3/');
|
|
|
|
urls.should.have.property('prev', 'http://127.0.0.1:2369/featured/');
|
|
|
|
urls.should.have.property('page1', '/featured/');
|
|
|
|
urls.should.have.property('page5', '/featured/page/5/');
|
|
|
|
urls.should.have.property('page10', '/featured/page/10/');
|
|
|
|
});
|
|
|
|
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
it('should calculate correct urls for the last page of another collection', function () {
|
2016-03-21 00:48:15 +03:00
|
|
|
// Setup tests
|
|
|
|
data.relativeUrl = '/featured/page/10/';
|
|
|
|
data.pagination = {prev: 9, next: null};
|
|
|
|
|
|
|
|
// Execute test
|
2020-04-29 18:44:27 +03:00
|
|
|
const urls = getTestUrls();
|
2016-03-21 00:48:15 +03:00
|
|
|
|
|
|
|
// Check results
|
|
|
|
urls.should.have.property('next', null);
|
|
|
|
urls.should.have.property('prev', 'http://127.0.0.1:2369/featured/page/9/');
|
|
|
|
urls.should.have.property('page1', '/featured/');
|
|
|
|
urls.should.have.property('page5', '/featured/page/5/');
|
|
|
|
urls.should.have.property('page10', '/featured/page/10/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with /blog subdirectory', function () {
|
2019-06-18 16:13:55 +03:00
|
|
|
let sandbox;
|
|
|
|
|
2016-03-21 00:48:15 +03:00
|
|
|
before(function () {
|
2019-06-18 16:13:55 +03:00
|
|
|
sandbox = sinon.createSandbox();
|
2019-08-12 11:31:42 +03:00
|
|
|
urlUtils.stubUrlUtils({url: 'http://localhost:65535/blog'}, sandbox);
|
2016-03-21 00:48:15 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2019-06-18 16:13:55 +03:00
|
|
|
sandbox.restore();
|
2016-03-21 00:48:15 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should calculate correct urls for index', function () {
|
|
|
|
// Setup tests
|
|
|
|
data.relativeUrl = '/page/2/';
|
|
|
|
data.pagination = {prev: 1, next: 3};
|
|
|
|
|
|
|
|
// Execute test
|
2020-04-29 18:44:27 +03:00
|
|
|
const urls = getTestUrls();
|
2016-03-21 00:48:15 +03:00
|
|
|
|
|
|
|
// Check results
|
2019-08-12 11:31:42 +03:00
|
|
|
urls.should.have.property('next', 'http://localhost:65535/blog/page/3/');
|
|
|
|
urls.should.have.property('prev', 'http://localhost:65535/blog/');
|
2016-03-21 00:48:15 +03:00
|
|
|
urls.should.have.property('page1', '/blog/');
|
|
|
|
urls.should.have.property('page5', '/blog/page/5/');
|
|
|
|
urls.should.have.property('page10', '/blog/page/10/');
|
|
|
|
});
|
|
|
|
|
✨Dynamic Routing Beta (#9596)
refs #9601
### Dynamic Routing
This is the beta version of dynamic routing.
- we had a initial implementation of "channels" available in the codebase
- we have removed and moved this implementation
- there is now a centralised place for dynamic routing - server/services/routing
- each routing component is represented by a router type e.g. collections, routes, static pages, taxonomies, rss, preview of posts
- keep as much as possible logic of routing helpers, middlewares and controllers
- ensure test coverage
- connect all the things together
- yaml file + validation
- routing + routers
- url service
- sitemaps
- url access
- deeper implementation of yaml validations
- e.g. hard require slashes
- ensure routing hierarchy/order
- e.g. you enable the subscriber app
- you have a custom static page, which lives under the same slug /subscribe
- static pages are stronger than apps
- e.g. the first collection owns the post it has filtered
- a post cannot live in two collections
- ensure apps are still working and hook into the routers layer (or better said: and register in the routing service)
- put as much as possible comments to the code base for better understanding
- ensure a clean debug log
- ensure we can unmount routes
- e.g. you have a collection permalink of /:slug/ represented by {globals.permalink}
- and you change the permalink in the admin to dated permalink
- the express route get's refreshed from /:slug/ to /:year/:month/:day/:slug/
- unmount without server restart, yey
- ensure we are backwards compatible
- e.g. render home.hbs for collection index if collection route is /
- ensure you can access your configured permalink from the settings table with {globals.permalink}
### Render 503 if url service did not finish
- return 503 if the url service has not finished generating the resource urls
### Rewrite sitemaps
- we have rewritten the sitemaps "service", because the url generator does no longer happen on runtime
- we generate all urls on bootstrap
- the sitemaps service will consume created resource and router urls
- these urls will be shown on the xml pages
- we listen on url events
- we listen on router events
- we no longer have to fetch the resources, which is nice
- the urlservice pre-fetches resources and emits their urls
- the urlservice is the only component who knows which urls are valid
- i made some ES6 adaptions
- we keep the caching logic -> only regenerate xml if there is a change
- updated tests
- checked test coverage (100%)
### Re-work usage of Url utility
- replace all usages of `urlService.utils.urlFor` by `urlService.getByResourceId`
- only for resources e.g. post, author, tag
- this is important, because with dynamic routing we no longer create static urls based on the settings permalink on runtime
- adapt url utility
- adapt tests
2018-06-05 20:02:20 +03:00
|
|
|
it('should calculate correct urls for another collection', function () {
|
2016-03-21 00:48:15 +03:00
|
|
|
// Setup tests
|
|
|
|
data.relativeUrl = '/featured/page/2/';
|
|
|
|
data.pagination = {prev: 1, next: 3};
|
|
|
|
|
|
|
|
// Execute test
|
2020-04-29 18:44:27 +03:00
|
|
|
const urls = getTestUrls();
|
2016-03-21 00:48:15 +03:00
|
|
|
|
|
|
|
// Check results
|
2019-08-12 11:31:42 +03:00
|
|
|
urls.should.have.property('next', 'http://localhost:65535/blog/featured/page/3/');
|
|
|
|
urls.should.have.property('prev', 'http://localhost:65535/blog/featured/');
|
2016-03-21 00:48:15 +03:00
|
|
|
urls.should.have.property('page1', '/blog/featured/');
|
|
|
|
urls.should.have.property('page5', '/blog/featured/page/5/');
|
|
|
|
urls.should.have.property('page10', '/blog/featured/page/10/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|