fix tests and switch them to es6 syntax

This commit is contained in:
David Hemphill 2017-08-26 14:54:39 -05:00 committed by Adam Wathan
parent d2b2722b2e
commit 3ceba8ef52
4 changed files with 49 additions and 48 deletions

View File

@ -0,0 +1,38 @@
import postcss from 'postcss'
import fs from 'fs'
import _ from 'lodash'
import defineClass from '../src/util/defineClass'
let flexHelper = `.flex {
display: flex
}`
let inlineBlock = `.inline-block {
display: inline-block
}`
let inlineFlexHelper = `.inline-flex {
display: inline-flex
}`
let backgroundColor = `.bg-1 {
background-color: #bada55
}`
/**
* Tests
*/
it('creates a proper single-word class with rules', () => {
let output = defineClass('flex', {display: 'flex'})
expect(output.toString()).toEqual(flexHelper)
})
it('generates a rule with a kebab-case selector', () => {
let output = defineClass('inlineBlock', {display: 'inline-block'})
expect(output.toString()).toEqual(inlineBlock)
})
it('generates a rule with a kebab-case property name', () => {
let output = defineClass('bg-1', {backgroundColor: '#bada55'})
expect(output.toString()).toEqual(backgroundColor)
})

View File

@ -1,9 +1,9 @@
var postcss = require('postcss')
var fs = require('fs')
var _ = require('lodash')
var defineClasses = require('../src/util/defineClasses')
import postcss from 'postcss'
import fs from 'fs'
import _ from 'lodash'
import defineClasses from '../src/util/defineClasses'
var config = {
let config = {
flex: {
display: 'flex',
},
@ -12,19 +12,19 @@ var config = {
},
}
var flexHelper = `.flex {
display: flex
let flexHelper = `.flex {
display: flex
}`
var inlineFlexHelper = `.inline-flex {
display: inline-flex
let inlineFlexHelper = `.inline-flex {
display: inline-flex
}`
/**
* Tests
*/
it('it generates a set of helper classes from a config', () => {
output = defineClasses(config)
let output = defineClasses(config)
expect(output).toBeInstanceOf(Array)
expect(output[0].toString()).toEqual(flexHelper)
expect(output[1].toString()).toEqual(inlineFlexHelper)

View File

@ -18,6 +18,7 @@
"devDependencies": {
"babel-cli": "^6.6.5",
"babel-core": "^6.7.2",
"babel-jest": "^20.0.3",
"babel-loader": "^6.2.4",
"babel-preset-env": "^1.0.0",
"babel-preset-react": "^6.5.0",

View File

@ -1,38 +0,0 @@
var postcss = require('postcss')
var fs = require('fs')
var _ = require('lodash')
var defineClass = require('../src/util/defineClass')
var flexHelper = `.flex {
display: flex
}`
var inlineBlock = `.inline-block {
display: inline-block
}`
var inlineFlexHelper = `.inline-flex {
display: inline-flex
}`
var backgroundColor = `.bg-1 {
background-color: #bada55
}`
/**
* Tests
*/
it('creates a proper single-word class with rules', () => {
let output = defineClass('flex', { display: 'flex' })
expect(output.toString()).toEqual(flexHelper)
})
it('generates a rule with a kebab-case selector', () => {
let output = defineClass('inlineBlock', { display: 'inline-block' })
expect(output.toString()).toEqual(inlineBlock)
})
it('generates a rule with a kebab-case property name', () => {
let output = defineClass('bg-1', { backgroundColor: '#bada55' })
expect(output.toString()).toEqual(backgroundColor)
})