@@ -20,7 +20,7 @@ const createMockField = (dataType: MockDataType, required = false) => {
2020 } ;
2121} ;
2222
23- const createMockSchema = ( fields : string [ ] ) => {
23+ const createMockSchema = ( fields : string [ ] ) : GenericDataSchema => {
2424 const models = fields . reduce (
2525 ( prev , name ) => ( {
2626 ...prev ,
@@ -41,7 +41,7 @@ const createMockSchema = (fields: string[]) => {
4141 models,
4242 nonModels : { } ,
4343 enums : { } ,
44- } ;
44+ } as GenericDataSchema ;
4545} ;
4646
4747void describe ( 'LocalCodegenGraphqlFormGenerator' , ( ) => {
@@ -262,9 +262,35 @@ void describe('LocalCodegenGraphqlFormGenerator', () => {
262262 [ 'graphql' , './graphql' ] ,
263263 [ 'gql/graphql' , './gql/graphql' ] ,
264264 ] ;
265+ void it ( `createdAt and updatedAt fields are removed from the generated form` , async ( ) => {
266+ const schema = createMockSchema ( [ 'Post' ] ) ;
267+ assert ( 'createdAt' in schema . models . Post . fields ) ;
268+ assert ( 'updatedAt' in schema . models . Post . fields ) ;
269+ const resultGenerationSpy = mock . fn < ResultBuilder > ( ) ;
270+ resultGenerationSpy . mock . mockImplementation ( ( ) => ( {
271+ writeToDirectory : async ( ) => undefined ,
272+ } ) ) ;
273+ const l = new LocalGraphqlFormGenerator (
274+ async ( ) => schema as unknown as GenericDataSchema ,
275+ {
276+ graphqlDir : './ui-components' ,
277+ } ,
278+ resultGenerationSpy
279+ ) ;
280+
281+ await l . generateForms ( ) ;
282+
283+ assert . equal ( resultGenerationSpy . mock . callCount ( ) , 1 ) ;
284+ const componentMap = resultGenerationSpy . mock . calls [ 0 ] . arguments [ 0 ] ;
285+
286+ const component = componentMap [ 'PostCreateForm.jsx' ] ;
287+ assert . equal ( component . includes ( `createdAt` ) , false ) ;
288+ assert . equal ( component . includes ( `updatedAt` ) , false ) ;
289+ } ) ;
265290 for ( const [ directory , outputDir = directory ] of graphqlDirectories ) {
266291 void it ( `given the directory ${ directory } , the correct import path appears for the mutations in the generated form` , async ( ) => {
267292 const schema = createMockSchema ( [ 'Post' ] ) ;
293+
268294 const resultGenerationSpy = mock . fn < ResultBuilder > ( ) ;
269295 resultGenerationSpy . mock . mockImplementation ( ( ) => ( {
270296 writeToDirectory : async ( ) => undefined ,
0 commit comments