@@ -105,7 +105,7 @@ module.exports = () => {
105105 } ) ;
106106
107107 describe ( 'oneOf' , ( ) => {
108- it ( 'should return a single entity with the provided id' , async ( ) => {
108+ it ( 'should return entities with the provided id' , async ( ) => {
109109 const queryBuilder = new QueryBuilder ( ) ;
110110 queryBuilder . where ( 'id' ) . oneOf ( '1' , 2 ) ;
111111 queryBuilder . orderBy ( 'id' , 'asc' ) ;
@@ -119,42 +119,80 @@ module.exports = () => {
119119 } ) ;
120120
121121 describe ( 'startsWith' , ( ) => {
122- it ( 'should return only entities starting with "Log "' , async ( ) => {
122+ it ( 'should return only entities starting with "First "' , async ( ) => {
123123 const queryBuilder = new QueryBuilder ( ) ;
124- queryBuilder . where ( 'title' ) . startsWith ( 'Log ' ) ;
124+ queryBuilder . where ( 'title' ) . startsWith ( 'First ' ) ;
125125 queryBuilder . orderBy ( 'id' , 'asc' ) ;
126126
127127 const result = await LogRepository . findAll ( queryBuilder ) ;
128128 expect ( result ) . to . not . be . null ;
129+ result . forEach ( ( { title } ) => {
130+ expect ( title . startsWith ( 'First' ) ) . to . be . true ;
131+ } ) ;
129132 } ) ;
130133
131- it ( 'should return only entities not starting with "Log "' , async ( ) => {
134+ it ( 'should return only entities not starting with "First "' , async ( ) => {
132135 const queryBuilder = new QueryBuilder ( ) ;
133- queryBuilder . where ( 'title' ) . not ( ) . startsWith ( 'Log ' ) ;
136+ queryBuilder . where ( 'title' ) . not ( ) . startsWith ( 'First ' ) ;
134137 queryBuilder . orderBy ( 'id' , 'asc' ) ;
135138
136139 const result = await LogRepository . findAll ( queryBuilder ) ;
137140 expect ( result ) . to . not . be . null ;
141+ result . forEach ( ( { title } ) => {
142+ expect ( title . startsWith ( 'First' ) ) . to . be . false ;
143+ } ) ;
138144 } ) ;
139145 } ) ;
140146
141147 describe ( 'endsWith' , ( ) => {
142- it ( 'should return only entities ending with "log"' , async ( ) => {
148+ it ( 'should return only entities ending with "entry"' , async ( ) => {
149+ const queryBuilder = new QueryBuilder ( ) ;
150+ queryBuilder . where ( 'title' ) . endsWith ( 'entry' ) ;
151+ queryBuilder . orderBy ( 'id' , 'asc' ) ;
152+
153+ const result = await LogRepository . findAll ( queryBuilder ) ;
154+ expect ( result ) . to . not . be . null ;
155+ result . forEach ( ( { title } ) => {
156+ expect ( title . endsWith ( 'entry' ) ) . to . be . true ;
157+ } ) ;
158+ } ) ;
159+
160+ it ( 'should return only entities not ending with "entry"' , async ( ) => {
161+ const queryBuilder = new QueryBuilder ( ) ;
162+ queryBuilder . where ( 'title' ) . not ( ) . endsWith ( 'entry' ) ;
163+ queryBuilder . orderBy ( 'id' , 'asc' ) ;
164+
165+ const result = await LogRepository . findAll ( queryBuilder ) ;
166+ expect ( result ) . to . not . be . null ;
167+ result . forEach ( ( { title } ) => {
168+ expect ( title . endsWith ( 'entry' ) ) . to . be . false ;
169+ } ) ;
170+ } ) ;
171+ } ) ;
172+
173+ describe ( 'substring' , ( ) => {
174+ it ( 'should return only entities containing "entr"' , async ( ) => {
143175 const queryBuilder = new QueryBuilder ( ) ;
144- queryBuilder . where ( 'title' ) . endsWith ( 'log ') ;
176+ queryBuilder . where ( 'title' ) . substring ( 'entr ') ;
145177 queryBuilder . orderBy ( 'id' , 'asc' ) ;
146178
147179 const result = await LogRepository . findAll ( queryBuilder ) ;
148180 expect ( result ) . to . not . be . null ;
181+ result . forEach ( ( { title } ) => {
182+ expect ( title . includes ( 'entr' ) ) . to . be . true ;
183+ } ) ;
149184 } ) ;
150185
151- it ( 'should return only entities not ending with "log "' , async ( ) => {
186+ it ( 'should return only entities not containing "og "' , async ( ) => {
152187 const queryBuilder = new QueryBuilder ( ) ;
153- queryBuilder . where ( 'title' ) . not ( ) . endsWith ( 'log ') ;
188+ queryBuilder . where ( 'title' ) . not ( ) . substring ( 'entr ') ;
154189 queryBuilder . orderBy ( 'id' , 'asc' ) ;
155190
156191 const result = await LogRepository . findAll ( queryBuilder ) ;
157192 expect ( result ) . to . not . be . null ;
193+ result . forEach ( ( { title } ) => {
194+ expect ( title . includes ( 'entr' ) ) . to . be . false ;
195+ } ) ;
158196 } ) ;
159197 } ) ;
160198 } ) ;
0 commit comments