A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
Castform tests refactoring
gianantoniopinid951a3f52d3d
diff --git a/src/templates/__tests__/Castform.test.js b/src/templates/__tests__/Castform.test.jsindex d2c92229d..e035bf3f9 100644--- a/src/templates/__tests__/Castform.test.js+++ b/src/templates/__tests__/Castform.test.js@@ -1,47 +1,53 @@import React from 'react';import { render, cleanup } from '@testing-library/react';-import path from 'path';-import fs from 'fs';+import FirebaseStub from 'gatsby-plugin-firebase';import '../../i18n/index';import Castform from '../Castform';-let data = {};--beforeEach(() => {- const filePath = path.resolve(__dirname, '../../data/initialState.json');- const file = fs.readFileSync(filePath);- data = JSON.parse(file);-});+describe('Castform', () => {+ let resume = {};++ beforeEach(async () => {+ FirebaseStub.database().initializeData();+ const resumesPath = FirebaseStub.database().resumesPath;+ const resumeId = FirebaseStub.database().emptyResumeId;+ resume = (+ await FirebaseStub.database()+ .ref(`${resumesPath}/${resumeId}`)+ .once('value')+ ).val();+ });-afterEach(cleanup);+ afterEach(cleanup);-it('renders correctly', () => {- const { container } = render(<Castform data={data} />);+ it('renders correctly', () => {+ const { container } = render(<Castform data={resume} />);- expect(container).toBeTruthy();- expect(container).toBeInTheDocument();-});+ expect(container).toBeTruthy();+ expect(container).toBeInTheDocument();+ });-describe('date of birth', () => {- const birthDateLabelMatcher = /Date of birth/i;+ describe('date of birth', () => {+ const birthDateLabelMatcher = /Date of birth/i;- it('is not shown if not provided', () => {- const { queryByText } = render(<Castform data={data} />);+ it('is not shown if not provided', () => {+ const { queryByText } = render(<Castform data={resume} />);- expect(queryByText(birthDateLabelMatcher)).toBe(null);- });+ expect(queryByText(birthDateLabelMatcher)).toBe(null);+ });- it('is shown if provided', () => {- const birthDate = new Date(1990, 0, 20);- const birthDateFormatted = '20 January 1990';- data.profile.birthDate = birthDate;+ it('is shown if provided', () => {+ const birthDate = new Date(1990, 0, 20);+ const birthDateFormatted = '20 January 1990';+ resume.profile.birthDate = birthDate;- const { getByText } = render(<Castform data={data} />);+ const { getByText } = render(<Castform data={resume} />);- expect(getByText(birthDateLabelMatcher)).toBeTruthy();- expect(getByText(birthDateLabelMatcher)).toBeInTheDocument();- expect(getByText(birthDateFormatted)).toBeTruthy();- expect(getByText(birthDateFormatted)).toBeInTheDocument();+ expect(getByText(birthDateLabelMatcher)).toBeTruthy();+ expect(getByText(birthDateLabelMatcher)).toBeInTheDocument();+ expect(getByText(birthDateFormatted)).toBeTruthy();+ expect(getByText(birthDateFormatted)).toBeInTheDocument();+ });});});