feat: remove news from platform

This commit is contained in:
Mrugesh Mohapatra
2019-01-14 22:49:13 +05:30
committed by Stuart Taylor
parent 219abdc2ce
commit fdc2219f81
39 changed files with 19 additions and 1709 deletions

View File

@@ -1,9 +1,7 @@
const challengePageCreators = require('./challengePageCreator');
const guidePageCreators = require('./guidePageCreator');
const newsPageCreators = require('./newsPageCreator');
module.exports = {
...challengePageCreators,
...guidePageCreators,
...newsPageCreators
...guidePageCreators
};

View File

@@ -1,22 +0,0 @@
const path = require('path');
const newsArticle = path.resolve(
__dirname, '../../src/templates/News/ShowArticle/index.js'
);
exports.createNewsArticle = createPage => ({
node: {
fields: { slug },
shortId,
id
}
}) =>
createPage({
path: slug,
component: newsArticle,
context: {
slug,
shortId,
id
}
});

View File

@@ -1,18 +0,0 @@
exports.createArticleSlug = ({
username = '',
slugPart = '',
shortId = ''
} = {}) => {
if (!username || !slugPart || !shortId) {
throw new Error(`
createArtcileSlug: One or more properties were missing, all are required
{
username: ${username},
slugPart: ${slugPart},
shortId: ${shortId}
}
`);
}
return `/news/${username}/${slugPart.concat('--', shortId)}`;
};

View File

@@ -1,32 +0,0 @@
/* global describe it expect */
import { mockArguments, slugWithId} from '../src/__mocks__/news-article';
import { createArticleSlug } from './news';
describe('news utils', () => {
describe('createArticleSlug', () => {
it('returns a string', () => {
expect(typeof createArticleSlug(mockArguments)).toEqual('string');
});
it('throws when values are missing', () => {
expect.assertions(3);
/* eslint-disable no-undefined */
expect(() =>
createArticleSlug({ ...mockArguments, shortId: undefined })
).toThrow();
expect(() =>
createArticleSlug({ ...mockArguments, slugPart: undefined })
).toThrow();
expect(() =>
createArticleSlug({ ...mockArguments, username: undefined })
).toThrow();
});
it('creates a slug in the expected format', () => {
const result = createArticleSlug(mockArguments);
expect(result).toEqual(slugWithId);
});
});
});