umap-project 2.5.1__py3-none-any.whl → 2.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of umap-project might be problematic. Click here for more details.
- umap/__init__.py +1 -1
- umap/admin.py +6 -1
- umap/context_processors.py +2 -1
- umap/decorators.py +13 -2
- umap/forms.py +26 -2
- umap/locale/br/LC_MESSAGES/django.mo +0 -0
- umap/locale/br/LC_MESSAGES/django.po +252 -146
- umap/locale/ca/LC_MESSAGES/django.mo +0 -0
- umap/locale/ca/LC_MESSAGES/django.po +274 -162
- umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
- umap/locale/cs_CZ/LC_MESSAGES/django.po +261 -150
- umap/locale/de/LC_MESSAGES/django.mo +0 -0
- umap/locale/de/LC_MESSAGES/django.po +299 -187
- umap/locale/el/LC_MESSAGES/django.mo +0 -0
- umap/locale/el/LC_MESSAGES/django.po +215 -159
- umap/locale/en/LC_MESSAGES/django.po +211 -155
- umap/locale/es/LC_MESSAGES/django.mo +0 -0
- umap/locale/es/LC_MESSAGES/django.po +255 -144
- umap/locale/eu/LC_MESSAGES/django.mo +0 -0
- umap/locale/eu/LC_MESSAGES/django.po +254 -198
- umap/locale/fa_IR/LC_MESSAGES/django.mo +0 -0
- umap/locale/fa_IR/LC_MESSAGES/django.po +347 -235
- umap/locale/fr/LC_MESSAGES/django.mo +0 -0
- umap/locale/fr/LC_MESSAGES/django.po +216 -160
- umap/locale/hu/LC_MESSAGES/django.mo +0 -0
- umap/locale/hu/LC_MESSAGES/django.po +215 -159
- umap/locale/it/LC_MESSAGES/django.mo +0 -0
- umap/locale/it/LC_MESSAGES/django.po +252 -146
- umap/locale/ms/LC_MESSAGES/django.mo +0 -0
- umap/locale/ms/LC_MESSAGES/django.po +252 -146
- umap/locale/pl/LC_MESSAGES/django.mo +0 -0
- umap/locale/pl/LC_MESSAGES/django.po +254 -148
- umap/locale/pt/LC_MESSAGES/django.mo +0 -0
- umap/locale/pt/LC_MESSAGES/django.po +215 -159
- umap/locale/sv/LC_MESSAGES/django.mo +0 -0
- umap/locale/sv/LC_MESSAGES/django.po +254 -143
- umap/locale/th_TH/LC_MESSAGES/django.mo +0 -0
- umap/locale/th_TH/LC_MESSAGES/django.po +125 -70
- umap/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
- umap/locale/zh_TW/LC_MESSAGES/django.po +256 -145
- umap/migrations/0022_add_team.py +94 -0
- umap/models.py +45 -10
- umap/settings/__init__.py +2 -0
- umap/settings/base.py +9 -2
- umap/static/umap/base.css +32 -41
- umap/static/umap/content.css +19 -25
- umap/static/umap/css/icon.css +63 -37
- umap/static/umap/css/importers.css +1 -1
- umap/static/umap/css/slideshow.css +7 -5
- umap/static/umap/css/tableeditor.css +4 -3
- umap/static/umap/img/16-white.svg +1 -4
- umap/static/umap/img/16.svg +2 -6
- umap/static/umap/img/24-white.svg +4 -4
- umap/static/umap/img/24.svg +6 -6
- umap/static/umap/img/source/16-white.svg +2 -5
- umap/static/umap/img/source/16.svg +3 -7
- umap/static/umap/img/source/24-white.svg +7 -14
- umap/static/umap/img/source/24.svg +10 -17
- umap/static/umap/js/components/alerts/alert.css +20 -8
- umap/static/umap/js/modules/autocomplete.js +8 -12
- umap/static/umap/js/modules/browser.js +4 -3
- umap/static/umap/js/modules/caption.js +9 -11
- umap/static/umap/js/modules/data/features.js +993 -0
- umap/static/umap/js/modules/data/layer.js +1210 -0
- umap/static/umap/js/modules/formatter.js +12 -3
- umap/static/umap/js/modules/global.js +21 -5
- umap/static/umap/js/modules/importers/overpass.js +22 -8
- umap/static/umap/js/modules/permissions.js +280 -0
- umap/static/umap/js/{umap.icon.js → modules/rendering/icon.js} +77 -56
- umap/static/umap/js/modules/rendering/layers/base.js +105 -0
- umap/static/umap/js/modules/rendering/layers/classified.js +484 -0
- umap/static/umap/js/modules/rendering/layers/cluster.js +103 -0
- umap/static/umap/js/modules/rendering/layers/heat.js +182 -0
- umap/static/umap/js/modules/rendering/popup.js +99 -0
- umap/static/umap/js/modules/rendering/template.js +217 -0
- umap/static/umap/js/modules/rendering/ui.js +610 -0
- umap/static/umap/js/modules/rules.js +16 -3
- umap/static/umap/js/modules/schema.js +25 -1
- umap/static/umap/js/modules/share.js +66 -45
- umap/static/umap/js/modules/sync/updaters.js +9 -10
- umap/static/umap/js/modules/tableeditor.js +7 -7
- umap/static/umap/js/modules/ui/dialog.js +8 -4
- umap/static/umap/js/modules/utils.js +22 -13
- umap/static/umap/js/umap.controls.js +80 -146
- umap/static/umap/js/umap.core.js +9 -9
- umap/static/umap/js/umap.forms.js +41 -17
- umap/static/umap/js/umap.js +72 -65
- umap/static/umap/locale/am_ET.js +8 -2
- umap/static/umap/locale/am_ET.json +8 -2
- umap/static/umap/locale/ar.js +8 -2
- umap/static/umap/locale/ar.json +8 -2
- umap/static/umap/locale/ast.js +8 -2
- umap/static/umap/locale/ast.json +8 -2
- umap/static/umap/locale/bg.js +8 -2
- umap/static/umap/locale/bg.json +8 -2
- umap/static/umap/locale/br.js +42 -36
- umap/static/umap/locale/br.json +42 -36
- umap/static/umap/locale/ca.js +67 -61
- umap/static/umap/locale/ca.json +67 -61
- umap/static/umap/locale/cs_CZ.js +8 -2
- umap/static/umap/locale/cs_CZ.json +8 -2
- umap/static/umap/locale/da.js +8 -2
- umap/static/umap/locale/da.json +8 -2
- umap/static/umap/locale/de.js +143 -137
- umap/static/umap/locale/de.json +143 -137
- umap/static/umap/locale/el.js +54 -48
- umap/static/umap/locale/el.json +54 -48
- umap/static/umap/locale/en.js +10 -2
- umap/static/umap/locale/en.json +10 -2
- umap/static/umap/locale/en_US.json +8 -2
- umap/static/umap/locale/es.js +8 -2
- umap/static/umap/locale/es.json +8 -2
- umap/static/umap/locale/et.js +8 -2
- umap/static/umap/locale/et.json +8 -2
- umap/static/umap/locale/eu.js +346 -338
- umap/static/umap/locale/eu.json +346 -338
- umap/static/umap/locale/fa_IR.js +415 -407
- umap/static/umap/locale/fa_IR.json +415 -407
- umap/static/umap/locale/fi.js +8 -2
- umap/static/umap/locale/fi.json +8 -2
- umap/static/umap/locale/fr.js +11 -3
- umap/static/umap/locale/fr.json +11 -3
- umap/static/umap/locale/gl.js +8 -2
- umap/static/umap/locale/gl.json +8 -2
- umap/static/umap/locale/he.js +8 -2
- umap/static/umap/locale/he.json +8 -2
- umap/static/umap/locale/hr.js +8 -2
- umap/static/umap/locale/hr.json +8 -2
- umap/static/umap/locale/hu.js +31 -23
- umap/static/umap/locale/hu.json +31 -23
- umap/static/umap/locale/id.js +8 -2
- umap/static/umap/locale/id.json +8 -2
- umap/static/umap/locale/is.js +8 -2
- umap/static/umap/locale/is.json +8 -2
- umap/static/umap/locale/it.js +8 -2
- umap/static/umap/locale/it.json +8 -2
- umap/static/umap/locale/ja.js +8 -2
- umap/static/umap/locale/ja.json +8 -2
- umap/static/umap/locale/ko.js +8 -2
- umap/static/umap/locale/ko.json +8 -2
- umap/static/umap/locale/lt.js +8 -2
- umap/static/umap/locale/lt.json +8 -2
- umap/static/umap/locale/ms.js +8 -2
- umap/static/umap/locale/ms.json +8 -2
- umap/static/umap/locale/nl.js +8 -2
- umap/static/umap/locale/nl.json +8 -2
- umap/static/umap/locale/no.js +8 -2
- umap/static/umap/locale/no.json +8 -2
- umap/static/umap/locale/pl.js +54 -48
- umap/static/umap/locale/pl.json +54 -48
- umap/static/umap/locale/pl_PL.json +8 -2
- umap/static/umap/locale/pt.js +24 -18
- umap/static/umap/locale/pt.json +24 -18
- umap/static/umap/locale/pt_BR.js +8 -2
- umap/static/umap/locale/pt_BR.json +8 -2
- umap/static/umap/locale/pt_PT.js +214 -208
- umap/static/umap/locale/pt_PT.json +214 -208
- umap/static/umap/locale/ro.js +8 -2
- umap/static/umap/locale/ro.json +8 -2
- umap/static/umap/locale/ru.js +8 -2
- umap/static/umap/locale/ru.json +8 -2
- umap/static/umap/locale/sk_SK.js +8 -2
- umap/static/umap/locale/sk_SK.json +8 -2
- umap/static/umap/locale/sl.js +8 -2
- umap/static/umap/locale/sl.json +8 -2
- umap/static/umap/locale/sr.js +8 -2
- umap/static/umap/locale/sr.json +8 -2
- umap/static/umap/locale/sv.js +8 -2
- umap/static/umap/locale/sv.json +8 -2
- umap/static/umap/locale/th_TH.js +33 -27
- umap/static/umap/locale/th_TH.json +33 -27
- umap/static/umap/locale/tr.js +8 -2
- umap/static/umap/locale/tr.json +8 -2
- umap/static/umap/locale/uk_UA.js +8 -2
- umap/static/umap/locale/uk_UA.json +8 -2
- umap/static/umap/locale/vi.js +8 -2
- umap/static/umap/locale/vi.json +8 -2
- umap/static/umap/locale/vi_VN.json +8 -2
- umap/static/umap/locale/zh.js +8 -2
- umap/static/umap/locale/zh.json +8 -2
- umap/static/umap/locale/zh_CN.json +8 -2
- umap/static/umap/locale/zh_TW.Big5.json +8 -2
- umap/static/umap/locale/zh_TW.js +102 -96
- umap/static/umap/locale/zh_TW.json +102 -96
- umap/static/umap/map.css +111 -108
- umap/static/umap/nav.css +19 -10
- umap/static/umap/unittests/utils.js +230 -107
- umap/static/umap/vars.css +1 -0
- umap/static/umap/vendors/csv2geojson/csv2geojson.js +62 -40
- umap/static/umap/vendors/editable/Leaflet.Editable.js +2079 -1937
- umap/storage.py +1 -0
- umap/templates/404.html +5 -1
- umap/templates/500.html +3 -1
- umap/templates/auth/user_detail.html +8 -2
- umap/templates/auth/user_form.html +19 -10
- umap/templates/auth/user_stars.html +8 -2
- umap/templates/base.html +1 -0
- umap/templates/registration/login.html +18 -3
- umap/templates/umap/about.html +1 -0
- umap/templates/umap/about_summary.html +22 -7
- umap/templates/umap/components/alerts/alert.html +42 -21
- umap/templates/umap/content.html +2 -0
- umap/templates/umap/content_footer.html +7 -3
- umap/templates/umap/css.html +1 -0
- umap/templates/umap/dashboard_menu.html +15 -0
- umap/templates/umap/home.html +14 -4
- umap/templates/umap/js.html +4 -9
- umap/templates/umap/login_popup_end.html +10 -4
- umap/templates/umap/map_detail.html +8 -2
- umap/templates/umap/map_fragment.html +3 -1
- umap/templates/umap/map_init.html +2 -1
- umap/templates/umap/map_list.html +6 -3
- umap/templates/umap/map_table.html +36 -12
- umap/templates/umap/messages.html +0 -1
- umap/templates/umap/navigation.html +2 -1
- umap/templates/umap/password_change.html +5 -1
- umap/templates/umap/password_change_done.html +8 -2
- umap/templates/umap/search.html +8 -2
- umap/templates/umap/search_bar.html +1 -0
- umap/templates/umap/team_confirm_delete.html +19 -0
- umap/templates/umap/team_detail.html +27 -0
- umap/templates/umap/team_form.html +60 -0
- umap/templates/umap/user_dashboard.html +7 -9
- umap/templates/umap/user_teams.html +51 -0
- umap/tests/base.py +8 -1
- umap/tests/conftest.py +6 -0
- umap/tests/fixtures/test_circles_layer.geojson +219 -0
- umap/tests/fixtures/test_upload_georss.xml +20 -0
- umap/tests/integration/conftest.py +18 -4
- umap/tests/integration/helpers.py +12 -0
- umap/tests/integration/test_anonymous_owned_map.py +23 -0
- umap/tests/integration/test_basics.py +29 -0
- umap/tests/integration/test_browser.py +20 -0
- umap/tests/integration/test_caption.py +20 -0
- umap/tests/integration/test_circles_layer.py +69 -0
- umap/tests/integration/test_conditional_rules.py +102 -17
- umap/tests/integration/test_draw_polygon.py +138 -13
- umap/tests/integration/test_draw_polyline.py +8 -18
- umap/tests/integration/test_edit_datalayer.py +3 -3
- umap/tests/integration/test_import.py +124 -5
- umap/tests/integration/test_owned_map.py +21 -13
- umap/tests/integration/test_querystring.py +7 -0
- umap/tests/integration/test_team.py +47 -0
- umap/tests/integration/test_tilelayer.py +19 -2
- umap/tests/integration/test_view_marker.py +28 -1
- umap/tests/integration/test_websocket_sync.py +5 -5
- umap/tests/test_datalayer.py +32 -7
- umap/tests/test_datalayer_views.py +1 -1
- umap/tests/test_map.py +30 -4
- umap/tests/test_map_views.py +2 -2
- umap/tests/test_statics.py +40 -0
- umap/tests/test_team_views.py +131 -0
- umap/tests/test_views.py +15 -1
- umap/urls.py +23 -13
- umap/views.py +116 -10
- {umap_project-2.5.1.dist-info → umap_project-2.6.0.dist-info}/METADATA +14 -14
- {umap_project-2.5.1.dist-info → umap_project-2.6.0.dist-info}/RECORD +260 -253
- umap/static/umap/js/umap.datalayer.permissions.js +0 -70
- umap/static/umap/js/umap.features.js +0 -1290
- umap/static/umap/js/umap.layer.js +0 -1837
- umap/static/umap/js/umap.permissions.js +0 -208
- umap/static/umap/js/umap.popup.js +0 -341
- umap/static/umap/test/TableEditor.js +0 -104
- umap/static/umap/vendors/leaflet/leaflet-src.js +0 -14512
- umap/static/umap/vendors/leaflet/leaflet-src.js.map +0 -1
- umap/static/umap/vendors/leaflet/leaflet.js +0 -6
- umap/static/umap/vendors/leaflet/leaflet.js.map +0 -1
- umap/static/umap/vendors/markercluster/WhereAreTheJavascriptFiles.txt +0 -5
- umap/static/umap/vendors/markercluster/leaflet.markercluster-src.js +0 -2718
- umap/static/umap/vendors/markercluster/leaflet.markercluster-src.js.map +0 -1
- umap/static/umap/vendors/toolbar/leaflet.toolbar-src.css +0 -117
- umap/static/umap/vendors/toolbar/leaflet.toolbar-src.js +0 -365
- umap/tests/integration/test_statics.py +0 -47
- {umap_project-2.5.1.dist-info → umap_project-2.6.0.dist-info}/WHEEL +0 -0
- {umap_project-2.5.1.dist-info → umap_project-2.6.0.dist-info}/entry_points.txt +0 -0
- {umap_project-2.5.1.dist-info → umap_project-2.6.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -8,137 +8,137 @@ const { assert, expect } = pkg
|
|
|
8
8
|
import { JSDOM } from 'jsdom'
|
|
9
9
|
global.JSDOM = JSDOM
|
|
10
10
|
|
|
11
|
-
describe('Utils',
|
|
12
|
-
describe('#toHTML()',
|
|
13
|
-
it('should handle title',
|
|
11
|
+
describe('Utils', () => {
|
|
12
|
+
describe('#toHTML()', () => {
|
|
13
|
+
it('should handle title', () => {
|
|
14
14
|
assert.equal(Utils.toHTML('# A title'), '<h4>A title</h4>')
|
|
15
15
|
})
|
|
16
|
-
it('should handle title followed by text',
|
|
16
|
+
it('should handle title followed by text', () => {
|
|
17
17
|
assert.equal(Utils.toHTML('# A title\nSome text.'), '<h4>A title</h4>Some text.')
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
it('should handle title in the middle of the content',
|
|
20
|
+
it('should handle title in the middle of the content', () => {
|
|
21
21
|
assert.equal(Utils.toHTML('A phrase\n## A title'), 'A phrase\n<h5>A title</h5>')
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
it('should handle hr',
|
|
24
|
+
it('should handle hr', () => {
|
|
25
25
|
assert.equal(Utils.toHTML('---'), '<hr>')
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
it('should handle bold',
|
|
28
|
+
it('should handle bold', () => {
|
|
29
29
|
assert.equal(Utils.toHTML('Some **bold**'), 'Some <strong>bold</strong>')
|
|
30
30
|
})
|
|
31
31
|
|
|
32
|
-
it('should handle italic',
|
|
32
|
+
it('should handle italic', () => {
|
|
33
33
|
assert.equal(Utils.toHTML('Some *italic*'), 'Some <em>italic</em>')
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
it('should handle links without formatting',
|
|
36
|
+
it('should handle links without formatting', () => {
|
|
37
37
|
assert.equal(
|
|
38
38
|
Utils.toHTML('A simple http://osm.org link'),
|
|
39
39
|
'A simple <a href="http://osm.org" target="_blank">http://osm.org</a> link'
|
|
40
40
|
)
|
|
41
41
|
})
|
|
42
42
|
|
|
43
|
-
it('should handle simple link in title',
|
|
43
|
+
it('should handle simple link in title', () => {
|
|
44
44
|
assert.equal(
|
|
45
45
|
Utils.toHTML('# http://osm.org'),
|
|
46
46
|
'<h4><a href="http://osm.org" target="_blank">http://osm.org</a></h4>'
|
|
47
47
|
)
|
|
48
48
|
})
|
|
49
49
|
|
|
50
|
-
it('should handle links with url parameter',
|
|
50
|
+
it('should handle links with url parameter', () => {
|
|
51
51
|
assert.equal(
|
|
52
52
|
Utils.toHTML('A simple https://osm.org/?url=https%3A//anotherurl.com link'),
|
|
53
53
|
'A simple <a href="https://osm.org/?url=https%3A//anotherurl.com" target="_blank">https://osm.org/?url=https%3A//anotherurl.com</a> link'
|
|
54
54
|
)
|
|
55
55
|
})
|
|
56
56
|
|
|
57
|
-
it('should handle simple link inside parenthesis',
|
|
57
|
+
it('should handle simple link inside parenthesis', () => {
|
|
58
58
|
assert.equal(
|
|
59
59
|
Utils.toHTML('A simple link (http://osm.org)'),
|
|
60
60
|
'A simple link (<a href="http://osm.org" target="_blank">http://osm.org</a>)'
|
|
61
61
|
)
|
|
62
62
|
})
|
|
63
63
|
|
|
64
|
-
it('should handle simple link with formatting',
|
|
64
|
+
it('should handle simple link with formatting', () => {
|
|
65
65
|
assert.equal(
|
|
66
66
|
Utils.toHTML('A simple [[http://osm.org]] link'),
|
|
67
67
|
'A simple <a href="http://osm.org" target="_blank">http://osm.org</a> link'
|
|
68
68
|
)
|
|
69
69
|
})
|
|
70
70
|
|
|
71
|
-
it('should handle simple link with formatting and content',
|
|
71
|
+
it('should handle simple link with formatting and content', () => {
|
|
72
72
|
assert.equal(
|
|
73
73
|
Utils.toHTML('A simple [[http://osm.org|link]]'),
|
|
74
74
|
'A simple <a href="http://osm.org" target="_blank">link</a>'
|
|
75
75
|
)
|
|
76
76
|
})
|
|
77
77
|
|
|
78
|
-
it('should handle simple link followed by a carriage return',
|
|
78
|
+
it('should handle simple link followed by a carriage return', () => {
|
|
79
79
|
assert.equal(
|
|
80
80
|
Utils.toHTML('A simple link http://osm.org\nAnother line'),
|
|
81
81
|
'A simple link <a href="http://osm.org" target="_blank">http://osm.org</a>\nAnother line'
|
|
82
82
|
)
|
|
83
83
|
})
|
|
84
84
|
|
|
85
|
-
it('should handle target option',
|
|
85
|
+
it('should handle target option', () => {
|
|
86
86
|
assert.equal(
|
|
87
87
|
Utils.toHTML('A simple http://osm.org link', { target: 'self' }),
|
|
88
88
|
'A simple <a href="http://osm.org" target="_self">http://osm.org</a> link'
|
|
89
89
|
)
|
|
90
90
|
})
|
|
91
91
|
|
|
92
|
-
it('should handle image',
|
|
92
|
+
it('should handle image', () => {
|
|
93
93
|
assert.equal(
|
|
94
94
|
Utils.toHTML('A simple image: {{http://osm.org/pouet.png}}'),
|
|
95
95
|
'A simple image: <img src="http://osm.org/pouet.png">'
|
|
96
96
|
)
|
|
97
97
|
})
|
|
98
98
|
|
|
99
|
-
it('should handle image without text',
|
|
99
|
+
it('should handle image without text', () => {
|
|
100
100
|
assert.equal(
|
|
101
101
|
Utils.toHTML('{{http://osm.org/pouet.png}}'),
|
|
102
102
|
'<img src="http://osm.org/pouet.png">'
|
|
103
103
|
)
|
|
104
104
|
})
|
|
105
105
|
|
|
106
|
-
it('should handle image with width',
|
|
106
|
+
it('should handle image with width', () => {
|
|
107
107
|
assert.equal(
|
|
108
108
|
Utils.toHTML('A simple image: {{http://osm.org/pouet.png|100}}'),
|
|
109
109
|
'A simple image: <img style="width:100px;min-width:100px;" src="http://osm.org/pouet.png">'
|
|
110
110
|
)
|
|
111
111
|
})
|
|
112
112
|
|
|
113
|
-
it('should handle iframe',
|
|
113
|
+
it('should handle iframe', () => {
|
|
114
114
|
assert.equal(
|
|
115
115
|
Utils.toHTML('A simple iframe: {{{http://osm.org/pouet.html}}}'),
|
|
116
116
|
'A simple iframe: <div><iframe height="300px" width="100%" src="http://osm.org/pouet.html" frameborder="0"></iframe></div>'
|
|
117
117
|
)
|
|
118
118
|
})
|
|
119
119
|
|
|
120
|
-
it('should handle iframe with height',
|
|
120
|
+
it('should handle iframe with height', () => {
|
|
121
121
|
assert.equal(
|
|
122
122
|
Utils.toHTML('A simple iframe: {{{http://osm.org/pouet.html|200}}}'),
|
|
123
123
|
'A simple iframe: <div><iframe height="200px" width="100%" src="http://osm.org/pouet.html" frameborder="0"></iframe></div>'
|
|
124
124
|
)
|
|
125
125
|
})
|
|
126
126
|
|
|
127
|
-
it('should handle iframe with height and width',
|
|
127
|
+
it('should handle iframe with height and width', () => {
|
|
128
128
|
assert.equal(
|
|
129
129
|
Utils.toHTML('A simple iframe: {{{http://osm.org/pouet.html|200*400}}}'),
|
|
130
130
|
'A simple iframe: <div><iframe height="200px" width="400px" src="http://osm.org/pouet.html" frameborder="0"></iframe></div>'
|
|
131
131
|
)
|
|
132
132
|
})
|
|
133
133
|
|
|
134
|
-
it('should handle iframe with height with px',
|
|
134
|
+
it('should handle iframe with height with px', () => {
|
|
135
135
|
assert.equal(
|
|
136
136
|
Utils.toHTML('A simple iframe: {{{http://osm.org/pouet.html|200px}}}'),
|
|
137
137
|
'A simple iframe: <div><iframe height="200px" width="100%" src="http://osm.org/pouet.html" frameborder="0"></iframe></div>'
|
|
138
138
|
)
|
|
139
139
|
})
|
|
140
140
|
|
|
141
|
-
it('should handle iframe with url parameter',
|
|
141
|
+
it('should handle iframe with url parameter', () => {
|
|
142
142
|
assert.equal(
|
|
143
143
|
Utils.toHTML(
|
|
144
144
|
'A simple iframe: {{{https://osm.org/?url=https%3A//anotherurl.com}}}'
|
|
@@ -147,7 +147,7 @@ describe('Utils', function () {
|
|
|
147
147
|
)
|
|
148
148
|
})
|
|
149
149
|
|
|
150
|
-
it('should handle iframe with height with px',
|
|
150
|
+
it('should handle iframe with height with px', () => {
|
|
151
151
|
assert.equal(
|
|
152
152
|
Utils.toHTML(
|
|
153
153
|
'A double iframe: {{{https://osm.org/pouet}}}{{{https://osm.org/boudin}}}'
|
|
@@ -156,52 +156,56 @@ describe('Utils', function () {
|
|
|
156
156
|
)
|
|
157
157
|
})
|
|
158
158
|
|
|
159
|
-
it('http link with http link as parameter as variable',
|
|
159
|
+
it('http link with http link as parameter as variable', () => {
|
|
160
160
|
assert.equal(
|
|
161
161
|
Utils.toHTML('A phrase with a [[http://iframeurl.com?to=http://another.com]].'),
|
|
162
162
|
'A phrase with a <a href="http://iframeurl.com?to=http://another.com" target="_blank">http://iframeurl.com?to=http://another.com</a>.'
|
|
163
163
|
)
|
|
164
164
|
})
|
|
165
165
|
|
|
166
|
-
it('simple bullet points',
|
|
166
|
+
it('simple bullet points', () => {
|
|
167
167
|
assert.equal(
|
|
168
168
|
Utils.toHTML('* First point\n* Second point\n* Last point'),
|
|
169
169
|
'<ul><li>First point</li><li>Second point</li><li>Last point</li></ul>'
|
|
170
170
|
)
|
|
171
171
|
})
|
|
172
172
|
|
|
173
|
-
it('bullet points with bold and italic',
|
|
173
|
+
it('bullet points with bold and italic', () => {
|
|
174
174
|
assert.equal(
|
|
175
|
-
Utils.toHTML(
|
|
175
|
+
Utils.toHTML(
|
|
176
|
+
'* First *point*\n* Second **point**\n* Last [[https://here.org|point]]'
|
|
177
|
+
),
|
|
176
178
|
'<ul><li>First <em>point</em></li><li>Second <strong>point</strong></li><li>Last <a href="https://here.org" target="_blank">point</a></li></ul>'
|
|
177
179
|
)
|
|
178
180
|
})
|
|
179
181
|
|
|
180
|
-
it('title followed by bullet points',
|
|
182
|
+
it('title followed by bullet points', () => {
|
|
181
183
|
assert.equal(
|
|
182
|
-
Utils.toHTML(
|
|
184
|
+
Utils.toHTML(
|
|
185
|
+
'## Some title\n* First *point*\n* Second **point**\n* Last [[https://here.org|point]]'
|
|
186
|
+
),
|
|
183
187
|
'<h5>Some title</h5><ul><li>First <em>point</em></li><li>Second <strong>point</strong></li><li>Last <a href="https://here.org" target="_blank">point</a></li></ul>'
|
|
184
188
|
)
|
|
185
189
|
})
|
|
186
190
|
})
|
|
187
191
|
|
|
188
|
-
describe('#escapeHTML',
|
|
189
|
-
it('should escape HTML tags',
|
|
192
|
+
describe('#escapeHTML', () => {
|
|
193
|
+
it('should escape HTML tags', () => {
|
|
190
194
|
assert.equal(Utils.escapeHTML('<span onload="alert(oups)">'), '<span></span>')
|
|
191
195
|
})
|
|
192
196
|
|
|
193
|
-
it('should not escape geo: links',
|
|
197
|
+
it('should not escape geo: links', () => {
|
|
194
198
|
assert.equal(Utils.escapeHTML('<a href="geo:1,2"></a>'), '<a href="geo:1,2"></a>')
|
|
195
199
|
})
|
|
196
200
|
|
|
197
|
-
it('should not escape dir and title attributes',
|
|
201
|
+
it('should not escape dir and title attributes', () => {
|
|
198
202
|
assert.equal(
|
|
199
203
|
Utils.escapeHTML('<a title="Title" dir="rtl"></a>'),
|
|
200
204
|
'<a dir="rtl" title="Title"></a>'
|
|
201
205
|
)
|
|
202
206
|
})
|
|
203
207
|
|
|
204
|
-
it('should not escape video tag with dedicated attributes',
|
|
208
|
+
it('should not escape video tag with dedicated attributes', () => {
|
|
205
209
|
assert.equal(
|
|
206
210
|
Utils.escapeHTML(
|
|
207
211
|
'<video width="100%" height="281" controls><source type="video/mp4" src="movie.mp4"></video>'
|
|
@@ -210,7 +214,7 @@ describe('Utils', function () {
|
|
|
210
214
|
)
|
|
211
215
|
})
|
|
212
216
|
|
|
213
|
-
it('should not escape audio tag with dedicated attributes',
|
|
217
|
+
it('should not escape audio tag with dedicated attributes', () => {
|
|
214
218
|
assert.equal(
|
|
215
219
|
Utils.escapeHTML(
|
|
216
220
|
'<audio controls><source type="audio/ogg" src="horse.ogg"></audio>'
|
|
@@ -219,38 +223,38 @@ describe('Utils', function () {
|
|
|
219
223
|
)
|
|
220
224
|
})
|
|
221
225
|
|
|
222
|
-
it('should not fail with int value',
|
|
226
|
+
it('should not fail with int value', () => {
|
|
223
227
|
assert.equal(Utils.escapeHTML(25), '25')
|
|
224
228
|
})
|
|
225
229
|
|
|
226
|
-
it('should not fail with null value',
|
|
230
|
+
it('should not fail with null value', () => {
|
|
227
231
|
assert.equal(Utils.escapeHTML(null), '')
|
|
228
232
|
})
|
|
229
233
|
})
|
|
230
234
|
|
|
231
|
-
describe('#greedyTemplate',
|
|
232
|
-
it('should replace simple props',
|
|
235
|
+
describe('#greedyTemplate', () => {
|
|
236
|
+
it('should replace simple props', () => {
|
|
233
237
|
assert.equal(
|
|
234
238
|
Utils.greedyTemplate('A phrase with a {variable}.', { variable: 'thing' }),
|
|
235
239
|
'A phrase with a thing.'
|
|
236
240
|
)
|
|
237
241
|
})
|
|
238
242
|
|
|
239
|
-
it('should not fail when missing key',
|
|
243
|
+
it('should not fail when missing key', () => {
|
|
240
244
|
assert.equal(
|
|
241
245
|
Utils.greedyTemplate('A phrase with a {missing}', {}),
|
|
242
246
|
'A phrase with a '
|
|
243
247
|
)
|
|
244
248
|
})
|
|
245
249
|
|
|
246
|
-
it('should process brakets in brakets',
|
|
250
|
+
it('should process brakets in brakets', () => {
|
|
247
251
|
assert.equal(
|
|
248
252
|
Utils.greedyTemplate('A phrase with a {{{variable}}}.', { variable: 'value' }),
|
|
249
253
|
'A phrase with a {{value}}.'
|
|
250
254
|
)
|
|
251
255
|
})
|
|
252
256
|
|
|
253
|
-
it('should not process http links',
|
|
257
|
+
it('should not process http links', () => {
|
|
254
258
|
assert.equal(
|
|
255
259
|
Utils.greedyTemplate('A phrase with a {{{http://iframeurl.com}}}.', {
|
|
256
260
|
'http://iframeurl.com': 'value',
|
|
@@ -259,14 +263,14 @@ describe('Utils', function () {
|
|
|
259
263
|
)
|
|
260
264
|
})
|
|
261
265
|
|
|
262
|
-
it('should not accept dash',
|
|
266
|
+
it('should not accept dash', () => {
|
|
263
267
|
assert.equal(
|
|
264
268
|
Utils.greedyTemplate('A phrase with a {var-iable}.', { 'var-iable': 'value' }),
|
|
265
269
|
'A phrase with a {var-iable}.'
|
|
266
270
|
)
|
|
267
271
|
})
|
|
268
272
|
|
|
269
|
-
it('should accept colon',
|
|
273
|
+
it('should accept colon', () => {
|
|
270
274
|
assert.equal(
|
|
271
275
|
Utils.greedyTemplate('A phrase with a {variable:fr}.', {
|
|
272
276
|
'variable:fr': 'value',
|
|
@@ -275,7 +279,7 @@ describe('Utils', function () {
|
|
|
275
279
|
)
|
|
276
280
|
})
|
|
277
281
|
|
|
278
|
-
it('should accept arobase',
|
|
282
|
+
it('should accept arobase', () => {
|
|
279
283
|
assert.equal(
|
|
280
284
|
Utils.greedyTemplate('A phrase with a {@variable}.', {
|
|
281
285
|
'@variable': 'value',
|
|
@@ -284,7 +288,7 @@ describe('Utils', function () {
|
|
|
284
288
|
)
|
|
285
289
|
})
|
|
286
290
|
|
|
287
|
-
it('should accept space',
|
|
291
|
+
it('should accept space', () => {
|
|
288
292
|
assert.equal(
|
|
289
293
|
Utils.greedyTemplate('A phrase with a {var iable}.', {
|
|
290
294
|
'var iable': 'value',
|
|
@@ -293,7 +297,7 @@ describe('Utils', function () {
|
|
|
293
297
|
)
|
|
294
298
|
})
|
|
295
299
|
|
|
296
|
-
it('should accept non ascii chars',
|
|
300
|
+
it('should accept non ascii chars', () => {
|
|
297
301
|
assert.equal(
|
|
298
302
|
Utils.greedyTemplate('A phrase with a {Accessibilité} and {переменная}.', {
|
|
299
303
|
Accessibilité: 'value',
|
|
@@ -303,7 +307,7 @@ describe('Utils', function () {
|
|
|
303
307
|
)
|
|
304
308
|
})
|
|
305
309
|
|
|
306
|
-
it('should replace even with ignore if key is found',
|
|
310
|
+
it('should replace even with ignore if key is found', () => {
|
|
307
311
|
assert.equal(
|
|
308
312
|
Utils.greedyTemplate(
|
|
309
313
|
'A phrase with a {variable:fr}.',
|
|
@@ -314,21 +318,21 @@ describe('Utils', function () {
|
|
|
314
318
|
)
|
|
315
319
|
})
|
|
316
320
|
|
|
317
|
-
it('should keep string when using ignore if key is not found',
|
|
321
|
+
it('should keep string when using ignore if key is not found', () => {
|
|
318
322
|
assert.equal(
|
|
319
323
|
Utils.greedyTemplate('A phrase with a {variable:fr}.', {}, true),
|
|
320
324
|
'A phrase with a {variable:fr}.'
|
|
321
325
|
)
|
|
322
326
|
})
|
|
323
327
|
|
|
324
|
-
it('should replace nested variables',
|
|
328
|
+
it('should replace nested variables', () => {
|
|
325
329
|
assert.equal(
|
|
326
330
|
Utils.greedyTemplate('A phrase with a {fr.var}.', { fr: { var: 'value' } }),
|
|
327
331
|
'A phrase with a value.'
|
|
328
332
|
)
|
|
329
333
|
})
|
|
330
334
|
|
|
331
|
-
it('should not fail if nested variable is missing',
|
|
335
|
+
it('should not fail if nested variable is missing', () => {
|
|
332
336
|
assert.equal(
|
|
333
337
|
Utils.greedyTemplate('A phrase with a {fr.var.foo}.', {
|
|
334
338
|
fr: { var: 'value' },
|
|
@@ -337,21 +341,21 @@ describe('Utils', function () {
|
|
|
337
341
|
)
|
|
338
342
|
})
|
|
339
343
|
|
|
340
|
-
it('should not fail with nested variables and no data',
|
|
344
|
+
it('should not fail with nested variables and no data', () => {
|
|
341
345
|
assert.equal(
|
|
342
346
|
Utils.greedyTemplate('A phrase with a {fr.var.foo}.', {}),
|
|
343
347
|
'A phrase with a .'
|
|
344
348
|
)
|
|
345
349
|
})
|
|
346
350
|
|
|
347
|
-
it('should handle fallback value if any',
|
|
351
|
+
it('should handle fallback value if any', () => {
|
|
348
352
|
assert.equal(
|
|
349
353
|
Utils.greedyTemplate('A phrase with a {fr.var.bar|"default"}.', {}),
|
|
350
354
|
'A phrase with a default.'
|
|
351
355
|
)
|
|
352
356
|
})
|
|
353
357
|
|
|
354
|
-
it('should handle fallback var if any',
|
|
358
|
+
it('should handle fallback var if any', () => {
|
|
355
359
|
assert.equal(
|
|
356
360
|
Utils.greedyTemplate('A phrase with a {fr.var.bar|fallback}.', {
|
|
357
361
|
fallback: 'default',
|
|
@@ -360,14 +364,14 @@ describe('Utils', function () {
|
|
|
360
364
|
)
|
|
361
365
|
})
|
|
362
366
|
|
|
363
|
-
it('should handle multiple fallbacks',
|
|
367
|
+
it('should handle multiple fallbacks', () => {
|
|
364
368
|
assert.equal(
|
|
365
369
|
Utils.greedyTemplate('A phrase with a {fr.var.bar|try.again|"default"}.', {}),
|
|
366
370
|
'A phrase with a default.'
|
|
367
371
|
)
|
|
368
372
|
})
|
|
369
373
|
|
|
370
|
-
it('should use the first defined value',
|
|
374
|
+
it('should use the first defined value', () => {
|
|
371
375
|
assert.equal(
|
|
372
376
|
Utils.greedyTemplate('A phrase with a {fr.var.bar|try.again|"default"}.', {
|
|
373
377
|
try: { again: 'please' },
|
|
@@ -376,7 +380,7 @@ describe('Utils', function () {
|
|
|
376
380
|
)
|
|
377
381
|
})
|
|
378
382
|
|
|
379
|
-
it('should use the first defined value',
|
|
383
|
+
it('should use the first defined value', () => {
|
|
380
384
|
assert.equal(
|
|
381
385
|
Utils.greedyTemplate('A phrase with a {fr.var.bar|try.again|"default"}.', {
|
|
382
386
|
try: { again: 'again' },
|
|
@@ -386,14 +390,14 @@ describe('Utils', function () {
|
|
|
386
390
|
)
|
|
387
391
|
})
|
|
388
392
|
|
|
389
|
-
it('should support the first example from #820 when translated to final syntax',
|
|
393
|
+
it('should support the first example from #820 when translated to final syntax', () => {
|
|
390
394
|
assert.equal(
|
|
391
395
|
Utils.greedyTemplate('# {name} ({ele|"-"} m ü. M.)', { name: 'Portalet' }),
|
|
392
396
|
'# Portalet (- m ü. M.)'
|
|
393
397
|
)
|
|
394
398
|
})
|
|
395
399
|
|
|
396
|
-
it('should support the first example from #820 when translated to final syntax when no fallback required',
|
|
400
|
+
it('should support the first example from #820 when translated to final syntax when no fallback required', () => {
|
|
397
401
|
assert.equal(
|
|
398
402
|
Utils.greedyTemplate('# {name} ({ele|"-"} m ü. M.)', {
|
|
399
403
|
name: 'Portalet',
|
|
@@ -403,14 +407,14 @@ describe('Utils', function () {
|
|
|
403
407
|
)
|
|
404
408
|
})
|
|
405
409
|
|
|
406
|
-
it('should support white space in fallback',
|
|
410
|
+
it('should support white space in fallback', () => {
|
|
407
411
|
assert.equal(
|
|
408
412
|
Utils.greedyTemplate('A phrase with {var|"white space in the fallback."}', {}),
|
|
409
413
|
'A phrase with white space in the fallback.'
|
|
410
414
|
)
|
|
411
415
|
})
|
|
412
416
|
|
|
413
|
-
it('should support empty string as fallback',
|
|
417
|
+
it('should support empty string as fallback', () => {
|
|
414
418
|
assert.equal(
|
|
415
419
|
Utils.greedyTemplate(
|
|
416
420
|
'A phrase with empty string ("{var|""}") in the fallback.',
|
|
@@ -420,7 +424,7 @@ describe('Utils', function () {
|
|
|
420
424
|
)
|
|
421
425
|
})
|
|
422
426
|
|
|
423
|
-
it('should support e.g. links as fallback',
|
|
427
|
+
it('should support e.g. links as fallback', () => {
|
|
424
428
|
assert.equal(
|
|
425
429
|
Utils.greedyTemplate(
|
|
426
430
|
'A phrase with {var|"[[https://osm.org|link]]"} as fallback.',
|
|
@@ -429,19 +433,29 @@ describe('Utils', function () {
|
|
|
429
433
|
'A phrase with [[https://osm.org|link]] as fallback.'
|
|
430
434
|
)
|
|
431
435
|
})
|
|
436
|
+
|
|
437
|
+
it('should not consider null values', () => {
|
|
438
|
+
assert.equal(
|
|
439
|
+
Utils.greedyTemplate('A phrase with a {foo|fallback}.', {
|
|
440
|
+
foo: null,
|
|
441
|
+
fallback: 'default',
|
|
442
|
+
}),
|
|
443
|
+
'A phrase with a default.'
|
|
444
|
+
)
|
|
445
|
+
})
|
|
432
446
|
})
|
|
433
447
|
|
|
434
|
-
describe('#flattenCoordinates()',
|
|
435
|
-
it('should not alter already flat coords',
|
|
436
|
-
|
|
448
|
+
describe('#flattenCoordinates()', () => {
|
|
449
|
+
it('should not alter already flat coords', () => {
|
|
450
|
+
const coords = [
|
|
437
451
|
[1, 2],
|
|
438
452
|
[3, 4],
|
|
439
453
|
]
|
|
440
454
|
assert.deepEqual(Utils.flattenCoordinates(coords), coords)
|
|
441
455
|
})
|
|
442
456
|
|
|
443
|
-
it('should flatten nested coords',
|
|
444
|
-
|
|
457
|
+
it('should flatten nested coords', () => {
|
|
458
|
+
let coords = [
|
|
445
459
|
[
|
|
446
460
|
[1, 2],
|
|
447
461
|
[3, 4],
|
|
@@ -459,36 +473,143 @@ describe('Utils', function () {
|
|
|
459
473
|
assert.deepEqual(Utils.flattenCoordinates(coords), coords[0][0])
|
|
460
474
|
})
|
|
461
475
|
|
|
462
|
-
it('should not fail on empty coords',
|
|
463
|
-
|
|
476
|
+
it('should not fail on empty coords', () => {
|
|
477
|
+
const coords = []
|
|
464
478
|
assert.deepEqual(Utils.flattenCoordinates(coords), coords)
|
|
465
479
|
})
|
|
466
480
|
})
|
|
467
481
|
|
|
468
|
-
describe('#
|
|
469
|
-
it('should
|
|
482
|
+
describe('#polygonMustBeFlattened', () => {
|
|
483
|
+
it('should return false for simple polygon', () => {
|
|
484
|
+
const coords = [
|
|
485
|
+
[
|
|
486
|
+
[100.0, 0.0],
|
|
487
|
+
[101.0, 0.0],
|
|
488
|
+
[101.0, 1.0],
|
|
489
|
+
[100.0, 1.0],
|
|
490
|
+
[100.0, 0.0],
|
|
491
|
+
],
|
|
492
|
+
]
|
|
493
|
+
assert.notOk(Utils.polygonMustBeFlattened(coords))
|
|
494
|
+
})
|
|
495
|
+
|
|
496
|
+
it('should return false for simple polygon with hole', () => {
|
|
497
|
+
const coords = [
|
|
498
|
+
[
|
|
499
|
+
[100.0, 0.0],
|
|
500
|
+
[101.0, 0.0],
|
|
501
|
+
[101.0, 1.0],
|
|
502
|
+
[100.0, 1.0],
|
|
503
|
+
[100.0, 0.0],
|
|
504
|
+
],
|
|
505
|
+
[
|
|
506
|
+
[100.8, 0.8],
|
|
507
|
+
[100.8, 0.2],
|
|
508
|
+
[100.2, 0.2],
|
|
509
|
+
[100.2, 0.8],
|
|
510
|
+
[100.8, 0.8],
|
|
511
|
+
],
|
|
512
|
+
]
|
|
513
|
+
assert.notOk(Utils.polygonMustBeFlattened(coords))
|
|
514
|
+
})
|
|
515
|
+
|
|
516
|
+
it('should return false for multipolygon', () => {
|
|
517
|
+
const coords = [
|
|
518
|
+
[
|
|
519
|
+
[
|
|
520
|
+
[102.0, 2.0],
|
|
521
|
+
[103.0, 2.0],
|
|
522
|
+
[103.0, 3.0],
|
|
523
|
+
[102.0, 3.0],
|
|
524
|
+
[102.0, 2.0],
|
|
525
|
+
],
|
|
526
|
+
],
|
|
527
|
+
[
|
|
528
|
+
[
|
|
529
|
+
[100.0, 0.0],
|
|
530
|
+
[101.0, 0.0],
|
|
531
|
+
[101.0, 1.0],
|
|
532
|
+
[100.0, 1.0],
|
|
533
|
+
[100.0, 0.0],
|
|
534
|
+
],
|
|
535
|
+
[
|
|
536
|
+
[100.2, 0.2],
|
|
537
|
+
[100.2, 0.8],
|
|
538
|
+
[100.8, 0.8],
|
|
539
|
+
[100.8, 0.2],
|
|
540
|
+
[100.2, 0.2],
|
|
541
|
+
],
|
|
542
|
+
],
|
|
543
|
+
]
|
|
544
|
+
assert.notOk(Utils.polygonMustBeFlattened(coords))
|
|
545
|
+
})
|
|
546
|
+
|
|
547
|
+
it('should return true for false multi polygon', () => {
|
|
548
|
+
const coords = [
|
|
549
|
+
[
|
|
550
|
+
[
|
|
551
|
+
[100.0, 0.0],
|
|
552
|
+
[101.0, 0.0],
|
|
553
|
+
[101.0, 1.0],
|
|
554
|
+
[100.0, 1.0],
|
|
555
|
+
[100.0, 0.0],
|
|
556
|
+
],
|
|
557
|
+
],
|
|
558
|
+
]
|
|
559
|
+
assert.ok(Utils.polygonMustBeFlattened(coords))
|
|
560
|
+
})
|
|
561
|
+
|
|
562
|
+
it('should return true for false multi polygon with hole', () => {
|
|
563
|
+
const coords = [
|
|
564
|
+
[
|
|
565
|
+
[
|
|
566
|
+
[100.0, 0.0],
|
|
567
|
+
[101.0, 0.0],
|
|
568
|
+
[101.0, 1.0],
|
|
569
|
+
[100.0, 1.0],
|
|
570
|
+
[100.0, 0.0],
|
|
571
|
+
],
|
|
572
|
+
[
|
|
573
|
+
[100.8, 0.8],
|
|
574
|
+
[100.8, 0.2],
|
|
575
|
+
[100.2, 0.2],
|
|
576
|
+
[100.2, 0.8],
|
|
577
|
+
[100.8, 0.8],
|
|
578
|
+
],
|
|
579
|
+
],
|
|
580
|
+
]
|
|
581
|
+
assert.ok(Utils.polygonMustBeFlattened(coords))
|
|
582
|
+
})
|
|
583
|
+
|
|
584
|
+
it('should return false for empty coords', () => {
|
|
585
|
+
assert.notOk(Utils.polygonMustBeFlattened([]))
|
|
586
|
+
})
|
|
587
|
+
})
|
|
588
|
+
|
|
589
|
+
describe('#usableOption()', () => {
|
|
590
|
+
it('should consider false', () => {
|
|
470
591
|
assert.ok(Utils.usableOption({ key: false }, 'key'))
|
|
471
592
|
})
|
|
472
593
|
|
|
473
|
-
it('should consider 0',
|
|
594
|
+
it('should consider 0', () => {
|
|
474
595
|
assert.ok(Utils.usableOption({ key: 0 }, 'key'))
|
|
475
596
|
})
|
|
476
597
|
|
|
477
|
-
it('should not consider undefined',
|
|
598
|
+
it('should not consider undefined', () => {
|
|
478
599
|
assert.notOk(Utils.usableOption({}, 'key'))
|
|
479
600
|
})
|
|
480
601
|
|
|
481
|
-
it('should not consider empty string',
|
|
602
|
+
it('should not consider empty string', () => {
|
|
482
603
|
assert.notOk(Utils.usableOption({ key: '' }, 'key'))
|
|
483
604
|
})
|
|
484
605
|
|
|
485
|
-
it('should consider null',
|
|
606
|
+
it('should consider null', () => {
|
|
486
607
|
assert.ok(Utils.usableOption({ key: null }, 'key'))
|
|
487
608
|
})
|
|
488
609
|
})
|
|
489
610
|
|
|
490
|
-
describe('#normalize()',
|
|
491
|
-
it('should remove accents',
|
|
611
|
+
describe('#normalize()', () => {
|
|
612
|
+
it('should remove accents', () => {
|
|
492
613
|
// French é
|
|
493
614
|
assert.equal(Utils.normalize('aéroport'), 'aeroport')
|
|
494
615
|
// American é
|
|
@@ -496,35 +617,37 @@ describe('Utils', function () {
|
|
|
496
617
|
})
|
|
497
618
|
})
|
|
498
619
|
|
|
499
|
-
describe('#sortFeatures()',
|
|
500
|
-
let feat1
|
|
501
|
-
|
|
620
|
+
describe('#sortFeatures()', () => {
|
|
621
|
+
let feat1
|
|
622
|
+
let feat2
|
|
623
|
+
let feat3
|
|
624
|
+
before(() => {
|
|
502
625
|
feat1 = { properties: {} }
|
|
503
626
|
feat2 = { properties: {} }
|
|
504
627
|
feat3 = { properties: {} }
|
|
505
628
|
})
|
|
506
|
-
it('should sort feature from custom key',
|
|
629
|
+
it('should sort feature from custom key', () => {
|
|
507
630
|
feat1.properties.mykey = '13. foo'
|
|
508
631
|
feat2.properties.mykey = '7. foo'
|
|
509
632
|
feat3.properties.mykey = '111. foo'
|
|
510
|
-
|
|
633
|
+
const features = Utils.sortFeatures([feat1, feat2, feat3], 'mykey')
|
|
511
634
|
assert.equal(features[0], feat2)
|
|
512
635
|
assert.equal(features[1], feat1)
|
|
513
636
|
assert.equal(features[2], feat3)
|
|
514
637
|
})
|
|
515
|
-
it('should sort feature from multiple keys',
|
|
638
|
+
it('should sort feature from multiple keys', () => {
|
|
516
639
|
feat1.properties.mykey = '13. foo'
|
|
517
640
|
feat2.properties.mykey = '111. foo'
|
|
518
641
|
feat3.properties.mykey = '111. foo'
|
|
519
642
|
feat1.properties.otherkey = 'C'
|
|
520
643
|
feat2.properties.otherkey = 'B'
|
|
521
644
|
feat3.properties.otherkey = 'A'
|
|
522
|
-
|
|
645
|
+
const features = Utils.sortFeatures([feat1, feat2, feat3], 'mykey,otherkey')
|
|
523
646
|
assert.equal(features[0], feat1)
|
|
524
647
|
assert.equal(features[1], feat3)
|
|
525
648
|
assert.equal(features[2], feat2)
|
|
526
649
|
})
|
|
527
|
-
it('should sort feature from custom key reverse',
|
|
650
|
+
it('should sort feature from custom key reverse', () => {
|
|
528
651
|
feat1.properties.mykey = '13. foo'
|
|
529
652
|
feat2.properties.mykey = '7. foo'
|
|
530
653
|
feat3.properties.mykey = '111. foo'
|
|
@@ -533,36 +656,36 @@ describe('Utils', function () {
|
|
|
533
656
|
assert.equal(features[1], feat1)
|
|
534
657
|
assert.equal(features[2], feat2)
|
|
535
658
|
})
|
|
536
|
-
it('should sort feature from multiple keys with reverse',
|
|
659
|
+
it('should sort feature from multiple keys with reverse', () => {
|
|
537
660
|
feat1.properties.mykey = '13. foo'
|
|
538
661
|
feat2.properties.mykey = '111. foo'
|
|
539
662
|
feat3.properties.mykey = '111. foo'
|
|
540
663
|
feat1.properties.otherkey = 'C'
|
|
541
664
|
feat2.properties.otherkey = 'B'
|
|
542
665
|
feat3.properties.otherkey = 'A'
|
|
543
|
-
|
|
666
|
+
const features = Utils.sortFeatures([feat1, feat2, feat3], 'mykey,-otherkey')
|
|
544
667
|
assert.equal(features[0], feat1)
|
|
545
668
|
assert.equal(features[1], feat2)
|
|
546
669
|
assert.equal(features[2], feat3)
|
|
547
670
|
})
|
|
548
|
-
it('should sort feature with space first',
|
|
671
|
+
it('should sort feature with space first', () => {
|
|
549
672
|
feat1.properties.mykey = '1 foo'
|
|
550
673
|
feat2.properties.mykey = '2 foo'
|
|
551
674
|
feat3.properties.mykey = '1a foo'
|
|
552
|
-
|
|
675
|
+
const features = Utils.sortFeatures([feat1, feat2, feat3], 'mykey')
|
|
553
676
|
assert.equal(features[0], feat1)
|
|
554
677
|
assert.equal(features[1], feat3)
|
|
555
678
|
assert.equal(features[2], feat2)
|
|
556
679
|
})
|
|
557
680
|
})
|
|
558
681
|
|
|
559
|
-
describe('#copyJSON',
|
|
560
|
-
it('should actually copy the JSON',
|
|
561
|
-
|
|
562
|
-
|
|
682
|
+
describe('#copyJSON', () => {
|
|
683
|
+
it('should actually copy the JSON', () => {
|
|
684
|
+
const originalJSON = { some: 'json' }
|
|
685
|
+
const returned = Utils.CopyJSON(originalJSON)
|
|
563
686
|
|
|
564
687
|
// Change the original JSON
|
|
565
|
-
originalJSON
|
|
688
|
+
originalJSON.anotherKey = 'value'
|
|
566
689
|
|
|
567
690
|
// ensure the two aren't the same object
|
|
568
691
|
assert.notEqual(returned, originalJSON)
|
|
@@ -570,9 +693,9 @@ describe('Utils', function () {
|
|
|
570
693
|
})
|
|
571
694
|
})
|
|
572
695
|
|
|
573
|
-
describe('#getImpactsFromSchema()',
|
|
574
|
-
|
|
575
|
-
it('should return an array',
|
|
696
|
+
describe('#getImpactsFromSchema()', () => {
|
|
697
|
+
const getImpactsFromSchema = Utils.getImpactsFromSchema
|
|
698
|
+
it('should return an array', () => {
|
|
576
699
|
expect(getImpactsFromSchema(['foo'], {})).to.be.an('array')
|
|
577
700
|
expect(getImpactsFromSchema(['foo'], { foo: {} })).to.be.an('array')
|
|
578
701
|
expect(getImpactsFromSchema(['foo'], { foo: { impacts: [] } })).to.be.an('array')
|
|
@@ -581,8 +704,8 @@ describe('Utils', function () {
|
|
|
581
704
|
)
|
|
582
705
|
})
|
|
583
706
|
|
|
584
|
-
it('should return a list of unique impacted values',
|
|
585
|
-
|
|
707
|
+
it('should return a list of unique impacted values', () => {
|
|
708
|
+
const schema = {
|
|
586
709
|
foo: { impacts: ['A'] },
|
|
587
710
|
bar: { impacts: ['A', 'B'] },
|
|
588
711
|
baz: { impacts: ['B', 'C'] },
|
|
@@ -596,8 +719,8 @@ describe('Utils', function () {
|
|
|
596
719
|
'C',
|
|
597
720
|
])
|
|
598
721
|
})
|
|
599
|
-
it('should return an empty list if nothing is found',
|
|
600
|
-
|
|
722
|
+
it('should return an empty list if nothing is found', () => {
|
|
723
|
+
const schema = {
|
|
601
724
|
foo: { impacts: ['A'] },
|
|
602
725
|
bar: { impacts: ['A', 'B'] },
|
|
603
726
|
baz: { impacts: ['B', 'C'] },
|
|
@@ -606,15 +729,15 @@ describe('Utils', function () {
|
|
|
606
729
|
assert.deepEqual(getImpactsFromSchema(['bad'], schema), [])
|
|
607
730
|
})
|
|
608
731
|
|
|
609
|
-
it('should return an empty list if the schema key does not exist',
|
|
610
|
-
|
|
732
|
+
it('should return an empty list if the schema key does not exist', () => {
|
|
733
|
+
const schema = {
|
|
611
734
|
foo: { impacts: ['A'] },
|
|
612
735
|
}
|
|
613
736
|
|
|
614
737
|
assert.deepEqual(getImpactsFromSchema(['bad'], schema), [])
|
|
615
738
|
})
|
|
616
|
-
it('should work if the "impacts" key is not defined',
|
|
617
|
-
|
|
739
|
+
it('should work if the "impacts" key is not defined', () => {
|
|
740
|
+
const schema = {
|
|
618
741
|
foo: {},
|
|
619
742
|
bar: { impacts: ['A'] },
|
|
620
743
|
baz: { impacts: ['B'] },
|