Skip to content

Conversation

@chanaKastellanith
Copy link

No description provided.

Copy link
Owner

@gemtechd gemtechd left a comment

Choose a reason for hiding this comment

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

use the it test function and not test
see more comments about the code

constructor({ point1 = new Point(), point2 = new Point(), n = undefined, slope = undefined }) {
if (!(point1 instanceof Point) || !(point2 instanceof Point)) {
throw new Error('InvalidPointError: point1 and point2 must be instances of Point');
}
Copy link
Owner

Choose a reason for hiding this comment

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

what happens if n is a string, or if slope is an object (for example)

}

calculateSlope() {
calculateSlope = () => {
Copy link
Owner

Choose a reason for hiding this comment

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

it's better it should be calculateSlope() and not calculateScope = () =>

this.calculateNOfLineFunction();
}
if (this.slope === 0) {
throw new Error('InvalidSlopeError: Slope cannot be zero for calculating X by Y');
Copy link
Owner

Choose a reason for hiding this comment

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

so what is the x? how do you calculate it?

const Point = require('../modules/ecs6-class/point');
const calculateDistance = (point1, point2) => {
if (!point1 || !point2 || typeof point1.x !== 'number' || typeof point1.y !== 'number' || typeof point2.x !== 'number' || typeof point2.y !== 'number') {
throw new Error('Invalid input points');
Copy link
Owner

Choose a reason for hiding this comment

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

which input is invalid? and why is it invalid?

const calculateJunctionPoint = (line1, line2) => {

if (!(line1 instanceof Line) || !(line2 instanceof Line)) {
throw new Error('Invalid input lines');
Copy link
Owner

Choose a reason for hiding this comment

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

which one?


describe('Line class', () => {
test('should create a line with default points and undefined slope and n', () => {
const line = new Line({});
Copy link
Owner

Choose a reason for hiding this comment

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

give more examples for the good constructor



test('should handle horizontal lines correctly by throwing an error', () => {
// Create a horizontal line (slope = 0)
Copy link
Owner

Choose a reason for hiding this comment

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

remove comments before pushing


describe('Point class', () => {
test('should create a point with default values (0, 0)', () => {
const point = new Point();
Copy link
Owner

Choose a reason for hiding this comment

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

create more examples

Copy link
Owner

Choose a reason for hiding this comment

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

Where are the mocks for the functions?

const line = new Line({ point1: point1, point2: point2} );
const point = new Point({ x: 2, y: 2 });
line.calculateSlope();
line.calculateNOfLineFunction();
Copy link
Owner

Choose a reason for hiding this comment

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

you can't call different functions so that you test will be good
each unittest calls only one function (that's what you have written in the presentation)

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