Skip to content

Commit

Permalink
fix(cli): Update cell test template to include id (#11749)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Dec 5, 2024
1 parent 2a86400 commit 495f625
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('AuthorCell', () => {

it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={42} error={new Error('Oh no')} />)
}).not.toThrow()
})

Expand All @@ -36,7 +36,7 @@ describe('AuthorCell', () => {

it('renders Success successfully', async () => {
expect(() => {
render(<Success author={standard().author} />)
render(<Success id={42} author={standard().author} />)
}).not.toThrow()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('BlogPostCell', () => {

it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={42} error={new Error('Oh no')} />)
}).not.toThrow()
})

Expand All @@ -36,7 +36,7 @@ describe('BlogPostCell', () => {

it('renders Success successfully', async () => {
expect(() => {
render(<Success blogPost={standard().blogPost} />)
render(<Success id={42} blogPost={standard().blogPost} />)
}).not.toThrow()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('BlogPostsCell', () => {

it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={42} error={new Error('Oh no')} />)
}).not.toThrow()
})

Expand All @@ -36,7 +36,7 @@ describe('BlogPostsCell', () => {

it('renders Success successfully', async () => {
expect(() => {
render(<Success blogPosts={standard().blogPosts} />)
render(<Success id={42} blogPosts={standard().blogPosts} />)
}).not.toThrow()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('WaterfallBlogPostCell', () => {

it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={42} error={new Error('Oh no')} />)
}).not.toThrow()
})

Expand All @@ -36,7 +36,9 @@ describe('WaterfallBlogPostCell', () => {

it('renders Success successfully', async () => {
expect(() => {
render(<Success waterfallBlogPost={standard().waterfallBlogPost} />)
render(
<Success id={42} waterfallBlogPost={standard().waterfallBlogPost} />
)
}).not.toThrow()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe('CustomIdFieldsCell', () => {
it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure uuid={'42'} error={new Error('Oh no')} />)
}).not.toThrow()
})
Expand All @@ -178,7 +178,7 @@ describe('CustomIdFieldsCell', () => {
it('renders Success successfully', async () => {
expect(() => {
render(<Success customIdFields={standard().customIdFields} />)
render(<Success uuid={'42'} customIdFields={standard().customIdFields} />)
}).not.toThrow()
})
})
Expand Down Expand Up @@ -283,7 +283,7 @@ describe('CustomIdFieldCell', () => {
it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure uuid={'42'} error={new Error('Oh no')} />)
}).not.toThrow()
})
Expand All @@ -295,7 +295,7 @@ describe('CustomIdFieldCell', () => {
it('renders Success successfully', async () => {
expect(() => {
render(<Success customIdField={standard().customIdField} />)
render(<Success uuid={'42'} customIdField={standard().customIdField} />)
}).not.toThrow()
})
})
Expand Down Expand Up @@ -400,7 +400,7 @@ describe('UserProfileCell', () => {
it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={42} error={new Error('Oh no')} />)
}).not.toThrow()
})
Expand All @@ -412,7 +412,7 @@ describe('UserProfileCell', () => {
it('renders Success successfully', async () => {
expect(() => {
render(<Success userProfile={standard().userProfile} />)
render(<Success id={42} userProfile={standard().userProfile} />)
}).not.toThrow()
})
})
Expand Down Expand Up @@ -517,7 +517,7 @@ describe('UserProfileCell', () => {
it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={42} error={new Error('Oh no')} />)
}).not.toThrow()
})
Expand All @@ -529,7 +529,7 @@ describe('UserProfileCell', () => {
it('renders Success successfully', async () => {
expect(() => {
render(<Success userProfile={standard().userProfile} />)
render(<Success id={42} userProfile={standard().userProfile} />)
}).not.toThrow()
})
})
Expand Down Expand Up @@ -634,7 +634,7 @@ describe('UserCell', () => {
it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={42} error={new Error('Oh no')} />)
}).not.toThrow()
})
Expand All @@ -646,7 +646,7 @@ describe('UserCell', () => {
it('renders Success successfully', async () => {
expect(() => {
render(<Success user={standard().user} />)
render(<Success id={42} user={standard().user} />)
}).not.toThrow()
})
})
Expand Down Expand Up @@ -751,7 +751,7 @@ describe('UserProfileCell', () => {
it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={42} error={new Error('Oh no')} />)
}).not.toThrow()
})
Expand All @@ -763,7 +763,7 @@ describe('UserProfileCell', () => {
it('renders Success successfully', async () => {
expect(() => {
render(<Success userProfile={standard().userProfile} />)
render(<Success id={42} userProfile={standard().userProfile} />)
}).not.toThrow()
})
})
Expand Down Expand Up @@ -835,7 +835,7 @@ describe('BazingaCell', () => {
it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={42} error={new Error('Oh no')} />)
}).not.toThrow()
})
Expand All @@ -847,7 +847,7 @@ describe('BazingaCell', () => {
it('renders Success successfully', async () => {
expect(() => {
render(<Success bazinga={standard().bazinga} />)
render(<Success id={42} bazinga={standard().bazinga} />)
}).not.toThrow()
})
})
Expand Down Expand Up @@ -1040,7 +1040,7 @@ describe('UserProfileCell', () => {
it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={42} error={new Error('Oh no')} />)
}).not.toThrow()
})
Expand All @@ -1052,7 +1052,7 @@ describe('UserProfileCell', () => {
it('renders Success successfully', async () => {
expect(() => {
render(<Success userProfile={standard().userProfile} />)
render(<Success id={42} userProfile={standard().userProfile} />)
}).not.toThrow()
})
})
Expand Down Expand Up @@ -1109,7 +1109,7 @@ describe('AddressCell', () => {
it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={'42'} error={new Error('Oh no')} />)
}).not.toThrow()
})
Expand All @@ -1121,7 +1121,7 @@ describe('AddressCell', () => {
it('renders Success successfully', async () => {
expect(() => {
render(<Success address={standard().address} />)
render(<Success id={'42'} address={standard().address} />)
}).not.toThrow()
})
})
Expand Down Expand Up @@ -1232,7 +1232,7 @@ describe('AddressesCell', () => {
it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={'42'} error={new Error('Oh no')} />)
}).not.toThrow()
})
Expand All @@ -1244,7 +1244,7 @@ describe('AddressesCell', () => {
it('renders Success successfully', async () => {
expect(() => {
render(<Success addresses={standard().addresses} />)
render(<Success id={'42'} addresses={standard().addresses} />)
}).not.toThrow()
})
})
Expand Down Expand Up @@ -1365,7 +1365,7 @@ describe('MembersCell', () => {
it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure id={42} error={new Error('Oh no')} />)
}).not.toThrow()
})
Expand All @@ -1377,7 +1377,7 @@ describe('MembersCell', () => {
it('renders Success successfully', async () => {
expect(() => {
render(<Success members={standard().members} />)
render(<Success id={42} members={standard().members} />)
}).not.toThrow()
})
})
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/commands/generate/cell/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export const files = async ({ name, typescript, ...options }) => {
webPathSection: REDWOOD_WEB_PATH_NAME,
generator: 'cell',
templatePath: 'test.js.template',
templateVars: {
idName,
mockIdValues,
},
})

const storiesFile = await templateForComponentFile({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('${pascalName}Cell', () => {

it('renders Failure successfully', async () => {
expect(() => {
render(<Failure error={new Error('Oh no')} />)
render(<Failure <% if (idName) { %>${idName}={${mockIdValues[0]}} <% } %>error={new Error('Oh no')} />)
}).not.toThrow()
})

Expand All @@ -36,7 +36,7 @@ describe('${pascalName}Cell', () => {

it('renders Success successfully', async () => {
expect(() => {
render(<Success ${camelName}={standard().${camelName}} />)
render(<Success <% if (idName) { %>${idName}={${mockIdValues[0]}} <% } %>${camelName}={standard().${camelName}} />)
}).not.toThrow()
})
})

0 comments on commit 495f625

Please sign in to comment.