3
3
4
4
import { describe , expect , test } from "vitest" ;
5
5
import { fromMatrix , generateGrid , generateRandomPath , generateResize , toString } from "../../debug-tools" ;
6
+ import { Position } from "../../utils/position" ;
6
7
import { LayoutEngine } from "../engine" ;
7
8
import { forEachTimes } from "./helpers" ;
8
9
@@ -31,10 +32,10 @@ test("commits no changes if resize path returns to original or smaller", () => {
31
32
if ( resize . path . length > 0 ) {
32
33
const lastPathItem = resize . path [ resize . path . length - 1 ] ;
33
34
const resizeTarget = grid . items . find ( ( it ) => it . id === resize . itemId ) ! ;
34
- const originalSizePath = {
35
+ const originalSizePath = new Position ( {
35
36
x : randomPathValue ( resizeTarget . x + resizeTarget . width ) ,
36
37
y : randomPathValue ( resizeTarget . y + resizeTarget . height ) ,
37
- } ;
38
+ } ) ;
38
39
resize . path = [ ...resize . path , ...generateRandomPath ( lastPathItem , originalSizePath ) ] ;
39
40
const moves = new LayoutEngine ( grid ) . resize ( resize ) . getLayoutShift ( ) . moves ;
40
41
expect ( moves . filter ( ( move ) => move . type !== "RESIZE" && move . type !== "FLOAT" ) ) . toHaveLength ( 0 ) ;
@@ -57,10 +58,7 @@ describe("resize scenarios", () => {
57
58
] ,
58
59
{
59
60
itemId : "A" ,
60
- path : [
61
- { x : 2 , y : 1 } ,
62
- { x : 2 , y : 2 } ,
63
- ] ,
61
+ path : [ new Position ( { x : 2 , y : 1 } ) , new Position ( { x : 2 , y : 2 } ) ] ,
64
62
} ,
65
63
[
66
64
[ "A" , "A" , "B" ] ,
@@ -77,10 +75,7 @@ describe("resize scenarios", () => {
77
75
] ,
78
76
{
79
77
itemId : "A" ,
80
- path : [
81
- { x : 1 , y : 2 } ,
82
- { x : 2 , y : 2 } ,
83
- ] ,
78
+ path : [ new Position ( { x : 1 , y : 2 } ) , new Position ( { x : 2 , y : 2 } ) ] ,
84
79
} ,
85
80
[
86
81
[ "A" , "A" , "B" ] ,
@@ -97,10 +92,7 @@ describe("resize scenarios", () => {
97
92
] ,
98
93
{
99
94
itemId : "A" ,
100
- path : [
101
- { x : 3 , y : 2 } ,
102
- { x : 3 , y : 1 } ,
103
- ] ,
95
+ path : [ new Position ( { x : 3 , y : 2 } ) , new Position ( { x : 3 , y : 1 } ) ] ,
104
96
} ,
105
97
[
106
98
[ "A" , "A" , "A" ] ,
@@ -118,10 +110,7 @@ describe("resize scenarios", () => {
118
110
] ,
119
111
{
120
112
itemId : "A" ,
121
- path : [
122
- { x : 3 , y : 2 } ,
123
- { x : 3 , y : 3 } ,
124
- ] ,
113
+ path : [ new Position ( { x : 3 , y : 2 } ) , new Position ( { x : 3 , y : 3 } ) ] ,
125
114
} ,
126
115
[
127
116
[ "A" , "A" , "A" ] ,
@@ -140,7 +129,7 @@ describe("resize scenarios", () => {
140
129
[ "C" , "D" , "D" , "E" ] ,
141
130
[ "C" , "F" , "F" , "F" ] ,
142
131
] ,
143
- { itemId : "B" , path : [ { x : 4 , y : 3 } ] } ,
132
+ { itemId : "B" , path : [ new Position ( { x : 4 , y : 3 } ) ] } ,
144
133
[
145
134
[ "A" , "A" , "A" , " " ] ,
146
135
[ "B" , "B" , "B" , "B" ] ,
@@ -159,10 +148,7 @@ describe("resize scenarios", () => {
159
148
] ,
160
149
{
161
150
itemId : "B" ,
162
- path : [
163
- { x : 4 , y : 3 } ,
164
- { x : 4 , y : 4 } ,
165
- ] ,
151
+ path : [ new Position ( { x : 4 , y : 3 } ) , new Position ( { x : 4 , y : 4 } ) ] ,
166
152
} ,
167
153
[
168
154
[ "A" , "A" , "A" , " " ] ,
@@ -183,10 +169,7 @@ describe("resize scenarios", () => {
183
169
] ,
184
170
{
185
171
itemId : "A" ,
186
- path : [
187
- { x : 3 , y : 2 } ,
188
- { x : 3 , y : 3 } ,
189
- ] ,
172
+ path : [ new Position ( { x : 3 , y : 2 } ) , new Position ( { x : 3 , y : 3 } ) ] ,
190
173
} ,
191
174
[
192
175
[ "A" , "A" , "A" , " " ] ,
@@ -207,7 +190,7 @@ describe("resize scenarios", () => {
207
190
] ,
208
191
{
209
192
itemId : "B" ,
210
- path : [ { x : 2 , y : 2 } ] ,
193
+ path : [ new Position ( { x : 2 , y : 2 } ) ] ,
211
194
} ,
212
195
[
213
196
[ "A" , "B" , "C" , "D" ] ,
0 commit comments