import chai from 'chai';
let assert = chai.assert;

import LabelPoint from '../src/styles/text/label_point';
import LabelOptions from '../src/styles/text/label_options';

let label;

describe('Labels', () => {

    describe('LabelPoint', () => {

        beforeEach(() => {
            let options = new LabelOptions({ units_per_pixel: 1 });
            let size = { text_size: [1000, 500] };
            let p = [2000, -1000];
            label = new LabelPoint('Test', p, size, options);
        });

        it('is in tile bounds', () => {
            assert.isTrue(label.inTileBounds());
        });

        describe('for tile edges', () => {

            let edges = [
                ['left', [450, -1000]],
                ['right', [4500, -1000]],
                ['top', [2000, 250]],
                ['bottom', [2000, -4100]]
            ];

            edges.forEach(([edge, p]) => {

                it(`is out of tile on ${edge} edge`, () => {
                    label.position = p;
                    label.update();
                    assert.isFalse(label.inTileBounds());
                });

                it(`can move back into tile for ${edge} edge`, () => {
                    label.position = p;
                    label.update();
                    let discarded = label.moveIntoTile();
                    assert.isFalse(discarded);
                    assert.isTrue(label.inTileBounds());
                });

            });

        });

    });

});


@@ -105,69 +105,8 @@
 nt';
-%0Aimport LabelOptions from '../src/styles/text/label_options';
 %0A%0Ale
@@ -210,76 +210,8 @@
 %3E %7B%0A
-            let options = new LabelOptions(%7B units_per_pixel: 1 %7D);%0A
     
@@ -348,15 +348,122 @@
 ze, 
-options
+%7B%0A                units_per_pixel: 1,%0A                offset: %5B0, 0%5D,%0A                buffer: %5B0, 0%5D%0A            %7D
 );%0A 

remove LabelOptions reference