Skip to content

Commit

Permalink
work on archive page
Browse files Browse the repository at this point in the history
  • Loading branch information
narthur committed Nov 8, 2022
1 parent f32a460 commit 5f5d48b
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 11 deletions.
4 changes: 4 additions & 0 deletions global-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ vi.mock('@mui/x-date-pickers');
vi.mock('./src/lib/api/getTimezones');
vi.mock('./src/lib/api/getCheckoutSession');
vi.mock('./src/lib/stripe');
vi.mock('./src/lib/api/getTasks');
vi.mock('./src/lib/api/getMe');
vi.mock('./src/lib/api/updateTask');
vi.mock('./src/lib/api/addTask');

global.scrollTo = vi.fn() as any;

Expand Down
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function App(): JSX.Element {
path={'/'}
element={
<Authenticated>
<Tasks lastToday={lastToday} />
<Tasks />
</Authenticated>
}
/>
Expand Down
25 changes: 25 additions & 0 deletions src/components/pages/Archive.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { vi, Mock, describe, it, expect, beforeEach } from 'vitest';
import { renderWithQueryProvider } from '../../lib/test/renderWithQueryProvider';
import Archive from './Archive';
import React from 'react';
import { loadTasksApiData } from '../../lib/test/loadTasksApiData';
import { makeTask } from '../../lib/test/makeTask';
import { screen } from '@testing-library/react';

describe('Archive', () => {
it('should render', () => {
renderWithQueryProvider(<Archive />);
});

// it('lists old tasks', () => {
// vi.setSystemTime(new Date('2021-01-01T00:00:00.000Z'));

// loadTasksApiData({
// tasks: [makeTask({ id: 'old_task', due: '2020-12-31T00:00:00.000Z' })],
// });

// renderWithQueryProvider(<Archive />);

// expect(screen.getByText('old_task')).toBeInTheDocument();
// });
});
5 changes: 5 additions & 0 deletions src/components/pages/Archive.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

export default function Archive(): JSX.Element {
return <>Archive</>;
}
2 changes: 1 addition & 1 deletion src/components/pages/Tasks.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const expectTaskSave = async ({
};

const renderTasksPage = () => {
const view = renderWithQueryProvider(<Tasks lastToday={undefined} />);
const view = renderWithQueryProvider(<Tasks />);

return {
openForm: async () => {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts", ".eslintrc.js"]
"include": ["vite.config.ts", "vitest.config.ts", ".eslintrc.js"]
}
9 changes: 1 addition & 8 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
/// <reference types="vitest" />
import { defineConfig } from 'vitest/config';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { visualizer } from 'rollup-plugin-visualizer';

export default defineConfig({
plugins: [react(), visualizer()],
test: {
environment: 'jsdom',
setupFiles: ['./global-setup.ts'],
clearMocks: true,
reporters: 'dot',
},
build: {
rollupOptions: {
output: {
Expand Down
12 changes: 12 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';

export default defineConfig({
plugins: [react()],
test: {
environment: 'jsdom',
setupFiles: ['./global-setup.ts'],
clearMocks: true,
reporters: 'dot',
},
});

1 comment on commit 5f5d48b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.