Skip to content

Commit

Permalink
fix: تصليح دالة الإنشاء وبعض الإختبارات
Browse files Browse the repository at this point in the history
  • Loading branch information
Assayyaad committed Jul 15, 2024
1 parent 1d6b902 commit 836edf1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/line/func/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* const line = Line.create.one({ spacing: 5, count: 3, neg: true })
* // line = { neg: true, count: 3, dis: 10, spacing: 5, end: -10, min: -10, max: 0, points: [0, -5, -10] }
*/
export function one({ dis = 1, end = 1, spacing = 1, count = 2, neg = false }) {
export function one({ dis, end, spacing, count, neg = false }) {
// التحقق من القيم المقدمة
if (!Number.isNaN(dis) && dis < 0) throw new Error('يجب أن تكون المسافة موجباً')
if (!Number.isNaN(spacing) && spacing < 0) throw new Error('يجب أن يكون التباعد موجباً')
Expand Down
8 changes: 4 additions & 4 deletions tests/line/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('5: اصنع نقاطاً على مستقيم', function () {
// +2 * 1 = +2
// +3 * 1 = +3

const pArr = Line.create.points(7)
const pArr = Line.create.points({ count: 7 })
deepStrictEqual(pArr, [0, 1, -1, 2, -2, 3, -3])
})

Expand All @@ -197,7 +197,7 @@ describe('5: اصنع نقاطاً على مستقيم', function () {
// (+1 * 1) + +half_spacing = +1 + +0.5 = +1.5
// (+2 * 1) + +half_spacing = +2 + +0.5 = +2.5

const pArr = Line.create.points(6)
const pArr = Line.create.points({ count: 6 })
deepStrictEqual(pArr, [0.5, -0.5, 1.5, -1.5, 2.5, -2.5])
})

Expand All @@ -212,7 +212,7 @@ describe('5: اصنع نقاطاً على مستقيم', function () {
// +2 * 2 = +4
// +3 * 2 = +6

const pArr = Line.create.points(7, 2)
const pArr = Line.create.points({ count: 7, spacing: 2 })
deepStrictEqual(pArr, [0, 2, -2, 4, -4, 6, -6])
})

Expand All @@ -228,7 +228,7 @@ describe('5: اصنع نقاطاً على مستقيم', function () {
// (+1 * 2) + +half_spacing = -2 + +1 = +3
// (+2 * 2) + +half_spacing = -4 + +1 = +5

const pArr = Line.create.points(6, 2)
const pArr = Line.create.points({ count: 6, spacing: 2 })
deepStrictEqual(pArr, [1, -1, 3, -3, 5, -5])
})
})

0 comments on commit 836edf1

Please sign in to comment.