import {expect} from 'chai'
import {
  createAndMountComponent, destroyComponent, getElement, onGwtReady,
  onNextTick
} from '../../vue-gwt-tests-utils'

describe('Scoped styling', () => {
  let component;

  beforeEach(() => onGwtReady().then(() => {
    component = createAndMountComponent(
        'com.axellience.vuegwt.tests.client.components.style.scoped.ScopedTestComponent');
  }));

  afterEach(() => {
    destroyComponent(component);
  });

  it('check non-boiling label has proper styling', () => {
    component.celsius = '22';
    return onNextTick(() => {
      const element = getElement(component, '.relax');
      expect(element).to.exist;
	  const c = window.getComputedStyle(element, null).getPropertyValue('color');
      expect(c).to.equal('rgb(0, 128, 0)'); // green
      const b = window.getComputedStyle(element, null).getPropertyValue('border-radius');
	  expect(b).to.equal('8px'); // 0.5em
    });
  });

  it('check boiling label has proper styling', () => {
    component.celsius = '101';
    return onNextTick(() => {
      const element = getElement(component, '.attention');	  
	  expect(element).to.exist;
	  const c = window.getComputedStyle(element, null).getPropertyValue('color');
      expect(c).to.equal('rgb(255, 0, 0)'); // red
    });
  });
});

@@ -56,16 +56,18 @@
 mponent,
+%0A 
  destroy
@@ -76,16 +76,18 @@
 mponent,
+%0A 
  getElem
@@ -94,33 +94,33 @@
 ent,
- onGwtReady,
 %0A  
-onN
+n
 extTick
+,%0A  onGwtReady
 %0A%7D f
@@ -546,35 +546,33 @@
 %0A    return 
-onN
+n
 extTick(
 () =%3E %7B%0A    
@@ -551,32 +551,39 @@
 return nextTick(
+).then(
 () =%3E %7B%0A      co
@@ -653,33 +653,36 @@
 ment).to.exist;%0A
-%09
+    
   const c = wind
@@ -725,32 +725,43 @@
 etPropertyValue(
+%0A          
 'color');%0A      
@@ -879,16 +879,27 @@
 tyValue(
+%0A          
 'border-
@@ -908,17 +908,20 @@
 dius');%0A
-%09
+    
   expect
@@ -1066,19 +1066,17 @@
 urn 
-onN
+n
 extTick(
 () =
@@ -1071,16 +1071,23 @@
 extTick(
+).then(
 () =%3E %7B%0A
@@ -1148,13 +1148,13 @@
 n');
-%09  %0A%09
+%0A    
   ex
@@ -1181,9 +1181,12 @@
 st;%0A
-%09
+    
   co
@@ -1249,16 +1249,27 @@
 tyValue(
+%0A          
 'color')

update scoped style test to use the new nextTick method