1- import { afterAll , beforeAll , describe , expect , test } from "@jest/globals" ;
21import { LokiJsCollectionProvider , LokiJsConnection } from "../src" ;
32
43const connection = LokiJsConnection . inMemory ( ) ;
@@ -22,8 +21,8 @@ describe("DatabaseCollection", () => {
2221 const entry = { id : "test" , name : "testtest" } ;
2322
2423 const createdEntry = await db . create ( entry ) ;
25- expect ( createdEntry . id ) . toEqual ( entry . id ) ;
26- expect ( createdEntry . name ) . toEqual ( entry . name ) ;
24+ expect ( createdEntry . id ) . toBe ( entry . id ) ;
25+ expect ( createdEntry . name ) . toBe ( entry . name ) ;
2726
2827 await db . create ( { id : "test2" , name : "asd" } ) ;
2928
@@ -32,10 +31,10 @@ describe("DatabaseCollection", () => {
3231
3332 const queriedEntries = await db . find ( { id : { $eq : "test" } } ) ;
3433 expect ( queriedEntries ) . toHaveLength ( 1 ) ;
35- expect ( queriedEntries [ 0 ] . name ) . toEqual ( entry . name ) ;
34+ expect ( queriedEntries [ 0 ] . name ) . toBe ( entry . name ) ;
3635
3736 const queriedEntry = await db . findOne ( { id : { $eq : "test" } } ) ;
38- expect ( queriedEntry . name ) . toEqual ( entry . name ) ;
37+ expect ( queriedEntry . name ) . toBe ( entry . name ) ;
3938 } ) ;
4039
4140 test ( "should query elements" , async function ( ) {
@@ -92,9 +91,9 @@ describe("DatabaseCollection", () => {
9291 await db . create ( { id : "test2" , value : "test2" } ) ;
9392
9493 const value = await db . findOne ( { id : "test" } ) ;
95- expect ( value ) . not . toBeUndefined ( ) ;
96- expect ( value . value ) . not . toBeUndefined ( ) ;
97- expect ( value . value ) . toEqual ( "test" ) ;
94+ expect ( value ) . toBeDefined ( ) ;
95+ expect ( value . value ) . toBeDefined ( ) ;
96+ expect ( value . value ) . toBe ( "test" ) ;
9897 } ) ;
9998
10099 test ( "should update a value" , async function ( ) {
@@ -105,45 +104,45 @@ describe("DatabaseCollection", () => {
105104 await db . update ( value , { id : "test" , value : "test" } ) ;
106105
107106 const queriedValue = await db . findOne ( { id : "test" } ) ;
108- expect ( queriedValue ) . not . toBeUndefined ( ) ;
109- expect ( queriedValue . value ) . not . toBeUndefined ( ) ;
110- expect ( queriedValue . value ) . toEqual ( "test" ) ;
107+ expect ( queriedValue ) . toBeDefined ( ) ;
108+ expect ( queriedValue . value ) . toBeDefined ( ) ;
109+ expect ( queriedValue . value ) . toBe ( "test" ) ;
111110 } ) ;
112111
113112 test ( "should get the count of objects" , async function ( ) {
114113 const db = await getRandomCollection ( ) ;
115114
116115 let count = await db . count ( ) ;
117- expect ( count ) . toStrictEqual ( 0 ) ;
116+ expect ( count ) . toBe ( 0 ) ;
118117
119118 await db . create ( { id : "test" , value : "a-string" } ) ;
120119 await db . create ( { id : "test" , value : "a-string" } ) ;
121120 await db . create ( { id : "test" , value : "another-string" } ) ;
122121
123122 count = await db . count ( ) ;
124- expect ( count ) . toStrictEqual ( 3 ) ;
123+ expect ( count ) . toBe ( 3 ) ;
125124
126125 count = await db . count ( { value : "a-string" } ) ;
127- expect ( count ) . toStrictEqual ( 2 ) ;
126+ expect ( count ) . toBe ( 2 ) ;
128127 } ) ;
129128
130129 test ( "should check if objects exist" , async function ( ) {
131130 const db = await getRandomCollection ( ) ;
132131
133132 let exists = await db . exists ( { } ) ;
134- expect ( exists ) . toStrictEqual ( false ) ;
133+ expect ( exists ) . toBe ( false ) ;
135134
136135 await db . create ( { id : "test" , value : "a-string" } ) ;
137136 await db . create ( { id : "test" , value : "a-string" } ) ;
138137
139138 exists = await db . exists ( ) ;
140- expect ( exists ) . toStrictEqual ( true ) ;
139+ expect ( exists ) . toBe ( true ) ;
141140
142141 exists = await db . exists ( { value : "a-string" } ) ;
143- expect ( exists ) . toStrictEqual ( true ) ;
142+ expect ( exists ) . toBe ( true ) ;
144143
145144 exists = await db . exists ( { value : "another-string" } ) ;
146- expect ( exists ) . toStrictEqual ( false ) ;
145+ expect ( exists ) . toBe ( false ) ;
147146 } ) ;
148147
149148 test ( "should query with paging" , async ( ) => {
@@ -158,8 +157,8 @@ describe("DatabaseCollection", () => {
158157 const find2 = await db . find ( undefined , { skip : 1 , limit : 1 } ) ;
159158 expect ( find2 ) . toHaveLength ( 1 ) ;
160159
161- expect ( find1 [ 0 ] . id ) . not . toEqual ( find2 [ 0 ] . id ) ;
162- expect ( find1 [ 0 ] . value ) . not . toEqual ( find2 [ 0 ] . value ) ;
160+ expect ( find1 [ 0 ] . id ) . not . toBe ( find2 [ 0 ] . id ) ;
161+ expect ( find1 [ 0 ] . value ) . not . toBe ( find2 [ 0 ] . value ) ;
163162 } ) ;
164163
165164 test ( "should sort ascending" , async ( ) => {
@@ -171,8 +170,8 @@ describe("DatabaseCollection", () => {
171170 const find = await db . find ( undefined , undefined , { sortBy : "value" , sortOrder : "asc" } ) ;
172171 expect ( find ) . toHaveLength ( 2 ) ;
173172
174- expect ( find [ 0 ] . id ) . toEqual ( "id1" ) ;
175- expect ( find [ 1 ] . id ) . toEqual ( "id2" ) ;
173+ expect ( find [ 0 ] . id ) . toBe ( "id1" ) ;
174+ expect ( find [ 1 ] . id ) . toBe ( "id2" ) ;
176175 } ) ;
177176
178177 test ( "should sort descending" , async ( ) => {
@@ -184,8 +183,8 @@ describe("DatabaseCollection", () => {
184183 const find = await db . find ( undefined , undefined , { sortBy : "value" , sortOrder : "desc" } ) ;
185184 expect ( find ) . toHaveLength ( 2 ) ;
186185
187- expect ( find [ 0 ] . id ) . toEqual ( "id2" ) ;
188- expect ( find [ 1 ] . id ) . toEqual ( "id1" ) ;
186+ expect ( find [ 0 ] . id ) . toBe ( "id2" ) ;
187+ expect ( find [ 1 ] . id ) . toBe ( "id1" ) ;
189188 } ) ;
190189
191190 test ( "should query with paging and sorting ascending" , async ( ) => {
@@ -196,11 +195,11 @@ describe("DatabaseCollection", () => {
196195
197196 const find1 = await db . find ( undefined , { skip : 0 , limit : 1 } , { sortBy : "value" , sortOrder : "asc" } ) ;
198197 expect ( find1 ) . toHaveLength ( 1 ) ;
199- expect ( find1 [ 0 ] . id ) . toEqual ( "id1" ) ;
198+ expect ( find1 [ 0 ] . id ) . toBe ( "id1" ) ;
200199
201200 const find2 = await db . find ( undefined , { skip : 1 , limit : 1 } , { sortBy : "value" , sortOrder : "asc" } ) ;
202201 expect ( find2 ) . toHaveLength ( 1 ) ;
203- expect ( find2 [ 0 ] . id ) . toEqual ( "id2" ) ;
202+ expect ( find2 [ 0 ] . id ) . toBe ( "id2" ) ;
204203 } ) ;
205204
206205 test ( "should query with paging and sorting descending" , async ( ) => {
@@ -211,11 +210,11 @@ describe("DatabaseCollection", () => {
211210
212211 const find1 = await db . find ( undefined , { skip : 0 , limit : 1 } , { sortBy : "value" , sortOrder : "desc" } ) ;
213212 expect ( find1 ) . toHaveLength ( 1 ) ;
214- expect ( find1 [ 0 ] . id ) . toEqual ( "id2" ) ;
213+ expect ( find1 [ 0 ] . id ) . toBe ( "id2" ) ;
215214
216215 const find2 = await db . find ( undefined , { skip : 1 , limit : 1 } , { sortBy : "value" , sortOrder : "desc" } ) ;
217216 expect ( find2 ) . toHaveLength ( 1 ) ;
218- expect ( find2 [ 0 ] . id ) . toEqual ( "id1" ) ;
217+ expect ( find2 [ 0 ] . id ) . toBe ( "id1" ) ;
219218 } ) ;
220219
221220 test ( "should not allow to create duplicate entries for unique index" , async function ( ) {
0 commit comments