Skip to content

Commit

Permalink
Fill out, polish the rule spec a little more.
Browse files Browse the repository at this point in the history
Drop use of startsWith in favor of indexOf for PhantomJS testing.
  • Loading branch information
jmchilton committed Jul 26, 2018
1 parent 6e8a7fd commit 42ddfbd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/galaxy/scripts/mvc/rules/rule-definitions.js
Expand Up @@ -167,7 +167,7 @@ const RULES = {
apply: (rule, data, sources, columns) => {
const ruleValue = rule.value;
let newRow;
if (ruleValue.startsWith("identifier")) {
if (ruleValue.indexOf("identifier") == 0) {
const identifierIndex = parseInt(ruleValue.substring("identifier".length));
newRow = (row, index) => {
const newRow = row.slice();
Expand Down
21 changes: 21 additions & 0 deletions test/base/data/rules_dsl_spec.yml
Expand Up @@ -325,6 +325,7 @@
final:
data: [["20", "dog"], ["30", "cat"]]
sources: [4, 5]

- rules:
- type: add_filter_compare
target_column: 0
Expand All @@ -336,6 +337,7 @@
final:
data: [["13", "rat"], ["20", "dog"], ["30", "cat"]]
sources: [3, 4, 5]

- rules:
- type: sort
numeric: false
Expand All @@ -346,6 +348,7 @@
final:
data: [["bark", "dog"], ["meow", "cat"], ["moo", "cow"]]
sources: [3, 2, 1]

- rules:
- type: sort
numeric: false
Expand All @@ -356,6 +359,7 @@
final:
data: [["meow", "cat"], ["moo", "cow"], ["bark", "dog"]]
sources: [2, 1, 3]

- rules:
- type: sort
numeric: false
Expand All @@ -366,6 +370,7 @@
final:
data: [["bark", "Dog"], ["meow", "cat"], ["moo", "cow"]]
sources: [3, 2, 1]

- rules:
- type: swap_columns
target_column_0: 0
Expand All @@ -376,6 +381,7 @@
final:
data: [["cow", "moo"], ["cat", "meow"], ["Dog", "bark"]]
sources: [1, 2, 3]

- rules:
- type: split_columns
target_columns_0: [0]
Expand All @@ -386,28 +392,43 @@
final:
data: [["moo", "A"], ["cow", "A"], ["meow", "B"], ["cat", "B"], ["bark", "C"], ["Dog", "C"]]
sources: [1, 1, 2, 2, 3, 3]

- rules:
- type: add_column_metadata
value: identifier0
initial:
data: [["moo"], ["meow"], ["bark"]]
sources: [{"identifiers": ["cow"]}, {"identifiers": ["cat"]}, {"identifiers": ["dog"]}]
final:
data: [["moo", "cow"], ["meow", "cat"], ["bark", "dog"]]

- rules:
- type: invalid_rule_type
error: true

- rules:
- type: add_filter_compare
target_column: 0
value: 13
compare_type: invalid_compare_type
error: true

- rules:
- type: add_column_concatenate
target_column: 0
error: true

- rules:
- type: add_column_basename
target_column_0: 0
error: true

- rules:
- type: add_column_regex
target_column: 0
regex: '(o)+'
error: true

- rules:
- type: add_column_regex
target_column: 0
Expand Down

0 comments on commit 42ddfbd

Please sign in to comment.