Files
freeCodeCamp/client/src/components/create-external-redirects.test.ts
Parth Parth 11d71adc6e feat(client): ts-migrate /client/src/components/ redirects (#42642)
* 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>
2021-06-30 20:52:17 +05:30

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);
});
});
});