Skip to content

Commit 8e2afad

Browse files
committed
Update tests
1 parent b41f9fa commit 8e2afad

File tree

1 file changed

+18
-52
lines changed

1 file changed

+18
-52
lines changed

packages/jinja/test/templates.test.js

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -122,25 +122,25 @@ const TEST_STRINGS = {
122122
FILTER_OPERATOR_DICTSORT_6: `{% for key, value in numdict | dictsort(by='value', reverse=true) %}{{ key }}:{{ value }},{% endfor %}`,
123123

124124
// Sort filter tests
125-
SORT_BASIC_NUMBERS: `{{ [3, 1, 2] | sort | tojson }}`,
126-
SORT_BASIC_STRINGS: `{{ ['banana', 'Apple', 'cherry'] | sort | tojson }}`,
127-
SORT_REVERSE: `{{ [1, 3, 2] | sort(reverse=true) | tojson }}`,
128-
SORT_CASE_SENSITIVE: `{{ ['banana', 'Apple', 'cherry'] | sort(case_sensitive=true) | tojson }}`,
129-
SORT_CASE_INSENSITIVE: `{{ ['banana', 'Apple', 'cherry'] | sort(case_sensitive=false) | tojson }}`,
130-
SORT_ATTRIBUTE_SIMPLE: `{{ users | sort(attribute='name') | map(attribute='name') | list | tojson }}`,
131-
SORT_ATTRIBUTE_REVERSE: `{{ users | sort(attribute='age', reverse=true) | map(attribute='age') | list | tojson }}`,
132-
SORT_ATTRIBUTE_DOT_NOTATION: `{{ items | sort(attribute='details.priority') | map(attribute='details.priority') | list | tojson }}`,
133-
SORT_CHAINED: `{{ users | sort(attribute='name') | sort(reverse=true, attribute='age') | map(attribute='name') | list | tojson }}`,
134-
SORT_STABLE: `{{ items | sort(attribute='category') | map(attribute='name') | list | tojson }}`,
125+
SORT_BASIC_NUMBERS: `{{ [3, 1, 2] | sort }}`,
126+
SORT_BASIC_STRINGS: `{{ ['banana', 'Apple', 'cherry'] | sort }}`,
127+
SORT_REVERSE: `{{ [1, 3, 2] | sort(reverse=true) }}`,
128+
SORT_CASE_SENSITIVE: `{{ ['banana', 'Apple', 'cherry'] | sort(case_sensitive=true) }}`,
129+
SORT_CASE_INSENSITIVE: `{{ ['banana', 'Apple', 'cherry'] | sort(case_sensitive=false) }}`,
130+
SORT_ATTRIBUTE_SIMPLE: `{{ users | sort(attribute='name') | map(attribute='name') | list }}`,
131+
SORT_ATTRIBUTE_REVERSE: `{{ users | sort(attribute='age', reverse=true) | map(attribute='age') | list }}`,
132+
SORT_ATTRIBUTE_DOT_NOTATION: `{{ items | sort(attribute='details.priority') | map(attribute='details.priority') | list }}`,
133+
SORT_CHAINED: `{{ users | sort(attribute='name') | sort(reverse=true, attribute='age') | map(attribute='name') | list }}`,
134+
SORT_STABLE: `{{ items | sort(attribute='category') | map(attribute='name') | list }}`,
135135
// Sort with positional arguments
136-
SORT_POSITIONAL_REVERSE: `{{ [1, 3, 2] | sort(true) | tojson }}`,
137-
SORT_POSITIONAL_REVERSE_CASE: `{{ ['banana', 'Apple', 'cherry'] | sort(false, true) | tojson }}`,
138-
SORT_POSITIONAL_ALL: `{{ users | sort(false, false, 'name') | map(attribute='name') | list | tojson }}`,
139-
SORT_POSITIONAL_MIXED: `{{ users | sort(true, attribute='age') | map(attribute='age') | list | tojson }}`,
136+
SORT_POSITIONAL_REVERSE: `{{ [1, 3, 2] | sort(true) }}`,
137+
SORT_POSITIONAL_REVERSE_CASE: `{{ ['banana', 'Apple', 'cherry'] | sort(false, true) }}`,
138+
SORT_POSITIONAL_ALL: `{{ users | sort(false, false, 'name') | map(attribute='name') | list }}`,
139+
SORT_POSITIONAL_MIXED: `{{ users | sort(true, attribute='age') | map(attribute='age') | list }}`,
140140
// Edge cases for sort
141-
SORT_NULL_VALUES: `{{ [None, None] | sort | tojson }}`,
142-
SORT_UNDEFINED_VALUES: `{{ [a, b, c] | sort | tojson }}`,
143-
SORT_MIXED_BOOL_NUM: `{{ [0, true, false, 1, 0.5] | sort | tojson }}`,
141+
SORT_NULL_VALUES: `{{ [None, None] | sort }}`,
142+
SORT_UNDEFINED_VALUES: `{{ [a, b, c] | sort }}`,
143+
SORT_MIXED_BOOL_NUM: `{{ [0, true, false, 1, 0.5] | sort }}`,
144144

145145
// Filter statements
146146
FILTER_STATEMENTS: `{% filter upper %}text{% endfilter %}`,
@@ -2591,8 +2591,6 @@ const TEST_PARSED = {
25912591
{ value: "]", type: "CloseSquareBracket" },
25922592
{ value: "|", type: "Pipe" },
25932593
{ value: "sort", type: "Identifier" },
2594-
{ value: "|", type: "Pipe" },
2595-
{ value: "tojson", type: "Identifier" },
25962594
{ value: "}}", type: "CloseExpression" },
25972595
],
25982596
SORT_BASIC_STRINGS: [
@@ -2606,8 +2604,6 @@ const TEST_PARSED = {
26062604
{ value: "]", type: "CloseSquareBracket" },
26072605
{ value: "|", type: "Pipe" },
26082606
{ value: "sort", type: "Identifier" },
2609-
{ value: "|", type: "Pipe" },
2610-
{ value: "tojson", type: "Identifier" },
26112607
{ value: "}}", type: "CloseExpression" },
26122608
],
26132609
SORT_REVERSE: [
@@ -2626,8 +2622,6 @@ const TEST_PARSED = {
26262622
{ value: "=", type: "Equals" },
26272623
{ value: "true", type: "Identifier" },
26282624
{ value: ")", type: "CloseParen" },
2629-
{ value: "|", type: "Pipe" },
2630-
{ value: "tojson", type: "Identifier" },
26312625
{ value: "}}", type: "CloseExpression" },
26322626
],
26332627
SORT_CASE_SENSITIVE: [
@@ -2646,8 +2640,6 @@ const TEST_PARSED = {
26462640
{ value: "=", type: "Equals" },
26472641
{ value: "true", type: "Identifier" },
26482642
{ value: ")", type: "CloseParen" },
2649-
{ value: "|", type: "Pipe" },
2650-
{ value: "tojson", type: "Identifier" },
26512643
{ value: "}}", type: "CloseExpression" },
26522644
],
26532645
SORT_CASE_INSENSITIVE: [
@@ -2666,8 +2658,6 @@ const TEST_PARSED = {
26662658
{ value: "=", type: "Equals" },
26672659
{ value: "false", type: "Identifier" },
26682660
{ value: ")", type: "CloseParen" },
2669-
{ value: "|", type: "Pipe" },
2670-
{ value: "tojson", type: "Identifier" },
26712661
{ value: "}}", type: "CloseExpression" },
26722662
],
26732663
SORT_ATTRIBUTE_SIMPLE: [
@@ -2689,8 +2679,6 @@ const TEST_PARSED = {
26892679
{ value: ")", type: "CloseParen" },
26902680
{ value: "|", type: "Pipe" },
26912681
{ value: "list", type: "Identifier" },
2692-
{ value: "|", type: "Pipe" },
2693-
{ value: "tojson", type: "Identifier" },
26942682
{ value: "}}", type: "CloseExpression" },
26952683
],
26962684
SORT_ATTRIBUTE_REVERSE: [
@@ -2716,8 +2704,6 @@ const TEST_PARSED = {
27162704
{ value: ")", type: "CloseParen" },
27172705
{ value: "|", type: "Pipe" },
27182706
{ value: "list", type: "Identifier" },
2719-
{ value: "|", type: "Pipe" },
2720-
{ value: "tojson", type: "Identifier" },
27212707
{ value: "}}", type: "CloseExpression" },
27222708
],
27232709
SORT_ATTRIBUTE_DOT_NOTATION: [
@@ -2739,8 +2725,6 @@ const TEST_PARSED = {
27392725
{ value: ")", type: "CloseParen" },
27402726
{ value: "|", type: "Pipe" },
27412727
{ value: "list", type: "Identifier" },
2742-
{ value: "|", type: "Pipe" },
2743-
{ value: "tojson", type: "Identifier" },
27442728
{ value: "}}", type: "CloseExpression" },
27452729
],
27462730
SORT_CHAINED: [
@@ -2773,8 +2757,6 @@ const TEST_PARSED = {
27732757
{ value: ")", type: "CloseParen" },
27742758
{ value: "|", type: "Pipe" },
27752759
{ value: "list", type: "Identifier" },
2776-
{ value: "|", type: "Pipe" },
2777-
{ value: "tojson", type: "Identifier" },
27782760
{ value: "}}", type: "CloseExpression" },
27792761
],
27802762
SORT_STABLE: [
@@ -2796,8 +2778,6 @@ const TEST_PARSED = {
27962778
{ value: ")", type: "CloseParen" },
27972779
{ value: "|", type: "Pipe" },
27982780
{ value: "list", type: "Identifier" },
2799-
{ value: "|", type: "Pipe" },
2800-
{ value: "tojson", type: "Identifier" },
28012781
{ value: "}}", type: "CloseExpression" },
28022782
],
28032783
// Sort with positional arguments
@@ -2815,8 +2795,6 @@ const TEST_PARSED = {
28152795
{ value: "(", type: "OpenParen" },
28162796
{ value: "true", type: "Identifier" },
28172797
{ value: ")", type: "CloseParen" },
2818-
{ value: "|", type: "Pipe" },
2819-
{ value: "tojson", type: "Identifier" },
28202798
{ value: "}}", type: "CloseExpression" },
28212799
],
28222800
SORT_POSITIONAL_REVERSE_CASE: [
@@ -2835,8 +2813,6 @@ const TEST_PARSED = {
28352813
{ value: ",", type: "Comma" },
28362814
{ value: "true", type: "Identifier" },
28372815
{ value: ")", type: "CloseParen" },
2838-
{ value: "|", type: "Pipe" },
2839-
{ value: "tojson", type: "Identifier" },
28402816
{ value: "}}", type: "CloseExpression" },
28412817
],
28422818
SORT_POSITIONAL_ALL: [
@@ -2860,8 +2836,6 @@ const TEST_PARSED = {
28602836
{ value: ")", type: "CloseParen" },
28612837
{ value: "|", type: "Pipe" },
28622838
{ value: "list", type: "Identifier" },
2863-
{ value: "|", type: "Pipe" },
2864-
{ value: "tojson", type: "Identifier" },
28652839
{ value: "}}", type: "CloseExpression" },
28662840
],
28672841
SORT_POSITIONAL_MIXED: [
@@ -2885,8 +2859,6 @@ const TEST_PARSED = {
28852859
{ value: ")", type: "CloseParen" },
28862860
{ value: "|", type: "Pipe" },
28872861
{ value: "list", type: "Identifier" },
2888-
{ value: "|", type: "Pipe" },
2889-
{ value: "tojson", type: "Identifier" },
28902862
{ value: "}}", type: "CloseExpression" },
28912863
],
28922864
// Edge cases for sort
@@ -2899,8 +2871,6 @@ const TEST_PARSED = {
28992871
{ value: "]", type: "CloseSquareBracket" },
29002872
{ value: "|", type: "Pipe" },
29012873
{ value: "sort", type: "Identifier" },
2902-
{ value: "|", type: "Pipe" },
2903-
{ value: "tojson", type: "Identifier" },
29042874
{ value: "}}", type: "CloseExpression" },
29052875
],
29062876
SORT_UNDEFINED_VALUES: [
@@ -2914,8 +2884,6 @@ const TEST_PARSED = {
29142884
{ value: "]", type: "CloseSquareBracket" },
29152885
{ value: "|", type: "Pipe" },
29162886
{ value: "sort", type: "Identifier" },
2917-
{ value: "|", type: "Pipe" },
2918-
{ value: "tojson", type: "Identifier" },
29192887
{ value: "}}", type: "CloseExpression" },
29202888
],
29212889
SORT_MIXED_BOOL_NUM: [
@@ -2933,8 +2901,6 @@ const TEST_PARSED = {
29332901
{ value: "]", type: "CloseSquareBracket" },
29342902
{ value: "|", type: "Pipe" },
29352903
{ value: "sort", type: "Identifier" },
2936-
{ value: "|", type: "Pipe" },
2937-
{ value: "tojson", type: "Identifier" },
29382904
{ value: "}}", type: "CloseExpression" },
29392905
],
29402906

@@ -4892,7 +4858,7 @@ const EXPECTED_OUTPUTS = {
48924858
SORT_POSITIONAL_MIXED: `[35, 30, 25]`,
48934859
// Edge cases for sort
48944860
SORT_NULL_VALUES: `[null, null]`,
4895-
SORT_UNDEFINED_VALUES: `[null, null, null]`,
4861+
SORT_UNDEFINED_VALUES: `[undefined, undefined, undefined]`,
48964862
SORT_MIXED_BOOL_NUM: `[0, false, 0.5, true, 1]`,
48974863

48984864
// Filter statements

0 commit comments

Comments
 (0)