This repository was archived by the owner on Jun 3, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 143
Unit tests with Jest + Enzyme and updates to Tabs component #315
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b98f36b
Setup jest
valentijnnieman 15c6813
Setup babel-test plugin and Tabs unit tests
valentijnnieman 72ad1c3
Rebuild components with Tabs changes
valentijnnieman 8ef4a64
Formatted .circleci config and added Jest step
valentijnnieman 9d74498
Refactored Tabs
valentijnnieman 4368653
Add child.props logic back in
valentijnnieman e7272a9
Better children prop validation and fix integration tests
valentijnnieman 0da5ff8
Reformatted Tabs.react.js
valentijnnieman 518b7c8
Update styled-jsx so it includes babel-test plugin
valentijnnieman e933923
Rewrite child props logic again
valentijnnieman 6e9af8d
Reformat Tabs.react.js part 2
valentijnnieman 2a72658
Remove debugging statements
valentijnnieman e0d21c2
Children props logic update
valentijnnieman f4b4aeb
Remove debugging statements part 999
valentijnnieman 962c96f
Don't break if no children are set on Tabs
valentijnnieman 5a567cd
Remove children from Tabs in integration_test
valentijnnieman 15b40d6
Only use state if setProps isn't defined, check if imcoming props are…
valentijnnieman fa9f711
pin urllib3 to <=1.22 a la #333
valentijnnieman 7116f65
Bump version and change some comments
valentijnnieman 390a499
Merge branch 'master' of https://github.com/plotly/dash-core-componen…
valentijnnieman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
{ | ||
"presets": ["env", "react"], | ||
"plugins": ["transform-object-rest-spread", "styled-jsx/babel"] | ||
} | ||
"env": { | ||
"production": { | ||
"plugins": ["transform-object-rest-spread", "styled-jsx/babel"] | ||
}, | ||
"development": { | ||
"plugins": ["transform-object-rest-spread", "styled-jsx/babel"] | ||
}, | ||
"test": { | ||
"plugins": ["transform-object-rest-spread", "styled-jsx/babel-test"] | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,84 @@ | ||
version: 2 | ||
|
||
jobs: | ||
"python-2.7": &test-template | ||
docker: | ||
- image: circleci/python:2.7-stretch-node-browsers | ||
environment: | ||
PYTHON_VERSION: py27 | ||
'python-2.7': &test-template | ||
docker: | ||
- image: circleci/python:2.7-stretch-node-browsers | ||
environment: | ||
PYTHON_VERSION: py27 | ||
|
||
steps: | ||
- checkout | ||
steps: | ||
- checkout | ||
|
||
- run: | ||
name: Create virtual env | ||
command: python -m venv || virtualenv venv | ||
- run: | ||
name: Create virtual env | ||
command: python -m venv || virtualenv venv | ||
|
||
- run: | ||
name: Write job name | ||
command: echo $CIRCLE_JOB > circlejob.txt | ||
- run: | ||
name: Write job name | ||
command: echo $CIRCLE_JOB > circlejob.txt | ||
|
||
- restore_cache: | ||
key: deps1-{{ .Branch }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "circlejob.txt" }} | ||
- restore_cache: | ||
key: deps1-{{ .Branch }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "circlejob.txt" }} | ||
|
||
- run: | ||
name: Install dependencies | ||
command: | | ||
sudo pip install virtualenv --upgrade | ||
. venv/bin/activate | ||
pip install -r requirements-dev.txt | ||
npm install --ignore-scripts | ||
- run: | ||
name: Install dependencies | ||
command: | | ||
sudo pip install virtualenv --upgrade | ||
. venv/bin/activate | ||
pip install -r requirements-dev.txt | ||
npm install --ignore-scripts | ||
|
||
- save_cache: | ||
key: deps1-{{ .Branch }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "circlejob.txt" }} | ||
paths: | ||
- "venv" | ||
- "node_modules" | ||
- save_cache: | ||
key: deps1-{{ .Branch }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "circlejob.txt" }} | ||
paths: | ||
- 'venv' | ||
- 'node_modules' | ||
|
||
- run: | ||
name: prettier --list-different | ||
command: npm run format:test | ||
- run: | ||
name: prettier --list-different | ||
command: npm run format:test | ||
|
||
- run: | ||
name: npm run lint | ||
command: npm run lint | ||
- run: | ||
name: npm run lint | ||
command: npm run lint | ||
|
||
- run: | ||
name: Build | ||
command: | | ||
. venv/bin/activate | ||
npm run build:js | ||
npm run build:py | ||
- run: | ||
name: Build | ||
command: | | ||
. venv/bin/activate | ||
npm run build:js | ||
npm run build:py | ||
|
||
- run: | ||
name: Run tests | ||
command: | | ||
. venv/bin/activate | ||
python --version | ||
python -m unittest test.test_integration | ||
python -m unittest test.test_dash_import | ||
- run: | ||
name: Run tests | ||
command: | | ||
. venv/bin/activate | ||
python --version | ||
npm run test-unit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only real difference apart from formatting - running the new unit tests in CircleCI. |
||
python -m unittest test.test_integration | ||
python -m unittest test.test_dash_import | ||
|
||
"python-3.6": | ||
<<: *test-template | ||
docker: | ||
- image: circleci/python:3.6-stretch-node-browsers | ||
environment: | ||
PYTHON_VERSION: py36 | ||
PERCY_ENABLE: 0 | ||
|
||
"python-3.7": | ||
<<: *test-template | ||
docker: | ||
- image: circleci/python:3.7-stretch-node-browsers | ||
environment: | ||
PYTHON_VERSION: py37 | ||
PERCY_ENABLE: 0 | ||
'python-3.6': | ||
<<: *test-template | ||
docker: | ||
- image: circleci/python:3.6-stretch-node-browsers | ||
environment: | ||
PYTHON_VERSION: py36 | ||
PERCY_ENABLE: 0 | ||
|
||
'python-3.7': | ||
<<: *test-template | ||
docker: | ||
- image: circleci/python:3.7-stretch-node-browsers | ||
environment: | ||
PYTHON_VERSION: py37 | ||
PERCY_ENABLE: 0 | ||
|
||
workflows: | ||
version: 2 | ||
build: | ||
jobs: | ||
- "python-2.7" | ||
- "python-3.6" | ||
- "python-3.7" | ||
version: 2 | ||
build: | ||
jobs: | ||
- 'python-2.7' | ||
- 'python-3.6' | ||
- 'python-3.7' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
# AUTO GENERATED FILE - DO NOT EDIT | ||
from dash.development.base_component import Component, _explicitize_args | ||
class Store(Component): | ||
"""A Store component. | ||
Easily keep data on the client side with this component. | ||
The data is not inserted in the DOM. | ||
Data can be in memory, localStorage or sessionStorage. | ||
The data will be kept with the id as key. | ||
Keyword arguments: | ||
- id (string; required): The key of the storage. | ||
- storage_type (a value equal to: 'local', 'session', 'memory'; optional): The type of the web storage. | ||
memory: only kept in memory, reset on page refresh. | ||
local: window.localStorage, data is kept after the browser quit. | ||
session: window.sessionStorage, data is cleared once the browser quit. | ||
- data (dict | list | number | string; optional): The stored data for the id. | ||
- clear_data (boolean; optional): Set to true to remove the data contained in `data_key`. | ||
- modified_timestamp (number; optional): The last time the storage was modified. | ||
Available events: """ | ||
@_explicitize_args | ||
def __init__(self, id=Component.REQUIRED, storage_type=Component.UNDEFINED, data=Component.UNDEFINED, clear_data=Component.UNDEFINED, modified_timestamp=Component.UNDEFINED, **kwargs): | ||
self._prop_names = ['id', 'storage_type', 'data', 'clear_data', 'modified_timestamp'] | ||
self._type = 'Store' | ||
self._namespace = 'dash_core_components' | ||
self._valid_wildcard_attributes = [] | ||
self.available_events = [] | ||
self.available_properties = ['id', 'storage_type', 'data', 'clear_data', 'modified_timestamp'] | ||
self.available_wildcard_properties = [] | ||
_explicit_args = kwargs.pop('_explicit_args') | ||
_locals = locals() | ||
_locals.update(kwargs) # For wildcard attrs | ||
args = {k: _locals[k] for k in _explicit_args if k != 'children'} | ||
for k in ['id']: | ||
if k not in args: | ||
raise TypeError( | ||
'Required argument `' + k + '` was not specified.') | ||
super(Store, self).__init__(**args) | ||
def __repr__(self): | ||
if(any(getattr(self, c, None) is not None | ||
for c in self._prop_names | ||
if c is not self._prop_names[0]) | ||
or any(getattr(self, c, None) is not None | ||
for c in self.__dict__.keys() | ||
if any(c.startswith(wc_attr) | ||
for wc_attr in self._valid_wildcard_attributes))): | ||
props_string = ', '.join([c+'='+repr(getattr(self, c, None)) | ||
for c in self._prop_names | ||
if getattr(self, c, None) is not None]) | ||
wilds_string = ', '.join([c+'='+repr(getattr(self, c, None)) | ||
for c in self.__dict__.keys() | ||
if any([c.startswith(wc_attr) | ||
for wc_attr in | ||
self._valid_wildcard_attributes])]) | ||
return ('Store(' + props_string + | ||
(', ' + wilds_string if wilds_string != '' else '') + ')') | ||
else: | ||
return ( | ||
'Store(' + | ||
repr(getattr(self, self._prop_names[0], None)) + ')') | ||
# AUTO GENERATED FILE - DO NOT EDIT | ||
|
||
from dash.development.base_component import Component, _explicitize_args | ||
|
||
|
||
class Store(Component): | ||
"""A Store component. | ||
Easily keep data on the client side with this component. | ||
The data is not inserted in the DOM. | ||
Data can be in memory, localStorage or sessionStorage. | ||
The data will be kept with the id as key. | ||
|
||
Keyword arguments: | ||
- id (string; required): The key of the storage. | ||
- storage_type (a value equal to: 'local', 'session', 'memory'; optional): The type of the web storage. | ||
|
||
memory: only kept in memory, reset on page refresh. | ||
local: window.localStorage, data is kept after the browser quit. | ||
session: window.sessionStorage, data is cleared once the browser quit. | ||
- data (dict | list | number | string; optional): The stored data for the id. | ||
- clear_data (boolean; optional): Set to true to remove the data contained in `data_key`. | ||
- modified_timestamp (number; optional): The last time the storage was modified. | ||
|
||
Available events: """ | ||
@_explicitize_args | ||
def __init__(self, id=Component.REQUIRED, storage_type=Component.UNDEFINED, data=Component.UNDEFINED, clear_data=Component.UNDEFINED, modified_timestamp=Component.UNDEFINED, **kwargs): | ||
self._prop_names = ['id', 'storage_type', 'data', 'clear_data', 'modified_timestamp'] | ||
self._type = 'Store' | ||
self._namespace = 'dash_core_components' | ||
self._valid_wildcard_attributes = [] | ||
self.available_events = [] | ||
self.available_properties = ['id', 'storage_type', 'data', 'clear_data', 'modified_timestamp'] | ||
self.available_wildcard_properties = [] | ||
|
||
_explicit_args = kwargs.pop('_explicit_args') | ||
_locals = locals() | ||
_locals.update(kwargs) # For wildcard attrs | ||
args = {k: _locals[k] for k in _explicit_args if k != 'children'} | ||
|
||
for k in ['id']: | ||
if k not in args: | ||
raise TypeError( | ||
'Required argument `' + k + '` was not specified.') | ||
super(Store, self).__init__(**args) | ||
|
||
def __repr__(self): | ||
if(any(getattr(self, c, None) is not None | ||
for c in self._prop_names | ||
if c is not self._prop_names[0]) | ||
or any(getattr(self, c, None) is not None | ||
for c in self.__dict__.keys() | ||
if any(c.startswith(wc_attr) | ||
for wc_attr in self._valid_wildcard_attributes))): | ||
props_string = ', '.join([c+'='+repr(getattr(self, c, None)) | ||
for c in self._prop_names | ||
if getattr(self, c, None) is not None]) | ||
wilds_string = ', '.join([c+'='+repr(getattr(self, c, None)) | ||
for c in self.__dict__.keys() | ||
if any([c.startswith(wc_attr) | ||
for wc_attr in | ||
self._valid_wildcard_attributes])]) | ||
return ('Store(' + props_string + | ||
(', ' + wilds_string if wilds_string != '' else '') + ')') | ||
else: | ||
return ( | ||
'Store(' + | ||
repr(getattr(self, self._prop_names[0], None)) + ')') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we use (a brand new) plugin
babel-test
, so that Jest will use Babel and styled-jsx, but won't parse the classes tojsx-1324
or whatever, so that we can make assertions on them!