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: add property based tests to DataBus #454

Closed
wants to merge 1 commit into from

Conversation

ziqiangai
Copy link
Contributor

Submit a pull request for this project.

Why?

For the issue #140
Use fast-check.js to simply test the two commands of DataBus to test whether the test quality of DataBus can be improved.

What?

I modified the SaveOps logic of MockDataLoadersaver.

At the same time, a test script is added. If the test code is valid, we can expand the test of DataBus on the basis of this.

expect(dst1!.id).toStrictEqual('dst1');
expect(dst1!.type).toStrictEqual(ResourceType.Datasheet);
expect(dst1!.name).toStrictEqual('datasheet 1');
return new Promise(resolve => {
Copy link
Contributor

Choose a reason for hiding this comment

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

A simple return prosEq is enough.

const fieldCount = Object.keys(dst1.fields).length;
return new Promise(resolve => {
resolve(fieldCount >= (oldFieldCount + 1));
});
Copy link
Contributor

Choose a reason for hiding this comment

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

missing assertions inside this function

@arucil
Copy link
Contributor

arucil commented Feb 27, 2023

Great job. Only some minor problems remain, fix them then everything is good.

@@ -0,0 +1,124 @@
import { MockDataBus, resetDataLoader } from './mock.databus';
import { ResourceType } from 'types';
import { CollaCommandName, } from 'commands';

Check warning

Code scanning / ESLint

require or disallow trailing commas

Unexpected trailing comma.
Comment on lines +17 to +19
} else {
return text.indexOf(pattern) >= 0;
}

Check warning

Code scanning / ESLint

disallow `else` blocks after `return` statements in `if` statements

Unnecessary 'else' after 'return'.
const oldViewColumnCount = view1?.columns.length || 0;
expect(oldViewColumnCount).toStrictEqual(2);
let expectFieldAddedCount = 0;
await fc.assert(fc.asyncProperty(fc.string(), fc.integer({min: 2 , max: 200}),

Check warning

Code scanning / ESLint

enforce consistent spacing inside braces

A space is required after '{'.
const oldViewColumnCount = view1?.columns.length || 0;
expect(oldViewColumnCount).toStrictEqual(2);
let expectFieldAddedCount = 0;
await fc.assert(fc.asyncProperty(fc.string(), fc.integer({min: 2 , max: 200}),

Check warning

Code scanning / ESLint

enforce consistent spacing inside braces

A space is required before '}'.
expect(oldViewColumnCount).toStrictEqual(2);
let expectFieldAddedCount = 0;
await fc.assert(fc.asyncProperty(fc.string(), fc.integer({min: 2 , max: 200}),
async (aStr: string, aInt: number) => {

Check warning

Code scanning / ESLint

enforce consistent spacing before `function` definition opening parenthesis

Unexpected space before function parentheses.
@ziqiangai ziqiangai closed this Feb 27, 2023
@ziqiangai ziqiangai deleted the fast-check-for-databus branch February 27, 2023 03:42
@ziqiangai ziqiangai restored the fast-check-for-databus branch February 27, 2023 03:52
@ziqiangai
Copy link
Contributor Author

This pr was accidentally turned off by me, the new pr is located at Pull Request

arucil pushed a commit that referenced this pull request Feb 27, 2023
Submit a pull request for this project.

<!-- If you have an Issue that related to this Pull Request, you can
copy this Issue's description -->

# Why? 
<!-- 
> Related to which issue?
> Why we need this pull request?
> What is the user story for this pull request? 
-->
For the issue #140 
Use `fast-check.js` to simply test the two commands of DataBus to test
whether the test quality of DataBus can be improved.




# What?
<!-- 
> Can you describe this feature in detail?
> Who can benefit from it? 
-->

I modified the `SaveOps` logic of `MockDataLoadersaver`.

At the same time, a test script is added. If the test code is valid, we
can expand the test of `DataBus` on the basis of this.


To explain, the old [pull
request](#454) was closed
because I accidentally deleted the code branch, so now I created a new
pull request.

Co-authored-by: Kelly Chan <kelly@apitable.com>
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.

None yet

2 participants