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

Commit 0c7ffb4

Browse files
Merge pull request #315 from plotly/unit_tests_with_jest
Unit tests with Jest + Enzyme and updates to Tabs component
2 parents b923e23 + 390a499 commit 0c7ffb4

19 files changed

+15119
-8152
lines changed

.babelrc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
{
22
"presets": ["env", "react"],
3-
"plugins": ["transform-object-rest-spread", "styled-jsx/babel"]
4-
}
3+
"env": {
4+
"production": {
5+
"plugins": ["transform-object-rest-spread", "styled-jsx/babel"]
6+
},
7+
"development": {
8+
"plugins": ["transform-object-rest-spread", "styled-jsx/babel"]
9+
},
10+
"test": {
11+
"plugins": ["transform-object-rest-spread", "styled-jsx/babel-test"]
12+
}
13+
}
14+
}

.circleci/config.yml

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,84 @@
11
version: 2
22

33
jobs:
4-
"python-2.7": &test-template
5-
docker:
6-
- image: circleci/python:2.7-stretch-node-browsers
7-
environment:
8-
PYTHON_VERSION: py27
4+
'python-2.7': &test-template
5+
docker:
6+
- image: circleci/python:2.7-stretch-node-browsers
7+
environment:
8+
PYTHON_VERSION: py27
99

10-
steps:
11-
- checkout
10+
steps:
11+
- checkout
1212

13-
- run:
14-
name: Create virtual env
15-
command: python -m venv || virtualenv venv
13+
- run:
14+
name: Create virtual env
15+
command: python -m venv || virtualenv venv
1616

17-
- run:
18-
name: Write job name
19-
command: echo $CIRCLE_JOB > circlejob.txt
17+
- run:
18+
name: Write job name
19+
command: echo $CIRCLE_JOB > circlejob.txt
2020

21-
- restore_cache:
22-
key: deps1-{{ .Branch }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "circlejob.txt" }}
21+
- restore_cache:
22+
key: deps1-{{ .Branch }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "circlejob.txt" }}
2323

24-
- run:
25-
name: Install dependencies
26-
command: |
27-
sudo pip install virtualenv --upgrade
28-
. venv/bin/activate
29-
pip install -r requirements-dev.txt
30-
npm install --ignore-scripts
24+
- run:
25+
name: Install dependencies
26+
command: |
27+
sudo pip install virtualenv --upgrade
28+
. venv/bin/activate
29+
pip install -r requirements-dev.txt
30+
npm install --ignore-scripts
3131
32-
- save_cache:
33-
key: deps1-{{ .Branch }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "circlejob.txt" }}
34-
paths:
35-
- "venv"
36-
- "node_modules"
32+
- save_cache:
33+
key: deps1-{{ .Branch }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}-{{ checksum ".circleci/config.yml" }}-{{ checksum "circlejob.txt" }}
34+
paths:
35+
- 'venv'
36+
- 'node_modules'
3737

38-
- run:
39-
name: prettier --list-different
40-
command: npm run format:test
38+
- run:
39+
name: prettier --list-different
40+
command: npm run format:test
4141

42-
- run:
43-
name: npm run lint
44-
command: npm run lint
42+
- run:
43+
name: npm run lint
44+
command: npm run lint
4545

46-
- run:
47-
name: Build
48-
command: |
49-
. venv/bin/activate
50-
npm run build:js
51-
npm run build:py
46+
- run:
47+
name: Build
48+
command: |
49+
. venv/bin/activate
50+
npm run build:js
51+
npm run build:py
5252
53-
- run:
54-
name: Run tests
55-
command: |
56-
. venv/bin/activate
57-
python --version
58-
python -m unittest test.test_integration
59-
python -m unittest test.test_dash_import
53+
- run:
54+
name: Run tests
55+
command: |
56+
. venv/bin/activate
57+
python --version
58+
npm run test-unit
59+
python -m unittest test.test_integration
60+
python -m unittest test.test_dash_import
6061
61-
"python-3.6":
62-
<<: *test-template
63-
docker:
64-
- image: circleci/python:3.6-stretch-node-browsers
65-
environment:
66-
PYTHON_VERSION: py36
67-
PERCY_ENABLE: 0
68-
69-
"python-3.7":
70-
<<: *test-template
71-
docker:
72-
- image: circleci/python:3.7-stretch-node-browsers
73-
environment:
74-
PYTHON_VERSION: py37
75-
PERCY_ENABLE: 0
62+
'python-3.6':
63+
<<: *test-template
64+
docker:
65+
- image: circleci/python:3.6-stretch-node-browsers
66+
environment:
67+
PYTHON_VERSION: py36
68+
PERCY_ENABLE: 0
7669

70+
'python-3.7':
71+
<<: *test-template
72+
docker:
73+
- image: circleci/python:3.7-stretch-node-browsers
74+
environment:
75+
PYTHON_VERSION: py37
76+
PERCY_ENABLE: 0
7777

7878
workflows:
79-
version: 2
80-
build:
81-
jobs:
82-
- "python-2.7"
83-
- "python-3.6"
84-
- "python-3.7"
79+
version: 2
80+
build:
81+
jobs:
82+
- 'python-2.7'
83+
- 'python-3.6'
84+
- 'python-3.7'

CHANGELOG.md

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

513
## [0.33.1] -- 2018-10-17
614
### Fixed

dash_core_components/Store.py

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
1-
# AUTO GENERATED FILE - DO NOT EDIT
2-
3-
from dash.development.base_component import Component, _explicitize_args
4-
5-
6-
class Store(Component):
7-
"""A Store component.
8-
Easily keep data on the client side with this component.
9-
The data is not inserted in the DOM.
10-
Data can be in memory, localStorage or sessionStorage.
11-
The data will be kept with the id as key.
12-
13-
Keyword arguments:
14-
- id (string; required): The key of the storage.
15-
- storage_type (a value equal to: 'local', 'session', 'memory'; optional): The type of the web storage.
16-
17-
memory: only kept in memory, reset on page refresh.
18-
local: window.localStorage, data is kept after the browser quit.
19-
session: window.sessionStorage, data is cleared once the browser quit.
20-
- data (dict | list | number | string; optional): The stored data for the id.
21-
- clear_data (boolean; optional): Set to true to remove the data contained in `data_key`.
22-
- modified_timestamp (number; optional): The last time the storage was modified.
23-
24-
Available events: """
25-
@_explicitize_args
26-
def __init__(self, id=Component.REQUIRED, storage_type=Component.UNDEFINED, data=Component.UNDEFINED, clear_data=Component.UNDEFINED, modified_timestamp=Component.UNDEFINED, **kwargs):
27-
self._prop_names = ['id', 'storage_type', 'data', 'clear_data', 'modified_timestamp']
28-
self._type = 'Store'
29-
self._namespace = 'dash_core_components'
30-
self._valid_wildcard_attributes = []
31-
self.available_events = []
32-
self.available_properties = ['id', 'storage_type', 'data', 'clear_data', 'modified_timestamp']
33-
self.available_wildcard_properties = []
34-
35-
_explicit_args = kwargs.pop('_explicit_args')
36-
_locals = locals()
37-
_locals.update(kwargs) # For wildcard attrs
38-
args = {k: _locals[k] for k in _explicit_args if k != 'children'}
39-
40-
for k in ['id']:
41-
if k not in args:
42-
raise TypeError(
43-
'Required argument `' + k + '` was not specified.')
44-
super(Store, self).__init__(**args)
45-
46-
def __repr__(self):
47-
if(any(getattr(self, c, None) is not None
48-
for c in self._prop_names
49-
if c is not self._prop_names[0])
50-
or any(getattr(self, c, None) is not None
51-
for c in self.__dict__.keys()
52-
if any(c.startswith(wc_attr)
53-
for wc_attr in self._valid_wildcard_attributes))):
54-
props_string = ', '.join([c+'='+repr(getattr(self, c, None))
55-
for c in self._prop_names
56-
if getattr(self, c, None) is not None])
57-
wilds_string = ', '.join([c+'='+repr(getattr(self, c, None))
58-
for c in self.__dict__.keys()
59-
if any([c.startswith(wc_attr)
60-
for wc_attr in
61-
self._valid_wildcard_attributes])])
62-
return ('Store(' + props_string +
63-
(', ' + wilds_string if wilds_string != '' else '') + ')')
64-
else:
65-
return (
66-
'Store(' +
67-
repr(getattr(self, self._prop_names[0], None)) + ')')
1+
# AUTO GENERATED FILE - DO NOT EDIT
2+
3+
from dash.development.base_component import Component, _explicitize_args
4+
5+
6+
class Store(Component):
7+
"""A Store component.
8+
Easily keep data on the client side with this component.
9+
The data is not inserted in the DOM.
10+
Data can be in memory, localStorage or sessionStorage.
11+
The data will be kept with the id as key.
12+
13+
Keyword arguments:
14+
- id (string; required): The key of the storage.
15+
- storage_type (a value equal to: 'local', 'session', 'memory'; optional): The type of the web storage.
16+
17+
memory: only kept in memory, reset on page refresh.
18+
local: window.localStorage, data is kept after the browser quit.
19+
session: window.sessionStorage, data is cleared once the browser quit.
20+
- data (dict | list | number | string; optional): The stored data for the id.
21+
- clear_data (boolean; optional): Set to true to remove the data contained in `data_key`.
22+
- modified_timestamp (number; optional): The last time the storage was modified.
23+
24+
Available events: """
25+
@_explicitize_args
26+
def __init__(self, id=Component.REQUIRED, storage_type=Component.UNDEFINED, data=Component.UNDEFINED, clear_data=Component.UNDEFINED, modified_timestamp=Component.UNDEFINED, **kwargs):
27+
self._prop_names = ['id', 'storage_type', 'data', 'clear_data', 'modified_timestamp']
28+
self._type = 'Store'
29+
self._namespace = 'dash_core_components'
30+
self._valid_wildcard_attributes = []
31+
self.available_events = []
32+
self.available_properties = ['id', 'storage_type', 'data', 'clear_data', 'modified_timestamp']
33+
self.available_wildcard_properties = []
34+
35+
_explicit_args = kwargs.pop('_explicit_args')
36+
_locals = locals()
37+
_locals.update(kwargs) # For wildcard attrs
38+
args = {k: _locals[k] for k in _explicit_args if k != 'children'}
39+
40+
for k in ['id']:
41+
if k not in args:
42+
raise TypeError(
43+
'Required argument `' + k + '` was not specified.')
44+
super(Store, self).__init__(**args)
45+
46+
def __repr__(self):
47+
if(any(getattr(self, c, None) is not None
48+
for c in self._prop_names
49+
if c is not self._prop_names[0])
50+
or any(getattr(self, c, None) is not None
51+
for c in self.__dict__.keys()
52+
if any(c.startswith(wc_attr)
53+
for wc_attr in self._valid_wildcard_attributes))):
54+
props_string = ', '.join([c+'='+repr(getattr(self, c, None))
55+
for c in self._prop_names
56+
if getattr(self, c, None) is not None])
57+
wilds_string = ', '.join([c+'='+repr(getattr(self, c, None))
58+
for c in self.__dict__.keys()
59+
if any([c.startswith(wc_attr)
60+
for wc_attr in
61+
self._valid_wildcard_attributes])])
62+
return ('Store(' + props_string +
63+
(', ' + wilds_string if wilds_string != '' else '') + ')')
64+
else:
65+
return (
66+
'Store(' +
67+
repr(getattr(self, self._prop_names[0], None)) + ')')

dash_core_components/Tab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Tab(Component):
1212
- id (string; optional): The ID of this component, used to identify dash components
1313
in callbacks. The ID needs to be unique across all of the
1414
components in an app.
15-
- label (optional): The tab's label
15+
- label (string; optional): The tab's label
1616
- value (string; optional): Value for determining which Tab is currently selected
1717
- disabled (boolean; optional): Determines if tab is disabled or not - defaults to false
1818
- disabled_style (dict; optional): Overrides the default (inline) styles when disabled

dash_core_components/Tabs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Tabs(Component):
1010
children components that will be that tab's content.
1111
1212
Keyword arguments:
13-
- children (a list of or a singular dash component, string or number; optional): Array that holds Tab components
13+
- children (list | a list of or a singular dash component, string or number; optional): Array that holds Tab components
1414
- id (string; optional): The ID of this component, used to identify dash components
1515
in callbacks. The ID needs to be unique across all of the
1616
components in an app.

0 commit comments

Comments
 (0)