How to use toBeArray method in jest-extended

Best JavaScript code snippet using jest-extended

transactions.test.js

Source:transactions.test.js Github

copy

Full Screen

...49 const transactions = await repository.findAll()50 // NOTE: The real count is avoided because it degrades the performance of the node51 // expect(transactions.count).toBe(153)52 expect(transactions.count).toBe(100)53 expect(transactions.rows).toBeArray()54 expect(transactions.rows).not.toBeEmpty()55 transactions.rows.forEach(transaction => {56 expect(transaction).toBeMinimalTransactionFields()57 })58 })59 it('should find all transactions that holds the condition', async () => {60 await connection.saveBlock(genesisBlock)61 const transactions = await repository.findAll({62 type: 363 })64 expect(transactions.count).toBe(51)65 expect(transactions.rows).toBeArray()66 expect(transactions.rows).not.toBeEmpty()67 transactions.rows.forEach(transaction => {68 expect(transaction).toBeMinimalTransactionFields()69 })70 })71 it('should find all transactions that holds all the conditions (AND)', async () => {72 await connection.saveBlock(genesisBlock)73 const transactions = await repository.findAll({74 recipientId: genesisTransaction.recipientId,75 type: 376 })77 expect(transactions.count).toBe(1)78 expect(transactions.rows).toBeArray()79 expect(transactions.rows).not.toBeEmpty()80 transactions.rows.forEach(transaction => {81 expect(transaction).toBeMinimalTransactionFields()82 })83 })84 it('should find the same transactions with parameter senderId and corresponding senderPublicKey', async () => {85 await connection.saveBlock(genesisBlock)86 const senderWallet = await spv.walletManager.findByPublicKey('034776bd6080a504b0f84f8d66b16af292dc253aa5f4be8b807746a82aa383bd3c')87 const transactionsSenderPublicKey = await repository.findAll({ senderPublicKey: senderWallet.publicKey })88 const transactionsSenderId = await repository.findAll({ senderId: senderWallet.address })89 expect(transactionsSenderPublicKey.count).toBe(transactionsSenderId.count)90 expect(transactionsSenderPublicKey.rows.length).toBe(transactionsSenderPublicKey.count)91 expect(transactionsSenderId.rows.length).toBe(transactionsSenderId.count)92 transactionsSenderPublicKey.rows.forEach((transactionSenderPublicKey, index) => {93 const transactionSenderId = transactionsSenderId.rows[index]94 expect(transactionSenderId).toEqual(transactionSenderPublicKey)95 })96 })97 it('should find no transaction when passed parameter senderId is invalid or unknown', async () => {98 await connection.saveBlock(genesisBlock)99 const invalidSenderId = 'thisIsNotAValidSenderId'100 const transactionsSenderId = await repository.findAll({ senderId: invalidSenderId })101 expect(transactionsSenderId.count).toBe(0)102 expect(transactionsSenderId.rows.length).toBe(0)103 })104 xit('should find all transactions by some fields only', () => {105 })106 describe('when no results', () => {107 it('should not return them', async () => {108 await connection.saveBlock(genesisBlock)109 const transactions = await repository.findAll({ type: 99 })110 expect(transactions.count).toBe(0)111 expect(transactions.rows).toBeArray()112 expect(transactions.rows).toBeEmpty()113 })114 // TODO this and other methods115 xit('should not perform a query to get the results', () => {116 })117 })118 })119 describe('findAllLegacy', () => {120 it('should be a function', () => {121 expect(repository.findAllLegacy).toBeFunction()122 })123 it('should find all transactions', async () => {124 await connection.saveBlock(genesisBlock)125 const transactions = await repository.findAllLegacy()126 // NOTE: The real count is avoided because it degrades the performance of the node127 // expect(transactions.count).toBe(153)128 expect(transactions.count).toBe(100)129 expect(transactions.rows).toBeArray()130 expect(transactions.rows).not.toBeEmpty()131 transactions.rows.forEach(transaction => {132 expect(transaction).toBeMinimalTransactionFields()133 })134 })135 it('should find all transactions that holds the condition', async () => {136 await connection.saveBlock(genesisBlock)137 const transactions = await repository.findAllLegacy({138 type: 3139 })140 expect(transactions.count).toBe(51)141 expect(transactions.rows).toBeArray()142 expect(transactions.rows).not.toBeEmpty()143 transactions.rows.forEach(transaction => {144 expect(transaction).toBeMinimalTransactionFields()145 })146 })147 it('should find all transactions that holds any of the conditions (OR)', async () => {148 await connection.saveBlock(genesisBlock)149 const transactions = await repository.findAllLegacy({150 recipientId: genesisTransaction.recipientId,151 type: 3152 })153 expect(transactions.count).toBe(52)154 expect(transactions.rows).toBeArray()155 expect(transactions.rows).not.toBeEmpty()156 transactions.rows.forEach(transaction => {157 expect(transaction).toBeMinimalTransactionFields()158 })159 })160 it('should find the same transactions with parameter senderId and corresponding senderPublicKey', async () => {161 await connection.saveBlock(genesisBlock)162 const senderWallet = await spv.walletManager.findByPublicKey('034776bd6080a504b0f84f8d66b16af292dc253aa5f4be8b807746a82aa383bd3c')163 const transactionsSenderPublicKey = await repository.findAllLegacy({ senderPublicKey: senderWallet.publicKey })164 const transactionsSenderId = await repository.findAllLegacy({ senderId: senderWallet.address })165 expect(transactionsSenderPublicKey.count).toBe(transactionsSenderId.count)166 expect(transactionsSenderPublicKey.rows.length).toBe(transactionsSenderPublicKey.count)167 expect(transactionsSenderId.rows.length).toBe(transactionsSenderId.count)168 transactionsSenderPublicKey.rows.forEach((transactionSenderPublicKey, index) => {169 const transactionSenderId = transactionsSenderId.rows[index]170 expect(transactionSenderId).toEqual(transactionSenderPublicKey)171 })172 })173 it('should find no transaction when passed parameter senderId is invalid or unknown', async () => {174 await connection.saveBlock(genesisBlock)175 const invalidSenderId = 'thisIsNotAValidSenderId'176 const transactionsSenderId = await repository.findAllLegacy({ senderId: invalidSenderId })177 expect(transactionsSenderId.count).toBe(0)178 expect(transactionsSenderId.rows.length).toBe(0)179 })180 xit('should find all transactions by any field', () => {181 })182 describe('when no results', () => {183 it('should not return them', async () => {184 await connection.saveBlock(genesisBlock)185 const transactions = await repository.findAllLegacy({ type: 99 })186 expect(transactions.count).toBe(0)187 expect(transactions.rows).toBeArray()188 expect(transactions.rows).toBeEmpty()189 })190 xit('should not perform a query to get the results', () => {191 })192 })193 })194 describe('findAllByWallet', () => {195 it('should be a function', () => {196 expect(repository.findAllByWallet).toBeFunction()197 })198 it('should find all transactions', async () => {199 await connection.saveBlock(genesisBlock)200 const receiver = await getWallet('AHXtmB84sTZ9Zd35h9Y1vfFvPE2Xzqj8ri')201 expect(receiver).toBeObject()202 const receiverTransactions = await repository.findAllByWallet(receiver)203 expect(receiverTransactions.count).toBe(2)204 expect(receiverTransactions.rows).toBeArray()205 expect(receiverTransactions.rows).not.toBeEmpty()206 receiverTransactions.rows.forEach(transaction => {207 expect(transaction).toBeMinimalTransactionFields()208 })209 const sender = await getWallet('APnhwwyTbMiykJwYbGhYjNgtHiVJDSEhSn')210 expect(sender).toBeObject()211 sender.publicKey = '035b63b4668ee261c16ca91443f3371e2fe349e131cb7bf5f8a3e93a3ddfdfc788'212 const senderTransactions = await repository.findAllByWallet(sender)213 expect(senderTransactions.count).toBe(51)214 expect(receiverTransactions.rows).toBeArray()215 expect(receiverTransactions.rows).not.toBeEmpty()216 senderTransactions.rows.forEach(transaction => {217 expect(transaction).toBeMinimalTransactionFields()218 })219 })220 describe('when no results', () => {221 it('should not return them', async () => {222 await connection.saveBlock(genesisBlock)223 const transactions = await repository.findAll({ type: 99 })224 expect(transactions.count).toBe(0)225 expect(transactions.rows).toBeArray()226 expect(transactions.rows).toBeEmpty()227 })228 })229 })230 describe('findAllBySender', () => {231 it('should be a function', () => {232 expect(repository.findAllBySender).toBeFunction()233 })234 it('should find all transactions', async () => {235 await connection.saveBlock(genesisBlock)236 const transactions = await repository.findAllBySender('03ba0fa7dd4760a15e46bc762ac39fc8cfb7022bdfef31d1fd73428404796c23fe')237 expect(transactions.count).toBe(2)238 expect(transactions.rows).toBeArray()239 expect(transactions.rows).not.toBeEmpty()240 transactions.rows.forEach(transaction => {241 expect(transaction).toBeMinimalTransactionFields()242 })243 })244 describe('when no results', () => {245 it('should not return them', async () => {246 await connection.saveBlock(genesisBlock)247 const transactions = await repository.findAll({ type: 99 })248 expect(transactions.count).toBe(0)249 expect(transactions.rows).toBeArray()250 expect(transactions.rows).toBeEmpty()251 })252 })253 })254 describe('findAllByRecipient', () => {255 it('should be a function', () => {256 expect(repository.findAllByRecipient).toBeFunction()257 })258 it('should find all transactions', async () => {259 await connection.saveBlock(genesisBlock)260 const transactions = await repository.findAllByRecipient('AU8hpb5QKJXBx6QhAzy3CJJR69pPfdvp5t')261 expect(transactions.count).toBe(2)262 expect(transactions.rows).toBeArray()263 expect(transactions.rows).not.toBeEmpty()264 transactions.rows.forEach(transaction => {265 expect(transaction).toBeMinimalTransactionFields()266 })267 })268 describe('when no results', () => {269 it('should not return them', async () => {270 await connection.saveBlock(genesisBlock)271 const transactions = await repository.findAllByRecipient('none')272 expect(transactions.count).toBe(0)273 expect(transactions.rows).toBeArray()274 expect(transactions.rows).toBeEmpty()275 })276 })277 })278 describe('allVotesBySender', () => {279 it('should be a function', () => {280 expect(repository.allVotesBySender).toBeFunction()281 })282 it('should find all transactions', async () => {283 await connection.saveBlock(genesisBlock)284 const transactions = await repository.allVotesBySender('03d7dfe44e771039334f4712fb95ad355254f674c8f5d286503199157b7bf7c357')285 expect(transactions.count).toBe(1)286 expect(transactions.rows).toBeArray()287 expect(transactions.rows).not.toBeEmpty()288 transactions.rows.forEach(transaction => {289 expect(transaction).toBeMinimalTransactionFields()290 })291 })292 describe('when no results', () => {293 it('should not return them', async () => {294 await connection.saveBlock(genesisBlock)295 const transactions = await repository.allVotesBySender('none')296 expect(transactions.count).toBe(0)297 expect(transactions.rows).toBeArray()298 expect(transactions.rows).toBeEmpty()299 })300 })301 })302 describe('findAllByBlock', () => {303 it('should be a function', () => {304 expect(repository.findAllByBlock).toBeFunction()305 })306 it('should find all transactions', async () => {307 await connection.saveBlock(genesisBlock)308 const transactions = await repository.findAllByBlock(genesisBlock.data.id)309 // NOTE: The real count is avoided because it degrades the performance of the node310 // expect(transactions.count).toBe(153)311 expect(transactions.count).toBe(100)312 expect(transactions.rows).toBeArray()313 expect(transactions.rows).not.toBeEmpty()314 transactions.rows.forEach(transaction => {315 expect(transaction).toBeMinimalTransactionFields()316 })317 })318 describe('when no results', () => {319 it('should not return them', async () => {320 await connection.saveBlock(genesisBlock)321 const transactions = await repository.findAllByBlock('none')322 expect(transactions.count).toBe(0)323 expect(transactions.rows).toBeArray()324 expect(transactions.rows).toBeEmpty()325 })326 })327 })328 describe('findAllByType', () => {329 it('should be a function', () => {330 expect(repository.findAllByType).toBeFunction()331 })332 it('should find all transactions', async () => {333 await connection.saveBlock(genesisBlock)334 const transactions = await repository.findAllByType(2)335 expect(transactions.count).toBe(51)336 expect(transactions.rows).toBeArray()337 expect(transactions.rows).not.toBeEmpty()338 transactions.rows.forEach(transaction => {339 expect(transaction).toBeMinimalTransactionFields()340 })341 })342 describe('when no results', () => {343 it('should not return them', async () => {344 await connection.saveBlock(genesisBlock)345 const transactions = await repository.findAllByType(88)346 expect(transactions.rows).toBeArray()347 expect(transactions.rows).toBeEmpty()348 expect(transactions.count).toBe(0)349 })350 })351 })352 describe('findOne', () => {353 it('should be a function', () => {354 expect(repository.findOne).toBeFunction()355 })356 it('should find the transaction fields', async () => {357 await connection.saveBlock(genesisBlock)358 const recipientId = 'AHXtmB84sTZ9Zd35h9Y1vfFvPE2Xzqj8ri'359 const senderPublicKey = '035b63b4668ee261c16ca91443f3371e2fe349e131cb7bf5f8a3e93a3ddfdfc788'360 const fields = await repository.findOne({ recipientId, senderPublicKey })361 expect(fields).toBeMinimalTransactionFields()362 const transaction = Transaction.deserialize(fields.serialized.toString('hex'))363 expect(transaction.id).toBe('db1aa687737858cc9199bfa336f9b1c035915c30aaee60b1e0f8afadfdb946bd')364 expect(transaction.recipientId).toBe(recipientId)365 expect(transaction.senderPublicKey).toBe(senderPublicKey)366 })367 describe('when the block is cached', () => {368 xit('uses it without executing additional queries', () => {369 })370 })371 })372 describe('findById', () => {373 it('should be a function', () => {374 expect(repository.findById).toBeFunction()375 })376 it('should find the transaction fields', async () => {377 await connection.saveBlock(genesisBlock)378 const fields = await repository.findById(genesisTransaction.id)379 expect(fields).toBeMinimalTransactionFields()380 const transaction = Transaction.deserialize(fields.serialized.toString('hex'))381 expect(transaction.id).toBe(genesisTransaction.id)382 })383 })384 describe('findByTypeAndId', () => {385 it('should be a function', () => {386 expect(repository.findByTypeAndId).toBeFunction()387 })388 it('should find the transaction fields', async () => {389 await connection.saveBlock(genesisBlock)390 const id = 'ea294b610e51efb3ceb4229f27bf773e87f41d21b6bb1f3bf68629ffd652c2d3'391 const type = 3392 const fields = await repository.findByTypeAndId(type, id)393 expect(fields).toBeMinimalTransactionFields()394 const transaction = Transaction.deserialize(fields.serialized.toString('hex'))395 expect(transaction.id).toBe(id)396 expect(transaction.type).toBe(type)397 })398 })399 describe('search', async () => {400 const expectSearch = async (params, expected) => {401 await connection.saveBlock(genesisBlock)402 const transactions = await repository.search(params)403 expect(transactions).toBeObject()404 expect(transactions.count).toBeNumber()405 expect(transactions.rows).toBeArray()406 expect(transactions.rows).not.toBeEmpty()407 transactions.rows.forEach(transaction => {408 expect(transaction).toBeMinimalTransactionFields()409 })410 expect(transactions.count).toBe(expected)411 }412 it('should be a function', () => {413 expect(repository.search).toBeFunction()414 })415 it('should search transactions by the specified `id`', async () => {416 await expectSearch({ id: genesisTransaction.id }, 1)417 })418 it('should search transactions by the specified `blockId`', async () => {419 await expectSearch({ blockId: genesisTransaction.blockId }, 153)420 })421 it('should search transactions by the specified `type`', async () => {422 await expectSearch({ type: genesisTransaction.type }, 51)423 })424 it('should search transactions by the specified `version`', async () => {425 await expectSearch({ version: genesisTransaction.version }, 153)426 })427 // TODO when is not on the blockchain?428 // TODO when is not indexed?429 describe('when the wallet is indexed', () => {430 const senderId = () => {431 return crypto.getAddress(genesisTransaction.senderPublicKey, 23)432 }433 beforeEach(() => {434 const wallet = getWallet(senderId())435 wallet.publicKey = genesisTransaction.senderPublicKey436 spv.walletManager.reindex(wallet)437 })438 it('should search transactions by the specified `senderId`', async () => {439 await expectSearch({ senderId: senderId() }, 51)440 })441 })442 it('should search transactions by the specified `senderPublicKey`', async () => {443 await expectSearch({ senderPublicKey: genesisTransaction.senderPublicKey }, 51)444 })445 it('should search transactions by the specified `recipientId`', async () => {446 await expectSearch({ recipientId: genesisTransaction.recipientId }, 2)447 })448 it('should search transactions by the specified `timestamp`', async () => {449 await expectSearch({450 timestamp: {451 from: genesisTransaction.timestamp,452 to: genesisTransaction.timestamp453 }454 }, 153)455 })456 it('should search transactions by the specified `amount`', async () => {457 await expectSearch({458 amount: {459 from: genesisTransaction.amount,460 to: genesisTransaction.amount461 }462 }, 50)463 })464 it('should search transactions by the specified `fee`', async () => {465 await expectSearch({466 fee: {467 from: genesisTransaction.fee,468 to: genesisTransaction.fee469 }470 }, 153)471 })472 it('should search transactions by the specified `vendorFieldHex`', async () => {473 await expectSearch({ vendorFieldHex: genesisTransaction.vendorFieldHex }, 153)474 })475 describe('when there are more than 1 condition', () => {476 it('should search transactions that includes all of them (AND)', async () => {477 await expectSearch({ recipientId: genesisTransaction.recipientId, type: 3 }, 1)478 })479 })480 describe('when no results', () => {481 it('should not return them', async () => {482 await connection.saveBlock(genesisBlock)483 const transactions = await repository.search({ recipientId: 'dummy' })484 expect(transactions).toBeObject()485 expect(transactions).toHaveProperty('count', 0)486 expect(transactions.rows).toBeArray()487 expect(transactions.rows).toBeEmpty()488 })489 })490 })491 describe('count', () => {492 it('should return the total number of transactions', async () => {493 await connection.saveBlock(genesisBlock)494 const { count } = await repository.count()495 expect(count).toBe(153)496 })497 })...

Full Screen

Full Screen

events-database-service.test.ts

Source:events-database-service.test.ts Github

copy

Full Screen

...57 database.boot();58 expect(existsSync(storagePath)).toBeTrue();59 database.add("dummy_event", { data: "dummy_data" });60 const result = database.find().data;61 expect(result).toBeArray();62 expect(result[0]).toMatchObject({63 id: 1,64 event: "dummy_event",65 data: { data: "dummy_data" },66 });67 expect(result[0].timestamp).toBeDefined();68 });69 it("should add event with empty data", async () => {70 database.boot();71 expect(existsSync(storagePath)).toBeTrue();72 database.add("dummy_event", undefined);73 const result = database.find().data;74 expect(result).toBeArray();75 expect(result[0]).toMatchObject({76 id: 1,77 event: "dummy_event",78 data: {},79 });80 expect(result[0].timestamp).toBeDefined();81 });82 });83 describe("Query", () => {84 beforeEach(() => {85 database.boot();86 for (let i = 0; i < 100; i++) {87 database.add("dummy_event", { data: "dummy_data" });88 database.add("another_dummy_event", { data: "another_dummy_data" });89 }90 });91 it("should return limit 100", async () => {92 const result = database.find();93 expect(result.total).toBe(200);94 expect(result.limit).toBe(100);95 expect(result.offset).toBe(0);96 expect(result.data).toBeArray();97 expect(result.data.length).toBe(100);98 });99 it("should return limit 10 with offset", async () => {100 const result = database.find({ $offset: 10 });101 expect(result.total).toBe(200);102 expect(result.limit).toBe(100);103 expect(result.offset).toBe(10);104 expect(result.data).toBeArray();105 expect(result.data.length).toBe(100);106 });107 it("should return limit 20", async () => {108 const result = database.find({ $limit: 20 });109 expect(result.total).toBe(200);110 expect(result.limit).toBe(20);111 expect(result.offset).toBe(0);112 expect(result.data).toBeArray();113 expect(result.data.length).toBe(20);114 });115 it("should return events with name", async () => {116 const result = database.find({ $limit: 1000, event: "dummy_event" });117 expect(result.total).toBe(100);118 expect(result.limit).toBe(1000);119 expect(result.offset).toBe(0);120 expect(result.data).toBeArray();121 expect(result.data.length).toBe(100);122 });123 it("should not return events if searching by number", async () => {124 const result = database.find({ $limit: 1000, event: 1 });125 expect(result.total).toBe(0);126 expect(result.limit).toBe(1000);127 expect(result.offset).toBe(0);128 expect(result.data).toBeArray();129 expect(result.data.length).toBe(0);130 });131 });132 describe("Query JSON", () => {133 beforeEach(() => {134 database.boot();135 database.add("dummy_event", { size: 1, name: "1_dummy_event" });136 database.add("dummy_event", { size: 2, name: "2_dummy_event" });137 database.add("dummy_event", { size: 3, name: "3_dummy_event" });138 database.add("dummy_event", { size: 4, name: "4_dummy_event" });139 database.add("dummy_event", { size: 5, name: "5_dummy_event" });140 });141 it("should chose $eq by default", async () => {142 const result = database.find({ data: { size: 1 } });143 expect(result.total).toBe(1);144 expect(result.limit).toBe(100);145 expect(result.offset).toBe(0);146 expect(result.data).toBeArray();147 expect(result.data.length).toBe(1);148 });149 it("should use $eq on string", async () => {150 const result = database.find({ data: { name: { $eq: "1_dummy_event" } } });151 expect(result.total).toBe(1);152 expect(result.limit).toBe(100);153 expect(result.offset).toBe(0);154 expect(result.data).toBeArray();155 expect(result.data.length).toBe(1);156 });157 it("should use $ne", async () => {158 const result = database.find({ data: { size: { $ne: 3 } } });159 expect(result.total).toBe(4);160 expect(result.limit).toBe(100);161 expect(result.offset).toBe(0);162 expect(result.data).toBeArray();163 expect(result.data.length).toBe(4);164 });165 it("should use $like on string", async () => {166 const result = database.find({ data: { name: { $like: "1_%" } } });167 expect(result.total).toBe(1);168 expect(result.limit).toBe(100);169 expect(result.offset).toBe(0);170 expect(result.data).toBeArray();171 expect(result.data.length).toBe(1);172 });173 it("should use $lt", async () => {174 const result = database.find({ data: { size: { $lt: 2 } } });175 expect(result.total).toBe(1);176 expect(result.limit).toBe(100);177 expect(result.offset).toBe(0);178 expect(result.data).toBeArray();179 expect(result.data.length).toBe(1);180 });181 it("should use $lte", async () => {182 const result = database.find({ data: { size: { $lte: 2 } } });183 expect(result.total).toBe(2);184 expect(result.limit).toBe(100);185 expect(result.offset).toBe(0);186 expect(result.data).toBeArray();187 expect(result.data.length).toBe(2);188 });189 it("should use $gt", async () => {190 const result = database.find({ data: { size: { $gt: 4 } } });191 expect(result.total).toBe(1);192 expect(result.limit).toBe(100);193 expect(result.offset).toBe(0);194 expect(result.data).toBeArray();195 expect(result.data.length).toBe(1);196 });197 it("should use $gte", async () => {198 const result = database.find({ data: { size: { $gte: 4 } } });199 expect(result.total).toBe(2);200 expect(result.limit).toBe(100);201 expect(result.offset).toBe(0);202 expect(result.data).toBeArray();203 expect(result.data.length).toBe(2);204 });205 it("should use $gte an $lte", async () => {206 const result = database.find({ data: { size: { $gte: 2, $lte: 4 } } });207 expect(result.total).toBe(3);208 expect(result.limit).toBe(100);209 expect(result.offset).toBe(0);210 expect(result.data).toBeArray();211 expect(result.data.length).toBe(3);212 });213 });...

Full Screen

Full Screen

AdegaService-spec.js

Source:AdegaService-spec.js Github

copy

Full Screen

...38 ];39 it('should obtain a set of relevant terms from a text', function(done) {40 AdegaService._context(key, text, function(err, context) {41 expect(err).toBeFalsy();42 expect(context).toBeArray();43 expect(context).toBeArrayOfObjects();44 context.forEach(function(object) {45 expect(object.term).toBeDefined();46 expect(object.uri).toBeDefined();47 expect(object.relevance).toBeDefined();48 expect(object.synonyms).toBeArray();49 expect(object.synonyms).toBeArrayOfStrings();50 });51 done();52 });53 });54 it('should obtain a set of root nodes from ontology graph using context term to start searching related nodes', function(done){55 AdegaService._rootNodes(key, context, function(err, nodes) {56 expect(err).toBeFalsy();57 expect(nodes).toBeArray();58 expect(nodes).toBeArrayOfObjects();59 nodes.forEach(function(object) {60 expect(object.id).toBeDefined();61 expect(object.label).toBeDefined();62 expect(object.resource).toBeDefined();63 expect(object.isCategory).toBeBoolean();64 });65 done();66 });67 });68});69describe('adega service', function() {70 var key = 'lcdkddtb2h6h0fnvdmmiims2bj';71 var text = 'Han pasado tres dias en Mariupol';72 it('should process both rootNodes and context methods', function(done) {73 AdegaService._process(key, text, function(err, nodes) {74 expect(err).toBeFalsy();75 expect(nodes).toBeArray();76 expect(nodes).toBeArrayOfObjects();77 nodes.forEach(function(object) {78 expect(object.id).toBeDefined();79 expect(object.label).toBeDefined();80 expect(object.resource).toBeDefined();81 expect(object.isCategory).toBeBoolean();82 });83 done();84 });85 });86 it('should find the relevant terms from a text', function(done) {87 AdegaService.search(email, text, function(err, nodes) {88 expect(err).toBeFalsy();89 expect(nodes).toBeArray();90 expect(nodes).toBeArrayOfObjects();91 nodes.forEach(function(object) {92 expect(object.id).toBeDefined();93 expect(object.label).toBeDefined();94 expect(object.resource).toBeDefined();95 expect(object.isCategory).toBeBoolean();96 });97 done();98 });99 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toBeArray } = require('jest-extended');2expect.extend({ toBeArray });3describe('toBeArray', () => {4 test('passes when given an array', () => {5 expect([]).toBeArray();6 });7});8const { toBeArrayOfBooleans } = require('jest-extended');9expect.extend({ toBeArrayOfBooleans });10describe('toBeArrayOfBooleans', () => {11 test('passes when given an array of booleans', () => {12 expect([true, false]).toBeArrayOfBooleans();13 });14});15const { toBeArrayOfNumbers } = require('jest-extended');16expect.extend({ toBeArrayOfNumbers });17describe('toBeArrayOfNumbers', () => {18 test('passes when given an array of numbers', () => {19 expect([1, 2, 3]).toBeArrayOfNumbers();20 });21});22const { toBeArrayOfObjects } = require('jest-extended');23expect.extend({ toBeArrayOfObjects });24describe('toBeArrayOfObjects', () => {25 test('passes when given an array of objects', () => {26 expect([{ a: 1 }, { b: 2 }]).toBeArrayOfObjects();27 });28});29const { toBeArrayOfSize } = require('jest-extended');30expect.extend({ toBeArrayOfSize });31describe('toBeArrayOfSize', () => {32 test('passes when given an array of a particular size', () => {33 expect([1, 2, 3]).toBeArrayOfSize(3);34 });35});36const { toBeArrayOfStrings } = require('jest-extended');37expect.extend({ toBeArrayOfStrings });38describe('toBeArrayOfStrings', () => {39 test('passes when given an array of strings', () => {40 expect(['a', 'b', 'c']).toBeArrayOfStrings();41 });42});43const { toBeBoolean

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toBeArray } = require('jest-extended');2expect.extend({ toBeArray });3test('passes when given an array', () => {4 expect([]).toBeArray();5});6test('fails when not given an array', () => {7 expect({}).not.toBeArray();8});9test('fails when given an array-like object', () => {10 expect(arguments).not.toBeArray();11});12test('fails when given an array-like object', () => {13 expect({ 0: 'a', 1: 'b', length: 2 }).not.toBeArray();14});15test('fails when given an array-like object', () => {16 expect('abc').not.toBeArray();17});18const { toBeArrayOfSize } = require('jest-extended');19expect.extend({ toBeArrayOfSize });20test('passes when given an array of the specified size', () => {21 expect([1, 2, 3]).toBeArrayOfSize(3);22});23test('fails when given an array of a different size', () => {24 expect([1, 2, 3]).not.toBeArrayOfSize(2);25});26test('fails when given an array-like object', () => {27 expect(arguments).not.toBeArrayOfSize(2);28});29test('fails when given an array-like object', () => {30 expect({ 0: 'a', 1: 'b', length: 2 }).not.toBeArrayOfSize(2);31});32test('fails when given an array-like object', () => {33 expect('abc').not.toBeArrayOfSize(2);34});35const { toBeBoolean } = require('jest-extended');36expect.extend({ toBeBoolean });37test('passes when given a boolean', () => {38 expect(true).toBeBoolean();39});40test('fails when not given a boolean', () => {41 expect('true').not.toBeBoolean();42});43const { toBeDate } = require('jest-extended');44expect.extend({ toBeDate });45test('passes when given a date', () => {46 expect(new Date()).toBeDate();47});48test('fails when not given a date', () => {49 expect('201

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toBeArray } = require('jest-extended');2expect.extend({ toBeArray });3test('toBeArray', () => {4 expect([1, 2, 3]).toBeArray();5 expect([]).toBeArray();6 expect('abc').not.toBeArray();7});8const { toBeArray } = require('jest-extended');9expect.extend({ toBeArray });10test('toBeArray', () => {11 expect([1, 2, 3]).toBeArray();12 expect([]).toBeArray();13 expect('abc').not.toBeArray();14});15const { toBeArray } = require('jest-extended');16expect.extend({ toBeArray });17test('toBeArray', () => {18 expect([1, 2, 3]).toBeArray();19 expect([]).toBeArray();20 expect('abc').not.toBeArray();21});22const { toBeArray } = require('jest-extended');23expect.extend({ toBeArray });24test('toBeArray', () => {25 expect([1, 2, 3]).toBeArray();26 expect([]).toBeArray();27 expect('abc').not.toBeArray();28});29const { toBeArray } = require('jest-extended');30expect.extend({ toBeArray });31test('toBeArray', () => {32 expect([1, 2, 3]).toBeArray();33 expect([]).toBeArray();34 expect('abc').not.toBeArray();35});36const { toBeArray } = require('jest-extended');37expect.extend({ toBeArray });38test('toBeArray', () => {39 expect([1, 2, 3]).toBeArray();40 expect([]).toBeArray();41 expect('abc').not.toBeArray();42});43const { toBeArray } = require('jest-extended');44expect.extend({ toBeArray });45test('toBeArray', () => {46 expect([

Full Screen

Using AI Code Generation

copy

Full Screen

1const { toBeArray } = require('jest-extended')2expect.extend({ toBeArray })3expect([1, 2, 3]).toBeArray()4const { toBeBoolean } = require('jest-extended')5expect.extend({ toBeBoolean })6expect(true).toBeBoolean()7const { toBeEmpty } = require('jest-extended')8expect.extend({ toBeEmpty })9expect([]).toBeEmpty()10const { toBeEmptyObject } = require('jest-extended')11expect.extend({ toBeEmptyObject })12expect({}).toBeEmptyObject()13const { toBeEmptyString } = require('jest-extended')14expect.extend({ toBeEmptyString })15expect('').toBeEmptyString()16const { toBeFunction } = require('jest-extended')17expect.extend({ toBeFunction })18expect(() => {}).toBeFunction()19const { toBeInteger } = require('jest-extended')20expect.extend({ toBeInteger })21expect(1).toBeInteger()22const { toBeNumber } = require('jest-extended')23expect.extend({ toBeNumber })24expect(1).toBeNumber()25const { toBeObject } = require('jest-extended')26expect.extend({ toBeObject })27expect({}).toBeObject()28const { toBeString } = require('jest-extended')29expect.extend({ toBeString })30expect('foo').toBeString()31const { toBeTrue } = require('jest-extended')32expect.extend({ toBeTrue })33expect(true).toBeTrue()

Full Screen

Using AI Code Generation

copy

Full Screen

1let array = [1,2,3];2expect(array).toBeArray();3let array = [1,2,3];4expect(array).not.toBeArray();5let array = [true, false];6expect(array).toBeArrayOfBooleans();7let array = [true, false];8expect(array).not.toBeArrayOfBooleans();9let array = [1,2,3];10expect(array).toBeArrayOfNumbers();11let array = [1,2,3];12expect(array).not.toBeArrayOfNumbers();13let array = [{}, {}];14expect(array).toBeArrayOfObjects();15let array = [{}, {}];16expect(array).not.toBeArrayOfObjects();17let array = [1,2,3];18expect(array).toBeArrayOfSize(3);19let array = [1,2,3];20expect(array).not.toBeArrayOfSize(3);21let array = ['a', 'b', 'c'];22expect(array).toBeArrayOfStrings();23let array = ['a', 'b', 'c'];24expect(array).not.toBeArrayOfStrings();25let boolean = true;26expect(boolean).toBeBoolean();27let boolean = true;28expect(boolean).not.toBeBoolean();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run jest-extended automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful