Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Unit tests with Jest + Enzyme and updates to Tabs component #315

Merged
merged 20 commits into from
Oct 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b98f36b
Setup jest
valentijnnieman Sep 25, 2018
15c6813
Setup babel-test plugin and Tabs unit tests
valentijnnieman Sep 26, 2018
72ad1c3
Rebuild components with Tabs changes
valentijnnieman Sep 26, 2018
8ef4a64
Formatted .circleci config and added Jest step
valentijnnieman Sep 26, 2018
9d74498
Refactored Tabs
valentijnnieman Sep 26, 2018
4368653
Add child.props logic back in
valentijnnieman Sep 26, 2018
e7272a9
Better children prop validation and fix integration tests
valentijnnieman Oct 15, 2018
0da5ff8
Reformatted Tabs.react.js
valentijnnieman Oct 15, 2018
518b7c8
Update styled-jsx so it includes babel-test plugin
valentijnnieman Oct 15, 2018
e933923
Rewrite child props logic again
valentijnnieman Oct 15, 2018
6e9af8d
Reformat Tabs.react.js part 2
valentijnnieman Oct 15, 2018
2a72658
Remove debugging statements
valentijnnieman Oct 15, 2018
e0d21c2
Children props logic update
valentijnnieman Oct 15, 2018
f4b4aeb
Remove debugging statements part 999
valentijnnieman Oct 15, 2018
962c96f
Don't break if no children are set on Tabs
valentijnnieman Oct 15, 2018
5a567cd
Remove children from Tabs in integration_test
valentijnnieman Oct 15, 2018
15b40d6
Only use state if setProps isn't defined, check if imcoming props are…
valentijnnieman Oct 17, 2018
fa9f711
pin urllib3 to <=1.22 a la #333
valentijnnieman Oct 17, 2018
7116f65
Bump version and change some comments
valentijnnieman Oct 17, 2018
390a499
Merge branch 'master' of https://github.com/plotly/dash-core-componen…
valentijnnieman Oct 17, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .babelrc
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"]
Copy link
Contributor Author

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 to jsx-1324 or whatever, so that we can make assertions on them!

}
}
}
134 changes: 67 additions & 67 deletions .circleci/config.yml
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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'
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Change Log for dash-core-components
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [0.34.0] - 2018-10-17
### Added
- `npm run test-unit` will run new Jest+Enzyme unit tests
- Unit tests for Tabs component
### Fixed
- Fixed bug in Tabs component where value was resetting if using callback-less mode [#331](https://github.com/plotly/dash-core-components/issues/331)
- Fixed bug with default Tabs value not being set to children's Tab value (if it's set)
- Fixed bug where Tabs.children.props wheren't being selected properly, related to [#84](https://github.com/plotly/dash-renderer/issues/84)

## [0.33.1] -- 2018-10-17
### Fixed
Expand Down
134 changes: 67 additions & 67 deletions dash_core_components/Store.py
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)) + ')')
2 changes: 1 addition & 1 deletion dash_core_components/Tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Tab(Component):
- id (string; optional): The ID of this component, used to identify dash components
in callbacks. The ID needs to be unique across all of the
components in an app.
- label (optional): The tab's label
- label (string; optional): The tab's label
- value (string; optional): Value for determining which Tab is currently selected
- disabled (boolean; optional): Determines if tab is disabled or not - defaults to false
- disabled_style (dict; optional): Overrides the default (inline) styles when disabled
Expand Down
2 changes: 1 addition & 1 deletion dash_core_components/Tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Tabs(Component):
children components that will be that tab's content.

Keyword arguments:
- children (a list of or a singular dash component, string or number; optional): Array that holds Tab components
- children (list | a list of or a singular dash component, string or number; optional): Array that holds Tab components
- id (string; optional): The ID of this component, used to identify dash components
in callbacks. The ID needs to be unique across all of the
components in an app.
Expand Down
Loading