Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Cases #151

Open
wants to merge 17 commits into
base: feat/c4gt
Choose a base branch
from
Open

Conversation

shashwatm1111
Copy link

Added test case #79

@shashwatm1111 shashwatm1111 changed the title Update dateparser.spec.ts test Test Cases Jul 19, 2023
Copy link
Collaborator

@techsavvyash techsavvyash left a comment

Choose a reason for hiding this comment

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

Where are the tests for query builder service?

@@ -1,7 +1,7 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why have you exported this?

PK,,Index`;
const mockReadFile = jest.fn().mockResolvedValue(mockFileContent);
const csvFilePath = '/path/to/valid_file.csv';
await createDimensionGrammarFromCSVDefinition(csvFilePath, mockReadFile);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make sure the function is returning the correct response as well

const csvFilePath = '/path/to/invalid_file.csv';
console.error = jest.fn();
const result = await createDimensionGrammarFromCSVDefinition(csvFilePath, mockReadFile);
expect(result).toBeNull();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a positive test case where the result is not null.

// const inputFilePath = 'test-input.csv';
// const outputFilePath = 'test-output.csv';

// // Create a sample input file
Copy link
Collaborator

Choose a reason for hiding this comment

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

Uncomment and fix these test cases as well

it('should return "Hello World!"', () => {
expect('Hello World!').toBe('Hello World!');
});
it('should return "Hello World!"', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

delete this expect('Hello World!').toBe('HelloWorld!') test

expect(result).toBe(4);
});

it('should transform asynchronously', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what exactly is the intention behind this test case?

const transformAsyncFn = service.stringToTransformAsync('(callback) => { throw new Error("Test Error"); }');
try {
await transformAsyncFn(null, null, null);
expect(true).toBe(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is this???? 😱

Copy link
Author

Choose a reason for hiding this comment

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

The purpose of this assertion is to ensure that the try...catch block is actually catching the error. If the try...catch block was not catching the error, then the expect statement would not fail and the test would pass even though the error was not actually caught. And this test case is covering the catch error line under stringToTransformAsync property .

try {
await transformAsyncFn(null, null, null);
expect(true).toBe(false);
} catch (error) {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

where is the error expected?

Copy link
Author

Choose a reason for hiding this comment

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

Added expect statement for this .

const callback = jest.fn();
try {
transformSyncFn(callback, null, null);
expect(true).toBe(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is happening here?? 😱

Copy link
Author

Choose a reason for hiding this comment

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

The purpose of this assertion is to ensure that the try...catch block is actually catching the error. If the try...catch block was not catching the error, then the expect statement would not fail and the test would pass even though the error was not actually caught. And this test case is covering the catch error line under stringToTransformSync property .

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not making sense to me kindly explain this during today's call.

// eslint-disable-next-line @typescript-eslint/no-var-requires

jest.mock('yargs', () => ({
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are yargs tests inside hash.spec.ts? what is the relevance for adding them here?

@shashwatm1111 shashwatm1111 changed the base branch from master to feat/c4gt August 30, 2023 14:32
@techsavvyash
Copy link
Collaborator

@shashwatm1111 resolve all the comments and merge conflicts on this PR to get this into a mergable state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants