Newer
Older
pixi.js / packages / text / test / TextStyle.js
@Matt Karl Matt Karl on 31 Oct 2017 1 KB Next Restructure for v5 (#4387)
const { TextStyle } = require('../');

describe('PIXI.TextStyle', function ()
{
    it('reset reverts style to default', function ()
    {
        const textStyle = new TextStyle();
        const defaultFontSize = textStyle.fontSize;

        textStyle.fontSize = 1000;

        expect(textStyle.fontSize).to.equal(1000);
        textStyle.reset();
        expect(textStyle.fontSize).to.equal(defaultFontSize);
    });

    it('should clone correctly', function ()
    {
        const textStyle = new TextStyle({ fontSize: 1000 });

        const clonedTextStyle = textStyle.clone();

        expect(textStyle.fontSize).to.equal(1000);
        expect(clonedTextStyle.fontSize).to.equal(textStyle.fontSize);
    });

    it('should assume pixel fonts', function ()
    {
        const style = new TextStyle({ fontSize: 72 });
        const font = style.toFontString();

        expect(font).to.be.a.string;
        expect(font).to.have.string(' 72px ');
    });

    it('should handle multiple fonts as array', function ()
    {
        const style = new TextStyle({
            fontFamily: ['Georgia', 'Arial', 'sans-serif'],
        });

        expect(style.toFontString()).to.have.string('"Georgia","Arial","sans-serif"');
    });

    it('should handle multiple fonts as string', function ()
    {
        const style = new TextStyle({
            fontFamily: 'Georgia, "Arial", sans-serif',
        });

        expect(style.toFontString()).to.have.string('"Georgia","Arial","sans-serif"');
    });
});