From 8ebd84f792d38623bb76c6c2d8a47ee1b7496547 Mon Sep 17 00:00:00 2001 From: Tuomas Jaakola Date: Mon, 21 Oct 2019 10:57:20 +0300 Subject: [PATCH] test case for css support --- __tests__/__snapshots__/css.test.tsx.snap | 311 ++++++++++++++++++++++ __tests__/css.test.tsx | 49 ++++ babel.config.js | 3 + package.json | 8 +- 4 files changed, 370 insertions(+), 1 deletion(-) create mode 100644 __tests__/__snapshots__/css.test.tsx.snap create mode 100644 __tests__/css.test.tsx create mode 100644 babel.config.js diff --git a/__tests__/__snapshots__/css.test.tsx.snap b/__tests__/__snapshots__/css.test.tsx.snap new file mode 100644 index 00000000..a322c24e --- /dev/null +++ b/__tests__/__snapshots__/css.test.tsx.snap @@ -0,0 +1,311 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`supports CSS in style element 1`] = ` + + + + + + + + + + + + +" + xmlns="http://www.w3.org/2000/svg" +> + + + + + + + + + + +`; diff --git a/__tests__/css.test.tsx b/__tests__/css.test.tsx new file mode 100644 index 00000000..168b829d --- /dev/null +++ b/__tests__/css.test.tsx @@ -0,0 +1,49 @@ +import React from 'react'; +import renderer from 'react-test-renderer'; +import { SvgCss, SvgCssUri, inlineStyles } from '../src/css'; + +test('supports CSS in style element', () => { + const xml = ` + + + + + + + + + + + +`; + + const tree = renderer.create().toJSON(); + expect(tree).toMatchSnapshot(); +}); diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 00000000..f842b77f --- /dev/null +++ b/babel.config.js @@ -0,0 +1,3 @@ +module.exports = { + presets: ['module:metro-react-native-babel-preset'], +}; diff --git a/package.json b/package.json index 86102087..95de382d 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "format": "prettier README.md './src/**/*.{ts,tsx}' src/index.d.ts --write", "peg": "pegjs -o src/lib/extract/transform.js ./src/lib/extract/transform.peg", "tsc": "tsc --noEmit", - "test": "npm run lint && npm run tsc && npm run flow", + "test": "npm run lint && npm run tsc && npm run flow && jest", "prepare": "npm run flowgen && npm run bob", "semantic-release": "semantic-release" }, @@ -63,6 +63,7 @@ "@types/react": "^16.9.5", "@types/react-native": "^0.60.19", "babel-eslint": "^10.0.3", + "babel-jest": "^24.9.0", "eslint": "^6.5.1", "eslint-plugin-flowtype": "^4.3.0", "eslint-plugin-prettier": "^3.1.1", @@ -70,14 +71,19 @@ "flow-bin": "^0.109.0", "flow-typed": "^2.6.1", "flowgen": "^1.10.0", + "jest": "^24.9.0", "pegjs": "^0.10.0", "prettier": "^1.18.2", "react": "^16.10.2", "react-native": "^0.61.2", + "react-test-renderer": "^16.10.2", "semantic-release": "^15.13.24", "semantic-release-cli": "^5.2.1", "typescript": "^3.6.3" }, + "jest": { + "preset": "react-native" + }, "release": { "plugins": [ "@semantic-release/commit-analyzer",