import test from 'tape';
import vcharts from '../src';

test('chart - basic - width and height should be based on el properties', t => {
  t.plan(2);

  const padding = {
    top: 10,
    left: 20,
    bottom: 30,
    right: 40
  };

  vcharts.templates.test = {
    width: ['@get', 'width', 100],
    height: ['@get', 'height', 200],
    padding: padding
  };

  let c = vcharts.chart('test', {
    el: {offsetWidth: 0, offsetHeight: 0}
  });

  t.deepEqual({
    width: 100,
    height: 200,
    padding: padding
  }, c.spec);

  c = vcharts.chart('test', {
    el: {offsetWidth: 300, offsetHeight: 400}
  });

  t.deepEqual({
    width: (300 - 20 - 40),
    height: (400 - 10 - 30),
    padding: padding
  }, c.spec);

  t.end();
});

test('vega - should produce vega spec', t => {
  let c = vcharts.chart('vega', {
    el: document.createElement('div'),
    spec: {marks: []}
  });

  t.deepEqual(vcharts.templates.vega, c.template);
  t.deepEqual({marks: []}, c.spec);

  t.end();
});

test('update - should update options', function () {
  var c = vcharts.chart('vega', {
    el: document.createElement('div')
    spec: {marks: [1]}
  });

  assert.deepEqual(vcharts.templates.vega, c.template);
  assert.deepEqual({el: {}, spec: {marks: [1]}}, c.options);

  c.update({spec: {marks: [1, 2, 3]}});

  assert.deepEqual({el: {}, spec: {marks: [1, 2, 3]}}, c.options);
});

@@ -64,18 +64,8 @@
 hart
- - basic -
  wid
@@ -434,32 +434,40 @@
 %0A%0A  t.deepEqual(
+c.spec, 
 %7B%0A    width: 100
@@ -505,32 +505,24 @@
  padding%0A  %7D
-, c.spec
 );%0A%0A  c = vc
@@ -610,16 +610,24 @@
 epEqual(
+c.spec, 
 %7B%0A    wi
@@ -701,24 +701,16 @@
 ding%0A  %7D
-, c.spec
 );%0A%0A  t.
@@ -732,13 +732,22 @@
 t('v
-ega -
+charts.chart()
  sho
@@ -885,32 +885,44 @@
 %0A%0A  t.deepEqual(
+c.template, 
 vcharts.template
@@ -923,36 +923,24 @@
 mplates.vega
-, c.template
 );%0A  t.deepE
@@ -944,16 +944,24 @@
 epEqual(
+c.spec, 
 %7Bmarks: 
@@ -967,16 +967,8 @@
  %5B%5D%7D
-, c.spec
 );%0A%0A
@@ -1026,19 +1026,12 @@
 s', 
-function ()
+t =%3E
  %7B%0A 
@@ -1100,16 +1100,17 @@
 t('div')
+,
 %0A    spe
@@ -1130,29 +1130,24 @@
 %5D%7D%0A  %7D);%0A%0A  
-asser
 t.deepEqual(
@@ -1146,16 +1146,28 @@
 epEqual(
+c.template, 
 vcharts.
@@ -1184,30 +1184,13 @@
 vega
-, c.template);%0A  asser
+);%0A  
 t.de
@@ -1193,38 +1193,39 @@
 t.deepEqual(
-%7Bel: %7B%7D, 
+c.options.
 spec
-:
+,
  %7Bmarks: %5B1%5D
@@ -1225,28 +1225,16 @@
 ks: %5B1%5D%7D
-%7D, c.options
 );%0A%0A  c.
@@ -1276,13 +1276,8 @@
 %0A%0A  
-asser
 t.de
@@ -1288,22 +1288,23 @@
 ual(
-%7Bel: %7B%7D, 
+c.options.
 spec
-:
+,
  %7Bma
@@ -1322,20 +1322,20 @@
  3%5D%7D
-%7D, c.options
+);%0A%0A  t.end(
 );%0A%7D

Make tests conform better to tape style