File tree 9 files changed +112
-10
lines changed
9 files changed +112
-10
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ website/i18n/*
116
116
.idea
117
117
cmake-build-debug
118
118
.ipynb_checkpoints
119
+ .python-version
119
120
120
121
package.json.lerna_backup
121
122
website /static /css /material.dark.css
Original file line number Diff line number Diff line change 30
30
"build:webpack:cjs" : " webpack --color --config src/config/cjs.config.js" ,
31
31
"build:webpack:umd" : " webpack --color --config src/config/umd.config.js" ,
32
32
"build:webpack" : " npm-run-all build:webpack:cjs build:webpack:umd" ,
33
- "build" : " npm-run-all --silent build:babel build:webpack" ,
33
+ "build" : " npm-run-all --silent build:babel build:webpack:cjs build:webpack:umd " ,
34
34
"test:build" : " cpx \" test/html/*\" dist/umd" ,
35
35
"watch" : " webpack --color --watch --config src/config/d3fc.watch.config.js" ,
36
36
"test:run" : " jest --silent --color 2>&1" ,
Original file line number Diff line number Diff line change 22
22
"build" : " npm-run-all --silent build:babel build:webpack:cjs build:webpack:umd" ,
23
23
"watch" : " webpack --color --watch --config src/config/view.config.js" ,
24
24
"test:build" : " cpx \" test/html/*\" dist/umd && cpx \" test/csv/*\" dist/umd && cpx \" test/css/*\" dist/umd" ,
25
- "test:run" : " jest --silent --color" ,
25
+ "test:run" : " jest --silent --color 2>&1" ,
26
+ "test:unit" : " jest --config=test/js/jest.unit.config.js --color --watch" ,
26
27
"test" : " npm-run-all test:build test:run" ,
27
28
"clean" : " rimraf dist" ,
28
29
"clean:screenshots" : " rimraf \" screenshots/**/*.@(failed|diff).png\" " ,
40
41
"verbose" : true ,
41
42
"testURL" : " http://localhost/" ,
42
43
"transform" : {},
43
- "automock" : false
44
+ "automock" : false ,
45
+ "transform" : {
46
+ ".js$" : " ./test/js/transform.js" ,
47
+ ".html$" : " html-loader-jest"
48
+ },
49
+ "setupFiles" : [
50
+ " ./test/js/beforeEachSpec.js"
51
+ ]
44
52
},
45
53
"repository" : {
46
54
"type" : " git" ,
Original file line number Diff line number Diff line change @@ -138,8 +138,8 @@ class ComputedColumn extends HTMLElement {
138
138
this . state . swap_target = false ;
139
139
140
140
for ( let i = 0 ; i < computation . num_params ; i ++ ) {
141
- this . _input_columns . innerHTML += `<div class="psp-cc-computation__input-column"
142
- data-index="${ i } "
141
+ this . _input_columns . innerHTML += `<div class="psp-cc-computation__input-column"
142
+ data-index="${ i } "
143
143
drop-target>
144
144
<span class="psp-label__requiredType ${ input_type } "></span>
145
145
<span class="psp-label__placeholder">Param ${ i + 1 } </span>
Original file line number Diff line number Diff line change @@ -65,12 +65,13 @@ export class DomElement extends PerspectiveElement {
65
65
66
66
if ( filter ) {
67
67
row . setAttribute ( "filter" , filter ) ;
68
+
68
69
if ( type === "string" ) {
69
- const v = this . _table . view ( { row_pivots : [ name ] , aggregates : { } } ) ;
70
- v . to_json ( ) . then ( json => {
71
- row . choices ( json . slice ( 1 , json . length ) . map ( x => x . __ROW_PATH__ ) ) ;
72
- } ) ;
73
- v . delete ( ) ;
70
+ const view = this . _table . view ( { row_pivots : [ name ] , aggregates : { } } ) ;
71
+ view . to_json ( ) . then ( json => {
72
+ row . choices ( this . _autocomplete_choices ( json ) ) }
73
+ ) ;
74
+ view . delete ( ) ;
74
75
}
75
76
}
76
77
@@ -294,4 +295,11 @@ export class DomElement extends PerspectiveElement {
294
295
this . load ( data ) ;
295
296
}
296
297
}
298
+
299
+ _autocomplete_choices ( json ) {
300
+ return json
301
+ . slice ( 1 , json . length )
302
+ . map ( x => x . __ROW_PATH__ )
303
+ . filter ( x => ( Array . isArray ( x ) ? x . filter ( v => ! ! v ) . length > 0 : ! ! x ) ) ;
304
+ }
297
305
}
Original file line number Diff line number Diff line change
1
+ /******************************************************************************
2
+ *
3
+ * Copyright (c) 2017, the Perspective Authors.
4
+ *
5
+ * This file is part of the Perspective library, distributed under the terms of
6
+ * the Apache License 2.0. The full license can be found in the LICENSE file.
7
+ *
8
+ */
9
+
10
+ global . CustomEvent = ( ) => { } ;
11
+ global . customElements = { define : ( ) => { } } ;
12
+ global . HTMLElement = class {
13
+ getAttribute ( ) { }
14
+ hasAttribute ( ) { }
15
+ removeAttribute ( ) { }
16
+ setAttribute ( ) { }
17
+ } ;
Original file line number Diff line number Diff line change
1
+ /******************************************************************************
2
+ *
3
+ * Copyright (c) 2017, the Perspective Authors.
4
+ *
5
+ * This file is part of the Perspective library, distributed under the terms of
6
+ * the Apache License 2.0. The full license can be found in the LICENSE file.
7
+ *
8
+ */
9
+
10
+ module . exports = {
11
+ roots : [ "unit" ] ,
12
+ verbose : true ,
13
+ testURL : "http://localhost/" ,
14
+ automock : false ,
15
+ transform : {
16
+ ".js$" : "./transform.js" ,
17
+ ".html$" : "html-loader-jest"
18
+ } ,
19
+ setupFiles : [ "./beforeEachSpec.js" ]
20
+ } ;
Original file line number Diff line number Diff line change
1
+ /******************************************************************************
2
+ *
3
+ * Copyright (c) 2017, the Perspective Authors.
4
+ *
5
+ * This file is part of the Perspective library, distributed under the terms of
6
+ * the Apache License 2.0. The full license can be found in the LICENSE file.
7
+ *
8
+ */
9
+
10
+ const config = require ( "../../babel.config.js" ) ;
11
+ config . presets [ 0 ] [ 1 ] . modules = "auto" ;
12
+
13
+ module . exports = require ( "babel-jest" ) . createTransformer ( config ) ;
Original file line number Diff line number Diff line change
1
+ /******************************************************************************
2
+ *
3
+ * Copyright (c) 2018, the Perspective Authors.
4
+ *
5
+ * This file is part of the Perspective library, distributed under the terms of
6
+ * the Apache License 2.0. The full license can be found in the LICENSE file.
7
+ *
8
+ */
9
+
10
+ import { DomElement } from "../../../src/js/viewer/dom_element" ;
11
+
12
+ jest . mock ( "../../../src/less/computed_column.less" , ( ) => jest . fn ( ) ) ;
13
+
14
+ describe ( DomElement , ( ) => {
15
+ describe ( "._autocomplete_choices" , ( ) => {
16
+ let dom_element , json_choices ;
17
+
18
+ beforeEach ( ( ) => {
19
+ dom_element = new DomElement ( ) ;
20
+ json_choices = [
21
+ { __ROW_PATH__ : [ ] , foo : 2 } ,
22
+ { __ROW_PATH__ : [ null ] , foo : 25 } ,
23
+ { __ROW_PATH__ : [ "somestring" ] , foo : 3 } ,
24
+ { __ROW_PATH__ : [ "otherstring" ] , foo : 3 }
25
+ ] ;
26
+ } ) ;
27
+
28
+ test ( "the first value and null values are filtered out" , ( ) => {
29
+ expect ( dom_element . _autocomplete_choices ( json_choices ) ) . toEqual ( [
30
+ [ "somestring" ] ,
31
+ [ "otherstring" ]
32
+ ] ) ;
33
+ } ) ;
34
+ } ) ;
35
+ } ) ;
You can’t perform that action at this time.
0 commit comments