From 95b6f1c02f54a533eeba7a1cdd6796ebb142228d Mon Sep 17 00:00:00 2001 From: Craig Morris Date: Thu, 7 Jun 2018 09:09:55 +0100 Subject: [PATCH] chore(readme): add testing instructions --- README.md | 2 ++ src/lib.js | 8 +++---- test/layer.test.js | 12 +++++++--- test/sample-data/layers.json | 44 +++++++++++++++++++++++++++++++++--- 4 files changed, 56 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 021655b..005f811 100644 --- a/README.md +++ b/README.md @@ -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` \ No newline at end of file diff --git a/src/lib.js b/src/lib.js index 4a42e86..b6f8107 100644 --- a/src/lib.js +++ b/src/lib.js @@ -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) { @@ -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) { @@ -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) { diff --git a/test/layer.test.js b/test/layer.test.js index d187aaf..648b087 100644 --- a/test/layer.test.js +++ b/test/layer.test.js @@ -20,8 +20,8 @@ let tests = { let css = ext.layer(context, layer) expect(css.code).toBe(`

Type

-

something

-

RED

`) +

something

+

RED

`) }, TextLayerWithMultipleStylesThatAreTheSame(context, layer) { @@ -48,12 +48,18 @@ let tests = { expect(css.code).toBe(`
`) }, - LayerWithBorderRadius(context, layer) { + LayerWithLargeBorderRadius(context, layer) { let css = ext.layer(context, layer) expect(css.code).toBe(`
`) }, + LayerWithDefaultBorderRadius(context, layer) { + let css = ext.layer(context, layer) + + expect(css.code).toBe(`
`) + }, + RotatedLayer(context, layer) { let css = ext.layer(context, layer) diff --git a/test/sample-data/layers.json b/test/sample-data/layers.json index f9faf26..903ef52 100644 --- a/test/sample-data/layers.json +++ b/test/sample-data/layers.json @@ -71,7 +71,7 @@ "fontStyle": "normal", "fontFamily": "SFProText", "fontStretch": "normal", - "textAlign": "left", + "textAlign": "center", "weightText": "regular", "color": { "r": 0, @@ -93,7 +93,7 @@ "fontStyle": "normal", "fontFamily": "SFProText", "fontStretch": "normal", - "textAlign": "left", + "textAlign": "right", "weightText": "regular", "color": { "r": 255, @@ -320,7 +320,7 @@ }, { "type": "shape", - "name": "Layer with border radius", + "name": "Layer with large border radius", "exportable": false, "rotation": 0, "opacity": 1, @@ -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",