1- import "mocha" ;
2- import expect from "expect.js" ;
1+ import "jest" ;
32import { NormalizedDataPoint } from "./types" ;
43import { calculateTriangleArea , calculateAverageDataPoint , splitIntoBuckets } from "./utils" ;
54
@@ -10,49 +9,49 @@ describe("utils", () => {
109 const pointB : NormalizedDataPoint = [ 2 , 2 ] ;
1110 const pointC : NormalizedDataPoint = [ 3 , 2 ] ;
1211
13- expect ( calculateTriangleArea ( pointA , pointB , pointC ) ) . to . be ( 0 ) ;
12+ expect ( calculateTriangleArea ( pointA , pointB , pointC ) ) . toBe ( 0 ) ;
1413 } ) ;
1514
1615 it ( "should return correct area for a triangle aligned with an axis" , ( ) => {
1716 const pointA : NormalizedDataPoint = [ 1 , 0 ] ;
1817 const pointB : NormalizedDataPoint = [ 2 , 5 ] ;
1918 const pointC : NormalizedDataPoint = [ 3 , 0 ] ;
2019
21- expect ( calculateTriangleArea ( pointA , pointB , pointC ) ) . to . be ( 5 ) ;
20+ expect ( calculateTriangleArea ( pointA , pointB , pointC ) ) . toBe ( 5 ) ;
2221 } ) ;
2322
2423 it ( "should return correct area for a triangle not aligned with an axis" , ( ) => {
2524 const pointA : NormalizedDataPoint = [ 1 , 2 ] ;
2625 const pointB : NormalizedDataPoint = [ 2 , 5 ] ;
2726 const pointC : NormalizedDataPoint = [ 3 , 5 ] ;
2827
29- expect ( calculateTriangleArea ( pointA , pointB , pointC ) ) . to . be ( 1.5 ) ;
28+ expect ( calculateTriangleArea ( pointA , pointB , pointC ) ) . toBe ( 1.5 ) ;
3029 } ) ;
3130
3231 it ( "should return correct area for a triangle covering negative quadrants" , ( ) => {
3332 const pointA : NormalizedDataPoint = [ - 1 , - 1 ] ;
3433 const pointB : NormalizedDataPoint = [ 0 , 1 ] ;
3534 const pointC : NormalizedDataPoint = [ 1 , - 1 ] ;
3635
37- expect ( calculateTriangleArea ( pointA , pointB , pointC ) ) . to . be ( 2 ) ;
36+ expect ( calculateTriangleArea ( pointA , pointB , pointC ) ) . toBe ( 2 ) ;
3837 } ) ;
3938 } ) ;
4039
4140 describe ( "calculateAverageDataPoint" , ( ) => {
4241 it ( "should return undefined when passed no data points" , ( ) => {
43- expect ( calculateAverageDataPoint ( ) ) . to . be ( undefined ) ;
42+ expect ( calculateAverageDataPoint ( ) ) . toBe ( undefined ) ;
4443 } ) ;
4544
4645 it ( "should return the same point when passed one data point" , ( ) => {
47- expect ( calculateAverageDataPoint ( [ 0 , 1 ] ) ) . to . eql ( [ 0 , 1 ] ) ;
46+ expect ( calculateAverageDataPoint ( [ 0 , 1 ] ) ) . toEqual ( [ 0 , 1 ] ) ;
4847 } ) ;
4948
5049 it ( "should return correct point average" , ( ) => {
5150 const pointA : NormalizedDataPoint = [ - 1 , - 1 ] ;
5251 const pointB : NormalizedDataPoint = [ 0 , 2 ] ;
5352 const pointC : NormalizedDataPoint = [ 1 , - 1 ] ;
5453
55- expect ( calculateAverageDataPoint ( pointA , pointB , pointC ) ) . to . eql ( [ 0 , 0 ] ) ;
54+ expect ( calculateAverageDataPoint ( pointA , pointB , pointC ) ) . toEqual ( [ 0 , 0 ] ) ;
5655 } ) ;
5756 } ) ;
5857
@@ -72,7 +71,7 @@ describe("utils", () => {
7271 expect ( splitIntoBuckets ( [
7372 [ 0 , 2 ] ,
7473 [ 1 , - 1 ]
75- ] , 2 ) ) . to . eql ( [
74+ ] , 2 ) ) . toEqual ( [
7675 [
7776 [ 0 , 2 ]
7877 ] ,
@@ -83,17 +82,17 @@ describe("utils", () => {
8382 } ) ;
8483
8584 it ( "should return an array of desired length" , ( ) => {
86- expect ( splitIntoBuckets ( data , 2 ) ) . to . have . length ( 2 ) ;
87- expect ( splitIntoBuckets ( data , 3 ) ) . to . have . length ( 3 ) ;
88- expect ( splitIntoBuckets ( data , 4 ) ) . to . have . length ( 4 ) ;
89- expect ( splitIntoBuckets ( data , 5 ) ) . to . have . length ( 5 ) ;
85+ expect ( splitIntoBuckets ( data , 2 ) ) . toHaveLength ( 2 ) ;
86+ expect ( splitIntoBuckets ( data , 3 ) ) . toHaveLength ( 3 ) ;
87+ expect ( splitIntoBuckets ( data , 4 ) ) . toHaveLength ( 4 ) ;
88+ expect ( splitIntoBuckets ( data , 5 ) ) . toHaveLength ( 5 ) ;
9089 } ) ;
9190
9291 it ( "should return an array with the first and the last bucket containing the first and the last data points" , ( ) => {
93- expect ( splitIntoBuckets ( data , 3 ) [ 0 ] ) . to . have . length ( 1 ) ;
94- expect ( splitIntoBuckets ( data , 3 ) [ 0 ] ) . to . eql ( [ [ 0 , 2 ] ] ) ;
95- expect ( splitIntoBuckets ( data , 3 ) [ 2 ] ) . to . have . length ( 1 ) ;
96- expect ( splitIntoBuckets ( data , 3 ) [ 2 ] ) . to . eql ( [ [ 7 , - 1 ] ] ) ;
92+ expect ( splitIntoBuckets ( data , 3 ) [ 0 ] ) . toHaveLength ( 1 ) ;
93+ expect ( splitIntoBuckets ( data , 3 ) [ 0 ] ) . toEqual ( [ [ 0 , 2 ] ] ) ;
94+ expect ( splitIntoBuckets ( data , 3 ) [ 2 ] ) . toHaveLength ( 1 ) ;
95+ expect ( splitIntoBuckets ( data , 3 ) [ 2 ] ) . toEqual ( [ [ 7 , - 1 ] ] ) ;
9796 } ) ;
9897 } ) ;
9998} ) ;
0 commit comments