const assert = require('assert');
const randsub = require('../src/util/randsub');

describe('Util - randsub()', function () {
	it('returns the array if num >= its length', function () {
		const arr = [1, 2, 3];
		const output1 = randsub(arr, 3);
		assert(output1 === arr);
		const output2 = randsub(arr, 4);
		assert(output2 === arr);
	});

	it('returns an empty array if num <= 0', function () {
		const arr = [4, 5, 6];
		const output1 = randsub(arr, 0);
		assert(output1.length === 0);
		const output2 = randsub(arr, -10);
		assert(output2.length === 0);
	});

	it('returns a subarray', function () {
		const arr = [];
		for (let i = 0; i < 5; i++) {
			arr.push(Math.floor(Math.random() * 0xFFFFFF));
		}

		for (let num = 1; num < 3; num++) {
			const output = randsub(arr, 1);
			for (const value of output) {
				assert(arr.includes(value));
			}
		}
	});
});

@@ -1,62 +1,24 @@
-const assert = require('assert');%0Aconst randsub = require(
+import randsub from 
 '../
@@ -34,17 +34,16 @@
 randsub'
-)
 ;%0A%0Adescr
@@ -66,27 +66,21 @@
 sub()', 
-function ()
+() =%3E
  %7B%0A%09it('
@@ -120,27 +120,21 @@
 ength', 
-function ()
+() =%3E
  %7B%0A%09%09con
@@ -186,29 +186,29 @@
 (arr, 3);%0A%09%09
-asser
+expec
 t(output1 ==
@@ -204,21 +204,23 @@
 (output1
- === 
+).toBe(
 arr);%0A%09%09
@@ -250,29 +250,29 @@
 (arr, 4);%0A%09%09
-asser
+expec
 t(output2 ==
@@ -268,21 +268,23 @@
 (output2
- === 
+).toBe(
 arr);%0A%09%7D
@@ -329,27 +329,21 @@
  %3C= 0', 
-function ()
+() =%3E
  %7B%0A%09%09con
@@ -395,29 +395,29 @@
 (arr, 0);%0A%09%09
-asser
+expec
 t(output1.le
@@ -413,28 +413,31 @@
 (output1
-.length === 
+).toHaveLength(
 0);%0A%09%09co
@@ -471,21 +471,21 @@
 -10);%0A%09%09
-asser
+expec
 t(output
@@ -489,20 +489,23 @@
 put2
-.length === 
+).toHaveLength(
 0);%0A
@@ -540,19 +540,13 @@
 y', 
-function ()
+() =%3E
  %7B%0A%09
@@ -764,35 +764,36 @@
 %09%09%09%09
-assert(arr.includes
+expect(arr).toContain
 (value)
-)
 ;%0A%09%09

Rewrite tests of randsub()