Skip to content

Commit

Permalink
feat: added event test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin101Zhang committed Aug 2, 2024
1 parent 051d375 commit cd8f3d6
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions frontend/src/test/api/generateCode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const createRequestResponseMocks = (
};
};

describe('generateCode API', () => {
it('should return generated JS and SQL code for valid input', async () => {
describe('generateCode API ', () => {
it('should return generated JS and SQL code for valid input methods', async () => {
const { req, res } = createRequestResponseMocks('POST', {
contractFilter: 'filter',
selectedMethods: [
Expand Down Expand Up @@ -74,6 +74,56 @@ describe('generateCode API', () => {
const responseData = JSON.parse(res._getData());
console.log(responseData);
});

it('should return generated JS and SQL code for valid input events', async () => {
const { req, res } = createRequestResponseMocks('POST', {
contractFilter: 'filter',
selectedMethods: [],
selectedEvents: [{
event_name: 'register',
schema: {
type: 'object',
properties: {
function_name: {
type: 'string',
},
code: {
type: 'string',
},
schema: {
type: 'string',
},
start_block_height: {
type: 'integer',
},
filter_json: {
type: 'string',
},
},
required: ['function_name', 'code', 'schema', 'start_block_height', 'filter_json'],
},
},
{
event_name: 'remove_indexer_function',
schema: {
type: 'object',
properties: {
function_name: {
type: 'string',
},
},
required: ['function_name'],
},
},],
});

handler(req, res);

expect(res._getStatusCode()).toBe(200);
const responseData = JSON.parse(res._getData());
console.log(responseData);
});

it('should handle empty arrays correctly because I mean maybe they just want something to do with contractName?', async () => {
const { req, res } = createRequestResponseMocks('POST', {
contractFilter: 'filter',
Expand Down

0 comments on commit cd8f3d6

Please sign in to comment.