diff --git a/tests/tween/tween.test.ts b/tests/tween/tween.test.ts index a1c457e619a..6bf67c57aed 100644 --- a/tests/tween/tween.test.ts +++ b/tests/tween/tween.test.ts @@ -45,98 +45,127 @@ test('destroySelf', function () { test('type color', function () { const shadow = new Shadows(); - const tweenact = tween(shadow).to(1, {shadowColor: Color.TRANSPARENT}); + shadow.shadowColor.set(200, 100, 50, 250); + const target = Color.TRANSPARENT; + const tweenact = tween(shadow).to(1, {shadowColor: target}); tweenact.start(); + // @ts-expect-error access private property const action = tweenact._actions[0] as TweenAction; + action.update(1.0); // @ts-expect-error access private property const props = action._props; for (const property in props) { const prop = props[property]; expect(prop.current instanceof Color).toBeTruthy(); + expect(Color.equals(prop.current, target)).toBeTruthy(); } }); test('type quat', function () { const node = new Node(); - const tweenact = tween(node).to(1, {rotation: new Quat(1, 1, 1, 1)}); + const target = new Quat(1, 1, 1, 1); + const tweenact = tween(node).to(1, {rotation: target}); tweenact.start(); + // @ts-expect-error access private property const action = tweenact._actions[0] as TweenAction; + action.update(1.0); // @ts-expect-error access private property const props = action._props; for (const property in props) { const prop = props[property]; expect(prop.current instanceof Quat).toBeTruthy(); + expect(Quat.equals(prop.current, target)).toBeTruthy(); } }); test('type rect', function () { const camera = new CameraComponent(); - const tweenact = tween(camera).to(1, {rect: new Rect(1, 1, 10, 20)}); + const target = new Rect(1, 1, 10, 20); + const tweenact = tween(camera).to(1, {rect: target}); tweenact.start(); + // @ts-expect-error access private property const action = tweenact._actions[0] as TweenAction; + action.update(1.0); // @ts-expect-error access private property const props = action._props; for (const property in props) { const prop = props[property]; expect(prop.current instanceof Rect).toBeTruthy(); + expect(Rect.equals(prop.current, target)).toBeTruthy(); } }); test('type size', function () { const rect = new Rect(); - const tweenact = tween(rect).to(1, {size: new Size(800, 600)}); + const target = new Size(800, 600); + const tweenact = tween(rect).to(1, {size: target}); tweenact.start(); + // @ts-expect-error access private property const action = tweenact._actions[0] as TweenAction; + action.update(1.0); // @ts-expect-error access private property const props = action._props; for (const property in props) { const prop = props[property]; expect(prop.current instanceof Size).toBeTruthy(); + expect(Rect.equals(prop.current, target)).toBeTruthy(); } }); test('type vec2', function () { const rect = new Rect(); - const tweenact = tween(rect).to(1, {origin: new Vec2(20, 10)}); + const target = new Vec2(20, 10); + const tweenact = tween(rect).to(1, {origin: target}); tweenact.start(); + // @ts-expect-error access private property const action = tweenact._actions[0] as TweenAction; + action.update(1.0); // @ts-expect-error access private property const props = action._props; for (const property in props) { const prop = props[property]; expect(prop.current instanceof Vec2).toBeTruthy(); + expect(Vec2.equals(prop.current, target)).toBeTruthy(); } }); test('type vec3', function () { const node = new Node(); - const tweenact = tween(node).to(1, {position: new Vec3(10, 20, 30)}); + const target = new Vec3(10, 20, 30); + const tweenact = tween(node).to(1, {position: target}); tweenact.start(); + // @ts-expect-error access private property const action = tweenact._actions[0] as TweenAction; + action.update(1.0); // @ts-expect-error access private property const props = action._props; for (const property in props) { const prop = props[property]; expect(prop.current instanceof Vec3).toBeTruthy(); - } + expect(Vec3.equals(prop.current, target)).toBeTruthy(); + } }); test('type vec4', function () { const shadowLayer = new CSMShadowLayer(4); - const tweenact = tween(shadowLayer).to(1, {csmAtlas: new Vec4(10, 20, 30, 40)}); + const target = new Vec4(10, 20, 30, 40); + const tweenact = tween(shadowLayer).to(1, {csmAtlas: target}); tweenact.start(); + // @ts-expect-error access private property const action = tweenact._actions[0] as TweenAction; + action.update(1.0); // @ts-expect-error access private property const props = action._props; for (const property in props) { const prop = props[property]; expect(prop.current instanceof Vec4).toBeTruthy(); + expect(Vec4.equals(prop.current, target)).toBeTruthy(); } }); \ No newline at end of file