-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
expect(dst1!.id).toStrictEqual('dst1'); | ||
expect(dst1!.type).toStrictEqual(ResourceType.Datasheet); | ||
expect(dst1!.name).toStrictEqual('datasheet 1'); | ||
return new Promise(resolve => { |
There was a problem hiding this comment.
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)); | ||
}); |
There was a problem hiding this comment.
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
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
} else { | ||
return text.indexOf(pattern) >= 0; | ||
} |
Check warning
Code scanning / ESLint
disallow `else` blocks after `return` statements in `if` statements
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
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
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
This pr was accidentally turned off by me, the new pr is located at Pull Request |
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>
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 ofMockDataLoadersaver
.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.