|
|
@@ -50,68 +50,6 @@ describe('ShareLink', () => {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
- test('share link is not found', async() => {
|
|
|
-
|
|
|
- findOneResult.populate = jest.fn(() => { return null });
|
|
|
-
|
|
|
- jest.spyOn(ShareLink, 'findOne').mockImplementation(() => {
|
|
|
- return findOneResult;
|
|
|
- });
|
|
|
-
|
|
|
- const response = await Page.showSharedPage(req, res);
|
|
|
-
|
|
|
- expect(findOneResult.populate).toHaveBeenCalled();
|
|
|
- expect(res.render).toHaveBeenCalled();
|
|
|
- expect(response.page).toEqual('layout-growi/not_found_shared_page');
|
|
|
- expect(response.renderVars).toEqual(null);
|
|
|
- });
|
|
|
-
|
|
|
- test('share link is found, but it does not have Page', async() => {
|
|
|
-
|
|
|
- findOneResult.populate = jest.fn(() => { return { _id: 'somePageId' } });
|
|
|
-
|
|
|
- jest.spyOn(ShareLink, 'findOne').mockImplementation(() => {
|
|
|
- return findOneResult;
|
|
|
- });
|
|
|
- const response = await Page.showSharedPage(req, res);
|
|
|
-
|
|
|
- expect(findOneResult.populate).toHaveBeenCalled();
|
|
|
- expect(res.render).toHaveBeenCalled();
|
|
|
- expect(response.page).toEqual('layout-growi/not_found_shared_page');
|
|
|
- expect(response.renderVars).toEqual(null);
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- test('share link is found, but it is expired', async() => {
|
|
|
-
|
|
|
- findOneResult.populate = jest.fn(() => { return { _id: 'somePageId', relatedPage, isExpired: () => { return true } } });
|
|
|
-
|
|
|
- jest.spyOn(ShareLink, 'findOne').mockImplementation(() => {
|
|
|
- return findOneResult;
|
|
|
- });
|
|
|
-
|
|
|
- const response = await Page.showSharedPage(req, res);
|
|
|
-
|
|
|
- expect(findOneResult.populate).toHaveBeenCalled();
|
|
|
- expect(res.render).toHaveBeenCalled();
|
|
|
- expect(response.page).toEqual('layout-growi/expired_shared_page');
|
|
|
- expect(response.renderVars).not.toEqual(null);
|
|
|
- });
|
|
|
-
|
|
|
- test('share link is found, and it has the page you can see', async() => {
|
|
|
-
|
|
|
- findOneResult.populate = jest.fn(() => { return { _id: 'somePageId', relatedPage, isExpired: () => { return false } } });
|
|
|
-
|
|
|
- jest.spyOn(ShareLink, 'findOne').mockImplementation(() => {
|
|
|
- return findOneResult;
|
|
|
- });
|
|
|
- const response = await Page.showSharedPage(req, res);
|
|
|
-
|
|
|
- expect(findOneResult.populate).toHaveBeenCalled();
|
|
|
- expect(res.render).toHaveBeenCalled();
|
|
|
- expect(response.page).toEqual('layout-growi/shared_page');
|
|
|
- expect(response.renderVars).not.toEqual(null);
|
|
|
- });
|
|
|
});
|
|
|
|
|
|
});
|