mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-30 16:01:10 -04:00
* rename * migrate * migrate create language redirect * fix type of redirects * migrate test Co-authored-by: Parth Parth <thecodingaviator@users.noreply.github.com> Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
99 lines
3.0 KiB
TypeScript
99 lines
3.0 KiB
TypeScript
import createExternalRedirect from './create-external-redirects';
|
|
|
|
describe('createExternalRedirects', () => {
|
|
describe('english redirects', () => {
|
|
const envVars = {
|
|
clientLocale: 'english'
|
|
};
|
|
|
|
const forumURL = 'https://forum.freecodecamp.org/';
|
|
const newsURL = 'https://www.freecodecamp.org/news';
|
|
|
|
it('should generate correct forum link', () => {
|
|
const receivedUrl = createExternalRedirect('forum', { ...envVars });
|
|
expect(receivedUrl).toBe(forumURL);
|
|
});
|
|
|
|
it('should generate correct news link', () => {
|
|
const receivedUrl = createExternalRedirect('news', { ...envVars });
|
|
expect(receivedUrl).toBe(newsURL);
|
|
});
|
|
});
|
|
|
|
describe('chinese redirects', () => {
|
|
const envVars = {
|
|
clientLocale: 'chinese'
|
|
};
|
|
|
|
const forumURL = 'https://chinese.freecodecamp.org/forum';
|
|
const newsURL = 'https://chinese.freecodecamp.org/news';
|
|
|
|
it('should generate correct forum link', () => {
|
|
const receivedUrl = createExternalRedirect('forum', { ...envVars });
|
|
expect(receivedUrl).toBe(forumURL);
|
|
});
|
|
|
|
it('should generate correct news link', () => {
|
|
const receivedUrl = createExternalRedirect('news', { ...envVars });
|
|
expect(receivedUrl).toBe(newsURL);
|
|
});
|
|
});
|
|
|
|
describe('spanish redirects', () => {
|
|
const envVars = {
|
|
clientLocale: 'espanol'
|
|
};
|
|
|
|
const forumURL = 'https://forum.freecodecamp.org/c/espanol/';
|
|
const newsURL = 'https://www.freecodecamp.org/espanol/news';
|
|
|
|
it('should generate correct forum link', () => {
|
|
const receivedUrl = createExternalRedirect('forum', { ...envVars });
|
|
expect(receivedUrl).toBe(forumURL);
|
|
});
|
|
|
|
it('should generate correct news link', () => {
|
|
const receivedUrl = createExternalRedirect('news', { ...envVars });
|
|
expect(receivedUrl).toBe(newsURL);
|
|
});
|
|
});
|
|
|
|
describe('french redirects', () => {
|
|
const envVars = {
|
|
clientLocale: 'francais'
|
|
};
|
|
|
|
const forumURL = 'https://forum.freecodecamp.org/c/francais/';
|
|
const newsURL = 'https://www.freecodecamp.org/francais/news';
|
|
|
|
it('should generate correct forum link', () => {
|
|
const receivedUrl = createExternalRedirect('forum', { ...envVars });
|
|
expect(receivedUrl).toBe(forumURL);
|
|
});
|
|
|
|
it('should generate correct news link', () => {
|
|
const receivedUrl = createExternalRedirect('news', { ...envVars });
|
|
expect(receivedUrl).toBe(newsURL);
|
|
});
|
|
});
|
|
|
|
describe('chinese-traditional redirects', () => {
|
|
const envVars = {
|
|
clientLocale: 'chinese-traditional'
|
|
};
|
|
|
|
const forumURL = 'https://chinese.freecodecamp.org/forum';
|
|
const newsURL = 'https://chinese.freecodecamp.org/news';
|
|
|
|
it('should generate correct forum link', () => {
|
|
const receivedUrl = createExternalRedirect('forum', { ...envVars });
|
|
expect(receivedUrl).toBe(forumURL);
|
|
});
|
|
|
|
it('should generate correct news link', () => {
|
|
const receivedUrl = createExternalRedirect('news', { ...envVars });
|
|
expect(receivedUrl).toBe(newsURL);
|
|
});
|
|
});
|
|
});
|