How to use the karma/case.constant.js.waitForUpdateTime function in karma

To help you get started, we’ve selected a few karma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github c-zhuo / easycanvas / test / cases / feature.add.js View on Github external
it('Default value correctly.', function (done) {
        setTimeout(() => {
            let children = $Painter.children;
            expect(children.length).toBe(1);
            expect(children[0].style.left).toBe(0);
            expect(children[0].style.top).toBe(77);
            expect(children[0].style.opacity).toBe(1);
            expect(children[0].style.rotate).toBe(undefined);
            expect(children[0].style.zIndex).toBe(0);
            expect(children[0].events.eIndex).toBe(undefined);
            // expect(children[0].inherit.indexOf('tx') >= 0).toBe(true);
            expect(children[0].content.img.width).toBe(10);
            done();
        }, constants.waitForUpdateTime);
    });
github c-zhuo / easycanvas / test / cases / feature.perf-jumpRenderOfCoveredSprite.js View on Github external
});
            }

            // 校验每组元素,真正绘制了几个
            var jumps = [];
            [1,2,3,4,5].forEach((n) => {
                jumps.push(sprites['type' + n].filter((bool) => {
                    return bool;
                }).length);
            });

            // 加载慢的话会报5个0
            expect(jumps.join(',')).toBe('0,4,7,0,0');

            done();
        }, constants.waitForUpdateTime + 100);
    });
});
github c-zhuo / easycanvas / test / cases / feature.sequence.jsx View on Github external
// 'createEvent' not working as expected
            // var evt = document.createEvent('MouseEvents');
            // evt.initMouseEvent('click', true, true, window, 1, 0, 0, 222, 222, false, false, false, false, 0, null);
            // $Painter.$dom.dispatchEvent(evt);

            // 这个case有时候是0,有时候$children是undefined
            // 可能是图片还没加载完,报错了重新跑试试(按理说本地图片不会这么慢?)
            expect($Painter.$children.length).toBe(1);

            expect($Painter.$children[0].type).toBe('img');
            expect($Painter.$children[0].props.cutWidth).toBe(Math.round(Fire.width / 9));
            expect($Painter.$children[0].props.cutHeight).toBe(Math.round(Fire.height));
            expect($Painter.$children[0].props.left).toBe(Math.round(posX - Fire.width / 9 / 2));
            expect($Painter.$children[0].props.top).toBe(Math.round(posY - Fire.height / 2));
            done();
        }, constants.waitForUpdateTime * 2);
    });
});
github c-zhuo / easycanvas / test / cases / feature.scale.js View on Github external
expect(getRenderTStyle($Painter.$children[1].props)).toBe('540,40,150,150');

            // tx/ty 100~130  ==>  85~145
            expect(getRenderTStyle($Painter.$children[2].props)).toBe('-35,65,300,300');
            // render逻辑调整,
            // expect(getRenderTStyle($Painter.$children[2].props)).toBe('0,65,265,300');

            // 如果没有scale,结果为'140,140,150,150',中心(215,215)
            // scale 5 ==> size 750, 215 - 375 = -160
            // 结果 -160,-160,750,750 ==> 0,0,590,590
            expect(getRenderStyle($Painter.$children[3].props)).toBe('0,0,30,30,540,540,150,150');
            expect(getRenderStyle($Painter.$children[4].props)).toBe('0,0,30,30,-160,-160,750,750');
            // render逻辑调整,
            // expect(getRenderStyle($Painter.$children[4].props)).toBe('6.4,6.4,23.6,23.6,0,0,590,590');
            done();
        }, constants.waitForUpdateTime);
    });
});
github c-zhuo / easycanvas / test / cases / feature.load-img.js View on Github external
it('All images loaded correctly.', function (done) {
        setTimeout(() => {
            expect($Painter.$children.length).toBe(3);
            expect($Painter.$children[0].type).toBe('img');
            expect($Painter.$children[1].type).toBe('img');
            expect($Painter.$children[2].type).toBe('img');
            expect($sp1.getImage().tagName).toBe('CANVAS');
            expect($sp2.content.img.tagName).toBe('CANVAS');
            expect($sp3.content.img.tagName).toBe('IMG');
            done();
        }, constants.waitForUpdateTime);
    });
});
github c-zhuo / easycanvas / test / cases / feature.add.js View on Github external
it('Children to $children fine.', function (done) {
        setTimeout(() => {
            let $children = $Painter.$children
            expect($children.length).toBe(1);
            expect($children[0].type).toBe('img');
            expect($children[0].props.img.tagName).toBe('IMG');
            expect($children[0].props.img.width).toBe(10);
            expect($children[0].props.width).toBe(10);
            expect($children[0].props.left).toBe(0);
            expect($children[0].props.top).toBe(77);
            done();
        }, constants.waitForUpdateTime);
    });
github c-zhuo / easycanvas / test / cases / feature.rendering.js View on Github external
props.left, props.top, props.width, props.height,
            ].join(',');
        };

        setTimeout(() => {
            $Painter.$children.forEach((i) => {
                console.log(i.$origin.name);
            });
            expect($Painter.$children.length).toBe(6);
            expect($Painter.$children[1].type).toBe('img');
            expect(getRenderStyle($Painter.$children[1].props)).toBe('0,0,30,30,100,100,30,30');
            expect($Painter.$children[3].settings.rotate).toBe(undefined);
            expect($Painter.$children[2].settings.rotate).toBe(undefined);
            expect(getRenderStyle($Painter.$children[3].props)).toBe('0,0,30,30,40,540,150,150');
            done();
        }, constants.waitForUpdateTime);
    });
});
github c-zhuo / easycanvas / test / cases / feature.hooks.js View on Github external
it('Hooks works correctly.', function (done) {
        sprite1.broadcast('custom', 75);
        $Painter.broadcast('fromRoot');
        $Painter.trigger('fromSelf');

        setTimeout(() => {
            expect($Painter.$children.length).toBe(2);
            expect(sprite3.style.opacity).toBe(0.3);
            expect(sprite2.style.top).toBe(75);
            expect(sprite3.style.top).toBe(0);
            expect(sprite2.style.left > 2).toBe(true);
            expect(sprite3.style.zIndex).toBe(0);
            expect(sprite2.style.zIndex).toBe(-30);
            done();
        }, constants.waitForUpdateTime);
    });
});
github c-zhuo / easycanvas / test / cases / feature.perf-jumpRenderOfOutside.js View on Github external
expect(shouldBeJumpedButPrinted.length).toBe(0);
            if (shouldBeJumpedButPrinted.length) {
                console.error(shouldBeJumpedButPrinted.map(($sprite) => {
                    return $sprite.name;
                }));
            }

            expect(shouldBePrintedButJumped.length).toBe(0);
            if (shouldBePrintedButJumped.length) {
                console.error(shouldBePrintedButJumped.map(($sprite) => {
                    return $sprite.name;
                }));
            }

            done();
        }, constants.waitForUpdateTime + 100);
    });
});