Skip to content

Commit fd8333b

Browse files
committed
Fix invalid assert.throws statements (issue #416); ToDo: tests not passing
1 parent c9cc17d commit fd8333b

4 files changed

Lines changed: 18 additions & 30 deletions

File tree

src/danfojs-browser/tests/core/frame.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,9 @@ describe("DataFrame", function () {
123123
const data = { alpha: [ "A", "B", "C", "D" ], count: [ 1, 2, 3, 4 ], sum: [ 20.3, 30.456, 40.90, 90.1 ] };
124124
const df = new dfd.DataFrame(data);
125125

126-
assert.throws(function () {
127-
df.addColumn("new_column", new dfd.Series([ "a", "b", "c" ])),
128-
Error,
129-
'ParamError: Column data length mismatch. You provided data with length 3 but Ndframe has column of length 4';
130-
});
126+
assert.throws(
127+
() => df.addColumn("new_column", new dfd.Series([ "a", "b", "c" ])), Error,
128+
'ParamError: Column data length mismatch. You provided data with length 3 but Ndframe has column of length 4');
131129

132130
});
133131
it("Ensure add column does not mutate parent when not in place", function () {

src/danfojs-browser/tests/core/generic.test.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,16 @@ describe("Generic (NDFrame)", function () {
5959

6060
it("Throws error on duplicate column name", function () {
6161
let data = [ [ 21, 20, 1 ], [ 20, 25, 3 ] ];
62-
assert.throws(() => {
63-
new dfd.NDframe({ data, isSeries: false, columns: [ "A", "A", "C" ] }),
64-
Error,
65-
"ColumnIndexError: Column index must contain unique values";
66-
});
62+
assert.throws(
63+
() => new dfd.NDframe({ data, isSeries: false, columns: [ "A", "A", "C" ] }), Error,
64+
"ColumnIndexError: Column index must contain unique values");
6765
});
6866

6967
it("Throws error on duplicate index", function () {
7068
let data = [ [ 21, 20, 1 ], [ 20, 25, 3 ] ];
71-
assert.throws(() => {
72-
new dfd.NDframe({ data, isSeries: false, index: [ 1, 1, 2 ] }),
73-
Error,
74-
"IndexError: Row index must contain unique values";
75-
});
69+
assert.throws(
70+
() => new dfd.NDframe({ data, isSeries: false, index: [ 1, 1, 2 ] }), Error,
71+
"IndexError: Row index must contain unique values");
7672
});
7773

7874
it("Successfully create a 2D Frame when first value is empty", function () {

src/danfojs-node/test/core/frame.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,9 @@ describe("DataFrame", function () {
128128
const data = { alpha: ["A", "B", "C", "D"], val_count: [1, 2, 3, 4], val_sum: [20.3, 30.456, 40.90, 90.1] };
129129
const df = new DataFrame(data);
130130

131-
assert.throws(function () {
132-
df.addColumn("new_column", new Series(["a", "b", "c"])),
133-
Error,
134-
'ParamError: Column data length mismatch. You provided data with length 3 but Ndframe has column of length 4'
135-
})
131+
assert.throws(
132+
() => df.addColumn("new_column", new Series(["a", "b", "c"])), Error,
133+
'ParamError: Column data length mismatch. You provided data with length 3 but Ndframe has column of length 4');
136134

137135
});
138136
it("Ensure add column does not mutate parent when not in place", function () {

src/danfojs-node/test/core/generic.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,16 @@ describe("Generic (NDFrame)", function () {
6262

6363
it("Throws error on duplicate column name", function () {
6464
let data = [[21, 20, 1], [20, 25, 3]];
65-
assert.throws(() => {
66-
new NDframe({ data, isSeries: false, columns: ["A", "A", "C"] }),
67-
Error,
68-
"ColumnIndexError: Column index must contain unique values"
69-
});
65+
assert.throws(
66+
() => new NDframe({ data, isSeries: false, columns: ["A", "A", "C"] }), Error,
67+
"ColumnIndexError: Column index must contain unique values");
7068
});
7169

7270
it("Throws error on duplicate index", function () {
7371
let data = [[21, 20, 1], [20, 25, 3]];
74-
assert.throws(() => {
75-
new NDframe({ data, isSeries: false, index: [1, 1, 2] }),
76-
Error,
77-
"IndexError: Row index must contain unique values"
78-
});
72+
assert.throws(
73+
() => new NDframe({ data, isSeries: false, index: [1, 1, 2] }), Error,
74+
"IndexError: Row index must contain unique values");
7975
});
8076

8177
it("Successfully create a 2D Frame when first value is empty", function () {

0 commit comments

Comments
 (0)