Skip to content

Instantly share code, notes, and snippets.

View albertBarsegyan's full-sized avatar
🌎
Do your best

Albert albertBarsegyan

🌎
Do your best
View GitHub Profile
@albertBarsegyan
albertBarsegyan / example.test.js
Last active September 2, 2021 14:00
Form testing
import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import formTestConstants from '../../constants/formTest.constants';
import { CompanyForm } from '../../components/forms/CompanyForm/CompanyForm';
// testing if company form is working
describe('CompanyForm tests 🙂', () => {
it('Success test', async () => {
@albertBarsegyan
albertBarsegyan / example.test.js
Created September 2, 2021 13:52
example.test.js imports
import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import formTestConstants from '../../constants/formTest.constants';
import { CompanyForm } from '../../components/forms/CompanyForm/CompanyForm';
@albertBarsegyan
albertBarsegyan / example.test.js
Created September 2, 2021 14:18
Form failure test
it('Failure test', async () => {
const handleSubmit = jest.fn();
render(<CompanyForm onSubmit={handleSubmit} />);
const submitButton = screen.getByTestId('companyFormSubmitButton');
const nameError = screen.getByTestId('nameError');
const emailError = screen.queryByTestId('emailError');
const phoneNumberError = screen.queryByTestId('phoneNumberError');
const agreementError = screen.queryByTestId('agreementError');
module.exports = {
i18n: {
locales: ['us', 'am'],
defaultLocale: 'us',
},
};
import React from 'react';
import Link from 'next/link';
import { useRouter } from 'next/dist/client/router';
export default function Test() {
const { locales, asPath } = useRouter();
return (
<div>
{locales.map((localeName) => {
return (
import { MDXRemote } from 'next-mdx-remote';
import getDocBySlug from '../src/services/getDocBySlug.mjs';
import Image from 'next/image';
import { serialize } from 'next-mdx-remote/serialize';
export default function Blog({ content, meta }) {
const components = {
Image,
};
@albertBarsegyan
albertBarsegyan / getDocBySlug.js
Created October 3, 2021 16:43
get markdown from file
import matter from 'gray-matter';
import path from 'path';
import fs from 'fs';
export default function getDocBySlug(slug, locale = 'us') {
const docsDirectory = path.join(process.cwd(), '/src/content');
const realSlug = slug.replace(/\.mdx$/, '');
const fullPath = path.join(docsDirectory, slug, `${realSlug}.${locale}.mdx`);
const fileContents = fs.readFileSync(fullPath, 'utf8');
const { content, data } = matter(fileContents);
import { Octokit } from '@octokit/rest';
export const octokit = new Octokit({
auth: process.env.NEXT_PUBLIC_GITHUB_TOKEN,
});
export const octokitResponse = async (responseUrl, dataToSend) => {
const responseData = await fetch(responseUrl, {
body: JSON.stringify(dataToSend),
method: 'POST',
/* eslint-disable */
import path from 'path';
import { Languages } from '../../constants';
import { popupMessages } from '../../constants/popup-messages.constants';
import { popupVariants } from '../../constants/popup.constants';
import { getUserNameFromEmail } from '../../helpers/string.helpers';
import { octokit } from '../../services/admin.services';
import { GithubOrganization } from './constants/github.constants';
/* eslint-disable */
import { Octokit } from '@octokit/rest';
import { popupMessages } from '../../constants/popup-messages.constants';
import { popupVariants } from '../../constants/popup.constants';
import { getUserNameFromEmail } from '../../helpers/string.helpers';
import {
GithubOrganization,
successStatusCodes,
} from './constants/github.constants';