Skip to content

Instantly share code, notes, and snippets.

@simonsmith
Created May 27, 2016 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonsmith/47096f0407931cc5d6324d9fb9e9f83f to your computer and use it in GitHub Desktop.
Save simonsmith/47096f0407931cc5d6324d9fb9e9f83f to your computer and use it in GitHub Desktop.
const tape = require('tape');
const test = require('tape-css')(tape);
const h = require('hyperscript');
const getStyle = require('computed-style');
const $ = selector => document.querySelector(selector);
const styles = require('./my-component.css');
const dom = () => (
h('div.MyComponent',
h('div.MyComponent-header')
)
);
test('MyComponent test', {dom: dom(), styles}, t => {
t.test('MyComponent', t => {
const el = $('.MyComponent');
t.equal(
getStyle(el, 'margin'),
'0px',
'should not have a margin'
);
t.equal(
getStyle(el, 'background-color'),
'rgb(255, 255, 255)',
'should have a white background'
);
t.end();
});
t.test('MyComponent--important', t => {
const el = $('.MyComponent');
el.classList.add('MyComponent--important');
t.equal(
getStyle(el, 'border-color'),
'rgb(255, 0, 0)',
'should add a red border'
);
t.end();
});
t.test('MyComponent-header', t => {
const el = $('.MyComponent-header');
t.equal(
getStyle(el, 'font-size'),
'24px',
'should have a font size'
);
t.equal(
getStyle(el, 'font-weight'),
'bold',
'should be bold'
);
t.end();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment