//
// Keeps count of all instances with arguments, stores in global var
//
@include describe("[function] instance") {

    $pseudo-instance: (
    	".instance::desktop": (
    		"instance-count": 1,
    		"parent-selector": none,
    		"key": "desktop",
    		"breakpoint": 80em,
    		"columns": 16,
    		"span": 4,
    		"context": null,
    		"gutter": null,
    		"internal": (
                "width": 18.75em,
                "margin-right": 0.625em,
                "margin-left": 0.625em
            )
    	)
    );

    .instance {
        @include _("desktop", 4);

        @at-root {
            @include it("should expect instance map to match pseudo instance") {
                @include should(expect(inspect($flint-instances)), to(be(inspect($pseudo-instance))));
            }
        }

        $flint-instances: () !global;
        $flint-instance-count: 0 !global;

        $flint-instances: flint-instance("desktop", 4, null, null, 18.75em, 0.625em, 0.625em) !global;

        @at-root {
            @include it("should expect instance map to match pseudo instance") {
                @include should(expect(inspect($flint-instances)), to(be(inspect($pseudo-instance))));
            }
        }
    }

    $flint-instances: () !global;
    $flint-instance-count: 0 !global;

    $pseudo-instance: (
        ".parent-instance .child-instance::mobile": (
            "instance-count": 8,
            "parent-selector": ".parent-instance::mobile",
            "key": "mobile",
            "breakpoint": 20em,
            "columns": 4,
            "span": 2,
            "context": 4,
            "gutter": normal,
            "internal": (
                "width": 8.125em,
                "margin-right": 0.625em,
                "margin-left": 0.625em
            )
        ),
        ".parent-instance .child-instance::tablet": (
            "instance-count": 7,
            "parent-selector": ".parent-instance::tablet",
            "key": "tablet",
            "breakpoint": 40em,
            "columns": 8,
            "span": 2,
            "context": 4,
            "gutter": normal,
            "internal": (
                "width": 8.4375em,
                "margin-right": 0.625em,
                "margin-left": 0.625em
            )
        ),
        ".parent-instance .child-instance::laptop": (
            "instance-count": 6,
            "parent-selector": ".parent-instance::laptop",
            "key": "laptop",
            "breakpoint": 60em,
            "columns": 12,
            "span": 2,
            "context": 4,
            "gutter": inside,
            "internal": (
                "width": 7.1875em,
                "margin-right": 0.625em,
                "margin-left": 0.625em
            )
        ),
        ".parent-instance .child-instance::desktop": (
            "instance-count": 5,
            "parent-selector": ".parent-instance::desktop",
            "key": "desktop",
            "breakpoint": 80em,
            "columns": 16,
            "span": 2,
            "context": 4,
            "gutter": row,
            "internal": (
                "width": 9.375em,
                "margin-right": 0,
                "margin-left": 0
            )
        ),
        ".parent-instance::mobile": (
            "instance-count": 4,
            "parent-selector": none,
            "key": "mobile",
            "breakpoint": 20em,
            "columns": 4,
            "span": 4,
            "context": null,
            "gutter": center,
            "internal": (
                "width": 18.75em,
                "margin-right": auto,
                "margin-left": auto
            )
        ),
        ".parent-instance::tablet": (
            "instance-count": 3,
            "parent-selector": none,
            "key": "tablet",
            "breakpoint": 40em,
            "columns": 8,
            "span": 4,
            "context": null,
            "gutter": omega,
            "internal": (
                "width": 19.375em,
                "margin-right": 0,
                "margin-left": 0.625em
            )
        ),
        ".parent-instance::laptop": (
            "instance-count": 2,
            "parent-selector": none,
            "key": "laptop",
            "breakpoint": 60em,
            "columns": 12,
            "span": 4,
            "context": null,
            "gutter": alpha,
            "internal": (
                "width": 19.375em,
                "margin-right": 0.625em,
                "margin-left": 0
            )
        ),
        ".parent-instance::desktop": (
            "instance-count": 1,
            "parent-selector": none,
            "key": "desktop",
            "breakpoint": 80em,
            "columns": 16,
            "span": 4,
            "context": null,
            "gutter": normal,
            "internal": (
                "width": 18.75em,
                "margin-right": 0.625em,
                "margin-left": 0.625em
            )
        )
    );

    .parent-instance {
        @include _(4, $gutter: normal alpha omega center);

        .child-instance {
            @include _(2, "auto", $gutter: row inside normal normal);

            @at-root {
                @include it("should expect instance map to match pseudo instance map") {
                    @include should(expect(inspect($flint-instances)), to(be(inspect($pseudo-instance))));
                }
            }
        }
    }

    $flint-instances: () !global;
    $flint-instance-count: 0 !global;
}
