test(routes): convert 3 .not.toThrow in home page to main/h1 assertions
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -169,7 +169,7 @@ describe('home page (/)', () => {
|
||||
expect(document.querySelector('main')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('renders without throwing when data props are undefined (uses ?? fallbacks)', async () => {
|
||||
it('renders the main region when data props are minimal (uses ?? fallbacks)', async () => {
|
||||
const minimalData = {
|
||||
isReader: false,
|
||||
user: { firstName: 'Anna' },
|
||||
@@ -177,17 +177,22 @@ describe('home page (/)', () => {
|
||||
canBlogWrite: false
|
||||
};
|
||||
|
||||
expect(() => render(HomePage, { props: { data: minimalData } })).not.toThrow();
|
||||
render(HomePage, { props: { data: minimalData } });
|
||||
|
||||
expect(document.querySelector('main')).not.toBeNull();
|
||||
expect(document.querySelector('h1')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('renders without throwing when reader data has all undefined fields', async () => {
|
||||
it('renders the reader dashboard main region with only required reader fields', async () => {
|
||||
const readerData = {
|
||||
isReader: true,
|
||||
user: { firstName: 'Anna' },
|
||||
canBlogWrite: false
|
||||
};
|
||||
|
||||
expect(() => render(HomePage, { props: { data: readerData } })).not.toThrow();
|
||||
render(HomePage, { props: { data: readerData } });
|
||||
|
||||
expect(document.querySelector('main')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('renders without throwing when isReader and canBlogWrite are both true (drafts module)', async () => {
|
||||
@@ -213,19 +218,19 @@ describe('home page (/)', () => {
|
||||
expect(main).not.toBeNull();
|
||||
});
|
||||
|
||||
it('renders writer dashboard without throwing with weeklyStats + pulse populated', async () => {
|
||||
// Stub-shaped objects that satisfy whichever child components expect them
|
||||
expect(() =>
|
||||
render(HomePage, {
|
||||
props: {
|
||||
data: baseData({
|
||||
isReader: false,
|
||||
user: { firstName: 'Anna' },
|
||||
canWrite: true,
|
||||
incompleteTotal: 25
|
||||
})
|
||||
}
|
||||
})
|
||||
).not.toThrow();
|
||||
it('renders the writer dashboard main region with weeklyStats + pulse populated', async () => {
|
||||
render(HomePage, {
|
||||
props: {
|
||||
data: baseData({
|
||||
isReader: false,
|
||||
user: { firstName: 'Anna' },
|
||||
canWrite: true,
|
||||
incompleteTotal: 25
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
expect(document.querySelector('main')).not.toBeNull();
|
||||
expect(document.querySelector('h1')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user