Skip to content

Board dimensions not respected when parsing vbml #32

@natekspencer

Description

@natekspencer

The following tests request a board that should be created with a height of 22 and a width of 6 (inverted flagship height/width), but the expected result passes with a width of 22, meaning the board style isn't actually enforced in underlying code.

it("Should layout absolute components by relative components", () => {
const result = vbml.parse({
style: {
height: 22,
width: 6,
},
components: [
{
template: "abc",
style: {
height: 6,
width: 22,
align: Align.top,
justify: Justify.left,
},
},
{
template: "def",
style: {
height: 1,
width: 3,
align: Align.top,
justify: Justify.left,
absolutePosition: {
x: 3,
y: 0,
},
},
},
],
});
expect(result[0]).toEqual([
1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]);
});
it("Should layout absolute components over relative components", () => {
const result = vbml.parse({
style: {
height: 22,
width: 6,
},
components: [
{
template: "abc",
style: {
height: 6,
width: 22,
align: Align.top,
justify: Justify.left,
},
},
{
template: "def",
style: {
height: 1,
width: 3,
align: Align.top,
justify: Justify.left,
absolutePosition: {
x: 0,
y: 0,
},
},
},
],
});
expect(result[0]).toEqual([
4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]);
});

The python and php code have similar tests, but the board dimensions are respected. However, the php test fails as it is using the same expected result the TS/JS test used.

public function testShouldLayoutAbsoluteByRelative(): void
{
$result = Vbml::parse([
'style' => ['height' => 22, 'width' => 6],
'components' => [
['template' => 'abc', 'style' => ['height' => 6, 'width' => 22, 'align' => 'top', 'justify' => 'left']],
['template' => 'def', 'style' => ['height' => 1, 'width' => 3, 'align' => 'top', 'justify' => 'left', 'absolutePosition' => ['x' => 3, 'y' => 0]]],
],
]);
$expected = [1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
$this->assertEquals($expected, $result[0]);
}
public function testShouldLayoutAbsoluteOverRelative(): void
{
$result = Vbml::parse([
'style' => ['height' => 22, 'width' => 6],
'components' => [
['template' => 'abc', 'style' => ['height' => 6, 'width' => 22, 'align' => 'top', 'justify' => 'left']],
['template' => 'def', 'style' => ['height' => 1, 'width' => 3, 'align' => 'top', 'justify' => 'left', 'absolutePosition' => ['x' => 0, 'y' => 0]]],
],
]);
$expected = [4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
$this->assertEquals($expected, $result[0]);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions