1
1
var QueryLogic = require ( "../can-query-logic" ) ;
2
2
var QUnit = require ( "steal-qunit" ) ;
3
3
var canReflect = require ( "can-reflect" ) ;
4
+ var canSymbol = require ( "can-symbol" ) ;
4
5
5
6
QUnit . module ( "can-query-logic special comparison logic" ) ;
6
7
@@ -34,6 +35,10 @@ QUnit.test("where to filter", function(){
34
35
} , "got intersection" ) ;
35
36
} ) ;
36
37
38
+ var stringIncludes = function ( strA , strB ) {
39
+ return strA . indexOf ( strB ) >= 0 ;
40
+ } ;
41
+
37
42
QUnit . test ( "Searchable string" , function ( ) {
38
43
// Create a set type that is used to do comparisons.
39
44
function SearchableStringSet ( value ) {
@@ -43,7 +48,7 @@ QUnit.test("Searchable string", function(){
43
48
canReflect . assignSymbols ( SearchableStringSet . prototype , {
44
49
// Returns if the name on a todo is actually a member of the set.
45
50
"can.isMember" : function ( value ) {
46
- return value . includes ( this . value ) ;
51
+ return stringIncludes ( value , this . value ) ;
47
52
} ,
48
53
"can.serialize" : function ( ) {
49
54
return this . value ;
@@ -53,31 +58,31 @@ QUnit.test("Searchable string", function(){
53
58
// Specify how to do the fundamental set comparisons.
54
59
QueryLogic . defineComparison ( SearchableStringSet , SearchableStringSet , {
55
60
union : function ( searchA , searchB ) {
56
- if ( searchA . value . includes ( searchB . value ) ) {
61
+ if ( stringIncludes ( searchA . value , searchB . value ) ) {
57
62
return searchB ;
58
63
}
59
- if ( searchB . value . includes ( searchA . value ) ) {
64
+ if ( stringIncludes ( searchB . value , searchA . value ) ) {
60
65
return searchA ;
61
66
}
62
67
return new QueryLogic . ValuesOr ( [ searchA , searchB ] ) ;
63
68
} ,
64
69
// a aa
65
70
intersection : function ( searchA , searchB ) {
66
- if ( searchA . value . includes ( searchB . value ) ) {
71
+ if ( stringIncludes ( searchA . value , searchB . value ) ) {
67
72
return searchA ;
68
73
}
69
- if ( searchB . value . includes ( searchA . value ) ) {
74
+ if ( stringIncludes ( searchB . value , searchA . value ) ) {
70
75
return searchB ;
71
76
}
72
77
return QueryLogic . UNDEFINABLE ;
73
78
} ,
74
79
difference : function ( searchA , searchB ) {
75
80
// if a is a subset
76
- if ( searchA . value . includes ( searchB . value ) ) {
81
+ if ( stringIncludes ( searchA . value , searchB . value ) ) {
77
82
return QueryLogic . EMPTY ;
78
83
}
79
84
// a is a superset
80
- if ( searchB . value . includes ( searchA . value ) ) {
85
+ if ( stringIncludes ( searchB . value , searchA . value ) ) {
81
86
return QueryLogic . UNDEFINABLE ;
82
87
}
83
88
// foo \ bar
@@ -100,7 +105,7 @@ QUnit.test("Searchable string", function(){
100
105
101
106
}
102
107
103
- SearchableString [ Symbol . for ( "can.SetType" ) ] = SearchableStringSet ;
108
+ SearchableString [ canSymbol . for ( "can.SetType" ) ] = SearchableStringSet ;
104
109
105
110
var todoQueryLogic = new QueryLogic ( {
106
111
keys : {
0 commit comments