Skip to content

Commit

Permalink
chore(readme): add testing instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
morrislaptop committed Jun 7, 2018
1 parent 368e0f2 commit 95b6f1c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@ See [#1](https://github.com/morrislaptop/tailwind-zeplin-extension/issues/1) for
Tailwind Zeplin Extension is developed using [zem](https://github.com/zeplin/zem), Zeplin Extension Manager. zem is a command line tool that lets you quickly create and test extensions.

To learn more about zem, [see documentation](https://github.com/zeplin/zem).

To run tests and show skipped - `yarn test --verbose --expand`
8 changes: 4 additions & 4 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function borderRadiusToClass(tailwind, radius) {

if (size === 'none') return null

return 'rounded-' + size
return size === 'default' ? 'rounded' : 'rounded-' + size
}

function opacityToClass(tailwind, opacity) {
Expand Down Expand Up @@ -99,9 +99,9 @@ function borderClass(tailwind, borders) {
let sizes = dropTheRem(tailwind.borderWidths)
let key = closestKey(sizes, border.thickness)

if (key === 'default') return null
if (key === '0') return null

return 'border-' + key
return key === 'default' ? 'border' : 'border-' + key
}

function borderColor(context, tailwind, borders) {
Expand Down Expand Up @@ -291,7 +291,7 @@ function lineHeightToClass(tailwind, size, height) {
function textAlignToClass(align) {
if (! align || align === 'left') return null

return 'font-' + align
return 'text-' + align
}

function letterSpacingToClass(tailwind, size, spacing) {
Expand Down
12 changes: 9 additions & 3 deletions test/layer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ let tests = {
let css = ext.layer(context, layer)

expect(css.code).toBe(`<p class="text-xl font-medium">Type</p>
<p class="text-xl text-green">something</p>
<p class="sample-text-style-with-color uppercase">RED</p>`)
<p class="text-xl text-center text-green">something</p>
<p class="text-xl text-right text-red uppercase">RED</p>`)
},

TextLayerWithMultipleStylesThatAreTheSame(context, layer) {
Expand All @@ -48,12 +48,18 @@ let tests = {
expect(css.code).toBe(`<div class="bg-yellow max-w-xs"></div>`)
},

LayerWithBorderRadius(context, layer) {
LayerWithLargeBorderRadius(context, layer) {
let css = ext.layer(context, layer)

expect(css.code).toBe(`<div class="rounded-lg bg-red max-w-xs"></div>`)
},

LayerWithDefaultBorderRadius(context, layer) {
let css = ext.layer(context, layer)

expect(css.code).toBe(`<div class="rounded bg-red max-w-xs"></div>`)
},

RotatedLayer(context, layer) {
let css = ext.layer(context, layer)

Expand Down
44 changes: 41 additions & 3 deletions test/sample-data/layers.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"fontStyle": "normal",
"fontFamily": "SFProText",
"fontStretch": "normal",
"textAlign": "left",
"textAlign": "center",
"weightText": "regular",
"color": {
"r": 0,
Expand All @@ -93,7 +93,7 @@
"fontStyle": "normal",
"fontFamily": "SFProText",
"fontStretch": "normal",
"textAlign": "left",
"textAlign": "right",
"weightText": "regular",
"color": {
"r": 255,
Expand Down Expand Up @@ -320,7 +320,7 @@
},
{
"type": "shape",
"name": "Layer with border radius",
"name": "Layer with large border radius",
"exportable": false,
"rotation": 0,
"opacity": 1,
Expand Down Expand Up @@ -356,6 +356,44 @@
"textStyles": [],
"assets": []
},
{
"type": "shape",
"name": "Layer with default border radius",
"exportable": false,
"rotation": 0,
"opacity": 1,
"blendMode": "normal",
"borderRadius": 4,
"rect": {
"y": 410,
"x": 50,
"width": 100,
"height": 100
},
"content": "",
"borders": [],
"fills": [
{
"type": "color",
"blendMode": "normal",
"fill": {
"r": 255,
"g": 0,
"b": 0,
"a": 1
},
"color": {
"r": 255,
"g": 0,
"b": 0,
"a": 1
}
}
],
"shadows": [],
"textStyles": [],
"assets": []
},
{
"type": "shape",
"name": "Rotated layer",
Expand Down

0 comments on commit 95b6f1c

Please sign in to comment.