-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix zmount test cases #3608
Fix zmount test cases #3608
Conversation
|
||
expect(result).toThrow(); | ||
expect(result).toBe(size.toString()); |
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.
can directly do expect(zmount.challenge()).toBe....
|
||
expect(result).toThrow(); | ||
expect(result).toBe(size.toString()); | ||
}); | ||
|
||
test("Max value for size.", () => { | ||
const size = 100 * 1025 ** 4; |
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.
What do these numbers mean? try extracting to a const
max: "size must not be greater than 10995116277760", | ||
}, | ||
}), | ||
); | ||
}); | ||
|
||
test("Size doesn't accept decimal value.", () => { | ||
const size = 1.5; |
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.
is that 1.5 byte?
min: "size must not be less than 104857600", | ||
}, | ||
}), | ||
); | ||
}); | ||
|
||
test("Size empty value.", () => { |
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.
While we are at it, check against null, undefined, NaN, {} , and []
}).toThrow( | ||
expect.objectContaining({ | ||
constraints: { | ||
max: "size must not be greater than 10995116277760", |
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.
check against the boundaries max, and min
and off by 1 min - 1 and max+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.
We need to use better descriptions to describe the cases better
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.
const result = () => zmount.challenge(); | ||
it("should fail validation if size is greater than the maximum", async () => { | ||
// Greater than 10 TB | ||
expect(() => (zmount.size = 15 * 1024 ** 4)).toThrow(); |
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.
define the min and max as constants before any of the tests
please place the min and max values in a constant before any of the tests. Please move tests that check if size is null, Nan or not an int before the min and max tests |
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.
you should add a test for setting a floating number
const minSize = 50 * 1024 ** 2; // Less than 100 MB | ||
const maxSize = 15 * 1024 ** 4; // Greater than 10 TB | ||
const validSize = 5 * 1024 ** 3; |
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.
it's better to have a random size (within a certain range) to test with
you can use this method to generate the random number
function getRandomNumber(min: number, max: number): number { |
let zmount: Zmount; | ||
const minSize = 50 * 1024 ** 2; // Less than 100 MB | ||
const maxSize = 15 * 1024 ** 4; // Greater than 10 TB | ||
const validSize = 5 * 1024 ** 3; |
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.
Why are we initializing this with a value, if we're using getRandomNumber
|
||
expect(result).toThrow(); | ||
const result = zmount.challenge(); | ||
expect(typeof result).toBe("string"); |
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.
you can cast validSize
to string and check against its value
Description
Fix zmount test suite expected errors.
Changes
Related Issues
Tested Scenarios
Checklist