From 5356b2423a08a6b2685978187c7649e584a98d2b Mon Sep 17 00:00:00 2001 From: robmadole Date: Thu, 6 Feb 2020 09:23:06 -0600 Subject: [PATCH] Release 0.2.1 --- CHANGELOG.md | 6 +++++ dist/converter.js | 4 ++-- package.json | 5 ++-- .../__tests__/FontAwesomeIcon.test.js | 24 ++++++++++--------- src/converter.js | 6 ++--- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22376a5..e104959 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p --- +## [0.2.1](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.2.1) - 2020-02-06 + +### Fixed + +- Convert 'focusable' attribute to boolean from string #42 + ## [0.2.0](https://github.com/FortAwesome/react-native-fontawesome/releases/tag/0.2.0) - 2019-12-13 ### Added diff --git a/dist/converter.js b/dist/converter.js index 756354f..5712559 100644 --- a/dist/converter.js +++ b/dist/converter.js @@ -56,8 +56,8 @@ function convert(createElement, element) { delete element.attributes[key]; break; - case "focusable": - acc.attrs[key] = Boolean(val); + case 'focusable': + acc.attrs[key] = val === 'true' ? true : false; break; default: diff --git a/package.json b/package.json index 1b37033..fb2624e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fortawesome/react-native-fontawesome", - "version": "0.2.0", + "version": "0.2.1", "description": "Official React Native component for Font Awesome 5", "main": "index.js", "scripts": { @@ -18,7 +18,8 @@ "Travis Chase ", "Rob Madole ", "Mike Wilkerson ", - "Dizy " + "Dizy ", + "David Martin " ], "license": "MIT", "peerDependencies": { diff --git a/src/components/__tests__/FontAwesomeIcon.test.js b/src/components/__tests__/FontAwesomeIcon.test.js index 8560fa7..6f9c771 100644 --- a/src/components/__tests__/FontAwesomeIcon.test.js +++ b/src/components/__tests__/FontAwesomeIcon.test.js @@ -5,6 +5,8 @@ import renderer from 'react-test-renderer' import { StyleSheet } from 'react-native' import { find } from 'lodash' +jest.spyOn(React, 'createElement') + const faCoffee = { prefix: 'fas', iconName: 'coffee', @@ -189,16 +191,16 @@ describe('when extra props are given', () => { }) describe("convert focusable attribute", () => { - test("from false string to boolean", () => { - const tree = renderer - .create() - .toJSON(); - expect(tree.props.focusable).toEqual(false); - }); - test("from true string to boolean", () => { + test("no title leads to focusable false", () => { const tree = renderer - .create() - .toJSON(); - expect(tree.props.focusable).toEqual(true); - }); + .create() + .toJSON() + + React.createElement.mock.calls + .map(([_c, attrs, _children]) => attrs) + .filter((attrs) => 'focusable' in attrs) + .forEach(({ focusable }) => { + expect(focusable).toEqual(false) + }) + }) }); diff --git a/src/converter.js b/src/converter.js index f928a0b..ab791c2 100644 --- a/src/converter.js +++ b/src/converter.js @@ -25,15 +25,15 @@ function convert(createElement, element, extraProps = {}) { const mixins = Object.keys(element.attributes || {}).reduce( (acc, key) => { const val = element.attributes[key] - switch(key){ + switch (key) { case 'class': case 'role': case 'style': case 'xmlns': delete element.attributes[key] break - case "focusable": - acc.attrs[key] = Boolean(val); + case 'focusable': + acc.attrs[key] = (val === 'true') ? true : false break default: if (key.indexOf('aria-') === 0 || key.indexOf('data-') === 0 || ( 'fill' === key && 'currentColor' === val )) {