import Matrix from 'ml-matrix';
import { Image } from 'test/common';

describe('check the open function', function () {
  it('check for GREY image 5x5', function () {
    let kernel = new Matrix([
      [1, 1, 1],
      [1, 1, 1],
      [1, 1, 1],
    ]);
    let image = new Image(
      5,
      5,
      [
        255,
        255,
        0,
        255,
        255,
        255,
        0,
        0,
        0,
        255,
        255,
        0,
        0,
        0,
        255,
        255,
        0,
        0,
        0,
        255,
        255,
        255,
        0,
        255,
        255,
      ],
      { kind: 'GREY' },
    );

    expect(Array.from(image.open({ kernel }).data)).toStrictEqual([
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
    ]);
  });

  it('check for GREY image 5x5 2 iterations', function () {
    let kernel = new Matrix([
      [1, 1, 1],
      [1, 1, 1],
      [1, 1, 1],
    ]);
    let image = new Image(
      5,
      5,
      [
        255,
        255,
        255,
        255,
        255,
        255,
        255,
        0,
        255,
        255,
        255,
        0,
        0,
        0,
        255,
        255,
        255,
        0,
        255,
        255,
        255,
        255,
        255,
        255,
        255,
      ],
      { kind: 'GREY' },
    );

    expect(
      Array.from(image.open({ kernel, iterations: 2 }).data),
    ).toStrictEqual([
      255,
      255,
      0,
      255,
      255,
      255,
      255,
      0,
      255,
      255,
      0,
      0,
      0,
      0,
      0,
      255,
      255,
      0,
      255,
      255,
      255,
      255,
      0,
      255,
      255,
    ]);
  });
});

@@ -1,36 +1,4 @@
-import Matrix from 'ml-matrix';%0A
 impo
@@ -15,17 +15,17 @@
  %7D from 
-'
+%22
 test/com
@@ -27,17 +27,17 @@
 t/common
-'
+%22
 ;%0A%0Adescr
@@ -40,17 +40,17 @@
 escribe(
-'
+%22
 check th
@@ -64,17 +64,17 @@
 function
-'
+%22
 , functi
@@ -82,25 +82,25 @@
 n () %7B%0A  it(
-'
+%22
 check for GR
@@ -111,17 +111,17 @@
 mage 5x5
-'
+%22
 , functi
@@ -141,35 +141,24 @@
 et kernel = 
-new Matrix(
 %5B%0A      %5B1, 
@@ -195,33 +195,32 @@
 %5B1, 1, 1%5D,%0A    %5D
-)
 ;%0A    let image 
@@ -580,33 +580,32 @@
     %7B kind: 
-'
+%22
 GREY
-'
+%22
  %7D
-,
 %0A    );%0A%0A   
@@ -914,17 +914,17 @@
 ;%0A%0A  it(
-'
+%22
 check fo
@@ -952,17 +952,17 @@
 erations
-'
+%22
 , functi
@@ -990,19 +990,8 @@
 l = 
-new Matrix(
 %5B%0A  
@@ -1040,25 +1040,24 @@
 1, 1%5D,%0A    %5D
-)
 ;%0A    let im
@@ -1441,17 +1441,16 @@
 nd: 
-'
+%22
 GREY
-'
+%22
  %7D
-,
 %0A   
@@ -1526,17 +1526,16 @@
 %7D).data)
-,
 %0A    ).t

fix opent testcase