How to use instance3 method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

test_entity.js

Source:test_entity.js Github

copy

Full Screen

1/**2 * Created by VinceZK on 06/29/18.3 */4const entity = require('../server/models/entity.js');5const _ = require('underscore');6describe.only('entity tests', function () {7 let instance =8 { ENTITY_ID: 'person',9 person: {HEIGHT: 1.70, GENDER: 'Male', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743E', HOBBY:'Reading, Movie, Coding',10 TYPE: 'employee', SYSTEM_ACCESS: 'PORTAL'},11 r_user: {USER_ID: 'DH999', USER_NAME:'VINCEZK', DISPLAY_NAME: 'Vincent Zhang'},12 r_email: [{EMAIL: 'dh999@hotmail.com', TYPE: 'PRIVATE', PRIMARY:1},13 {EMAIL: 'dh999@gmail.com', TYPE: 'WORK', PRIMARY:0}14 ],15 r_address: [{COUNTRY: 'China', CITY:'Shanghai', POSTCODE: 201202,16 ADDRESS_VALUE:'Room #402, Building #41, Dongjing Road #393',17 TYPE: 'CLIVE', PRIMARY:1},18 {COUNTRY: 'China', CITY:'Haimen', POSTCODE: 226126,19 ADDRESS_VALUE:'Group 8 Lizhu Tangjia',20 TYPE: 'WORK', PRIMARY:0}],21 r_employee: {USER_ID: 'DH999', COMPANY_ID:'DARKHOUSE', DEPARTMENT_ID: 'DEVELOPMENT', TITLE: 'Developer', GENDER:'Male'},22 relationships:[23 { RELATIONSHIP_ID: 'rs_user_role',24 values:[25 {action:'add', SYNCED:0,26 PARTNER_INSTANCES:[{ENTITY_ID:'permission', ROLE_ID:'system_role',27 INSTANCE_GUID:'391E75B02A1811E981F3C33C6FB0A7C1'}]}28 ]29 }]30 };31 let wifeInstanceGUID;32 describe('Entity Creation', function () {33 it('should not create an instance as mandatory relation is missing 1', function(done){34 let instance2 = _.clone(instance);35 delete instance2.person;36 entity.createInstance(instance2, function(err){37 err.should.containDeep([{38 msgCat: 'ENTITY',39 msgName: 'MANDATORY_RELATION_MISSING',40 msgType: 'E'41 }]);42 done();43 })44 });45 it('should not create an instance as mandatory relation is missing 2', function(done){46 let instance2 = _.clone(instance);47 delete instance2.r_user;48 entity.createInstance(instance2, function(err){49 err.should.containDeep([{50 msgCat: 'ENTITY',51 msgName: 'MANDATORY_RELATION_MISSING',52 msgType: 'E'53 }]);54 done();55 })56 });57 it('should not create an instance as multiple values is not allowed for r_employee', function(done){58 let instance2 = _.clone(instance);59 instance2.r_employee = [60 {USER_ID: 'DH999', COMPANY_ID:'Darkhouse', DEPARTMENT_ID: 'Development', TITLE: 'Developer', GENDER:'Male'},61 {USER_ID: 'DH998', COMPANY_ID:'Darkhouse', DEPARTMENT_ID: 'Development', TITLE: 'Director', GENDER:'Male'}62 ];63 entity.createInstance(instance2, function(err){64 err.should.containDeep([{65 msgCat: 'ENTITY',66 msgName: 'RELATION_NOT_ALLOW_MULTIPLE_VALUE',67 msgType: 'E'68 }]);69 done();70 })71 });72 it('should not create an instance for illegal actions', function(done){73 let instance2 = _.clone(instance);74 instance2.r_email = [75 {action: 'delete', EMAIL: 'dh999@hotmail.com', TYPE: 'private', PRIMARY:1},76 {action: 'update', EMAIL: 'dh999@gmail.com', TYPE: 'private important', PRIMARY:0}77 ];78 entity.createInstance(instance2, function(err){79 err.should.containDeep([{80 msgCat: 'ENTITY',81 msgName: 'UPDATE_DELETE_NOT_ALLOWED',82 msgType: 'E'83 }]);84 done();85 })86 });87 it('should not create an instance for non-exist partner entity', function(done){88 let instance2 = _.clone(instance);89 instance2.relationships = [90 { RELATIONSHIP_ID: 'rs_user_role',91 values:[92 {action:'add', SYNCED:0,93 PARTNER_INSTANCES:[{ENTITY_ID:'permission', ROLE_ID:'system_role', INSTANCE_GUID:'5F50DE92743683E1ED7F964E5B9F6167'}]},94 {action:'add', SYNCED:0,95 PARTNER_INSTANCES:[{ENTITY_ID:'permission', ROLE_ID:'system_role', INSTANCE_GUID:''}]}96 ]97 }];98 entity.createInstance(instance2, function(err){99 err.should.containDeep([{100 msgCat: 'ENTITY',101 msgName: 'ENTITY_INSTANCE_NOT_EXIST',102 msgType: 'E'103 }]);104 done();105 })106 });107 it('should create an instance of person', function (done) {108 entity.createInstance(instance, function (errs) {109 should(errs).eql(null);110 done();111 });112 });113 it('should get an instance of person', function (done) {114 entity.getInstanceByID({RELATION_ID: 'r_user', USER_ID: 'DH999'}, function (err, instance2) {115 should(err).eql(null);116 instance2.ENTITY_ID.should.eql(instance.ENTITY_ID);117 instance2.person.should.containDeep([instance.person]);118 instance2.r_user.should.containDeep([instance.r_user]);119 instance2.r_email.should.containDeep(instance.r_email);120 instance2.r_address.should.containDeep(instance.r_address);121 instance2.r_employee.should.containDeep([instance.r_employee]);122 delete instance.relationships[0].values[0].action;123 instance2.relationships.should.containDeep(instance.relationships);124 done();125 })126 });127 it('should get pieces of an instance', function (done) {128 let piece = {RELATIONS: ['r_user', 'r_email'], RELATIONSHIPS: ['rs_user_role'] };129 entity.getInstancePieceByGUID(instance.INSTANCE_GUID, piece, function (err, instancePiece) {130 should(err).eql(null);131 instancePiece.r_user.should.containDeep([instance.r_user]);132 instancePiece.r_email.should.containDeep(instance.r_email);133 instancePiece.relationships.should.containDeep(instance.relationships);134 done();135 })136 });137 it('should fail to create an instance with relation of a disabled role', function (done) {138 let instance2 = { ENTITY_ID: 'person',139 person: {HEIGHT: 165, GENDER: 'female', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743F', HOBBY:'Drama',140 TYPE: 'employee'},141 r_user: [{USER_ID: 'DH998', USER_NAME:'Jessy', DISPLAY_NAME: 'Jessy Huang'}],142 r_email: [{EMAIL: 'dh998@hotmail.com', TYPE: 'private', PRIMARY:1}],143 r_address: [],144 r_employee: {USER_ID: 'DH998', COMPANY_ID:'Darkhouse', DEPARTMENT_ID: 'Development', TITLE: 'Tester', GENDER:'Female'},145 r_personalization: {}146 };147 entity.createInstance(instance2, function (err) {148 err.should.containDeep([{149 msgCat: 'ENTITY',150 msgName: 'RELATION_NOT_VALID',151 msgType: 'E'152 }]);153 done();154 });155 });156 it('should fail to create an instance with relationship of a disabled role', function (done) {157 let instance2 = { ENTITY_ID: 'person',158 person: {HEIGHT: 165, GENDER: 'female', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743F', HOBBY:'Drama',159 TYPE: 'employee'},160 r_email: [{EMAIL: 'dh998@hotmail.com', TYPE: 'private', PRIMARY:1}],161 r_address: [],162 r_employee: {USER_ID: 'DH998', COMPANY_ID:'Darkhouse', DEPARTMENT_ID: 'Development', TITLE: 'Tester', GENDER:'Female'},163 relationships:[164 { RELATIONSHIP_ID: 'rs_user_role',165 values:[166 {action:'add', SYNCED:0,167 PARTNER_INSTANCES:[{ENTITY_ID:'permission', ROLE_ID:'system_role', INSTANCE_GUID:'5F50DE92743683E1ED7F964E5B9F6167'}]}168 ]169 }]170 };171 entity.createInstance(instance2, function (err) {172 err.should.containDeep([{173 msgCat: 'ENTITY',174 msgName: 'RELATIONSHIP_NOT_VALID',175 msgType: 'E'176 }]);177 done();178 });179 });180 it('should fail to create an instance, because of invalid gender', function (done) {181 let instance2 = { ENTITY_ID: 'person',182 person: {HEIGHT: 1.65, GENDER: 'invalid', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743F', HOBBY:'Drama',183 TYPE: 'employee'},184 r_email: [{EMAIL: 'dh998@hotmail.com', TYPE: 'PRIVATE', PRIMARY:1}],185 r_address: [],186 r_employee: {USER_ID: 'DH998', COMPANY_ID:'DARKHOUSE', DEPARTMENT_ID: 'Development', TITLE: 'Tester', GENDER:'Female'},187 };188 entity.createInstance(instance2, function (err) {189 err.should.containDeep([{190 msgCat: 'ENTITY',191 msgName: 'INVALID_VALUE_IN_DOMAIN',192 msgType: 'E'193 }]);194 done();195 });196 });197 it('should fail to create an instance, because of invalid email', function (done) {198 let instance2 = { ENTITY_ID: 'person',199 person: {HEIGHT: 1.65, GENDER: 'Female', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743F', HOBBY:'Drama',200 TYPE: 'employee'},201 r_email: [{EMAIL: 'invalid Email', TYPE: 'PRIVATE', PRIMARY:1}],202 r_address: [],203 r_employee: {USER_ID: 'DH998', COMPANY_ID:'DARKHOUSE', DEPARTMENT_ID: 'Development', TITLE: 'Tester', GENDER:'Female'},204 };205 entity.createInstance(instance2, function (err) {206 err.should.containDeep([{207 msgCat: 'ENTITY',208 msgName: 'NOT_MATCH_REGEXP',209 msgType: 'E'210 }]);211 done();212 });213 });214 it('should create an instance of a female person', function (done) {215 let instance2 = { ENTITY_ID: 'person',216 person: {HEIGHT: 1.65, GENDER: 'Female', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743F', HOBBY:'Drama',217 TYPE: 'employee'},218 r_email: [{EMAIL: 'dh998@hotmail.com', TYPE: 'PRIVATE', PRIMARY:1}],219 r_address: [],220 r_employee: {USER_ID: 'DH998', COMPANY_ID:'DARKHOUSE', DEPARTMENT_ID: 'Development', TITLE: 'Tester', GENDER:'Female'},221 };222 entity.createInstance(instance2, function (err) {223 should(err).eql(null);224 wifeInstanceGUID = instance2.INSTANCE_GUID;225 done();226 });227 });228 it('should get an instance of the female person', function (done) {229 entity.getInstanceByGUID(wifeInstanceGUID, function (err, instance2) {230 should(err).eql(null);231 instance2.person.should.containDeep([232 {HEIGHT: 1.65, GENDER: 'Female', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743F',233 HOBBY:'Drama', TYPE: 'employee'}]);234 (instance2.r_user === undefined).should.true();235 (instance2.r_personalization === undefined).should.true();236 instance2.r_email.should.containDeep(237 [{EMAIL: 'dh998@hotmail.com', TYPE: 'PRIVATE', PRIMARY:1}]);238 (instance2.r_address === undefined).should.true();239 instance2.r_employee.should.containDeep([240 {USER_ID: 'DH998', COMPANY_ID:'DARKHOUSE', DEPARTMENT_ID: 'DEVELOPMENT', TITLE: 'Tester', GENDER:'Female'}]);241 done();242 })243 });244 it('should get pieces of the female person', function (done) {245 let piece = {RELATIONS: ['r_user', 'r_email'], RELATIONSHIPS: ['rs_user_role'] };246 entity.getInstancePieceByID({RELATION_ID: 'r_employee', USER_ID: 'DH998'}, piece,247 function (err) {248 err.should.containDeep([{249 msgCat: 'ENTITY',250 msgName: 'RELATION_NOT_VALID',251 msgType: 'E'252 }]);253 done();254 })255 });256 });257 describe('Entity Changing', function () {258 it('should change attributes of the instance', function (done) {259 let instance3 =260 {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,261 person: {action:'update', HOBBY:'Reading, Movie, Coding, Bike', HEIGHT: 1.71 },262 r_user : {action:'update', USER_ID: 'DH999', DISPLAY_NAME: 'Zhang Kai', FAMILY_NAME: 'Zhang'},263 r_email: [264 {action:'delete', EMAIL: 'dh999@hotmail.com'},265 {action:'update', EMAIL: 'dh999@gmail.com', PRIMARY:1},266 {action:'add', EMAIL: 'dh999@sap.com', TYPE: 'WORK', PRIMARY:0},267 {EMAIL: 'dh999@hotmail.com', TYPE: 'PRIVATE', PRIMARY:0}],268 relationships:[269 { RELATIONSHIP_ID: 'rs_user_role',270 values:[271 {action:'add', SYNCED: 1,272 PARTNER_INSTANCES:[273 {ENTITY_ID:'permission', ROLE_ID:'system_role', INSTANCE_GUID:'23F3AE905E8311E9A91C03500E3C8091'}274 ]}]}275 ]276 };277 entity.changeInstance(instance3, function(err){278 should(err).eql(null);279 entity.getInstanceByGUID(instance.INSTANCE_GUID, function (err, instance2) {280 should(err).eql(null);281 delete instance3.person.action;282 instance2.person.should.containDeep([instance3.person]);283 delete instance3.r_user.action;284 instance2.r_user.should.containDeep([instance3.r_user]);285 instance2.r_email.should.containDeep([286 {EMAIL: 'dh999@sap.com'},287 {EMAIL: 'dh999@gmail.com', PRIMARY:1},{EMAIL: 'dh999@hotmail.com', TYPE: 'PRIVATE', PRIMARY:0}]);288 delete instance3.relationships[0].values[0].action;289 instance2.relationships.should.containDeep(instance3.relationships);290 done();291 });292 })293 });294 it('should report an error as the INSTANCE_GUID does not exit', function (done) {295 let instance3 = {ENTITY_ID:"person",INSTANCE_GUID:"3AD9A9F0840F11E995EFADDBF5879A0E",296 person:{action:"update",GENDER:"male",HEIGHT:"175"}};297 entity.changeInstance(instance3, function(err){298 err.should.containDeep([{299 msgCat: 'ENTITY',300 msgName: 'ENTITY_INSTANCE_NOT_EXIST',301 msgType: 'E'302 }]);303 done();304 })305 });306 it('should report an error as ENTITY_ID is not provided', function (done) {307 let instance3 = {INSTANCE_GUID: instance.INSTANCE_GUID,308 r_user : {action:'update', USER_ID: 'DH999', DISPLAY_NAME: 'Zhang Kai', FAMILY_NAME: 'Zhang'}};309 entity.changeInstance(instance3, function(err){310 err.should.containDeep([{311 msgCat: 'ENTITY',312 msgName: 'ENTITY_ID_MISSING',313 msgType: 'E'314 }]);315 done();316 })317 });318 it('should add user personalization successfully', function (done) {319 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,320 r_personalization : {USER_ID: 'DH999', TIMEZONE: 'UTC+8', LANGUAGE: 'ZH'}};321 entity.changeInstance(instance3, function(err){322 should(err).eql(null);323 done();324 })325 });326 it('should be failed to add personalization, as it is [0..1] and already exists', function (done) {327 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,328 r_personalization : {USER_ID: 'DH999', TIMEZONE: 'UTC+8', LANGUAGE: 'EN', DATE_FORMAT: 3}};329 entity.changeInstance(instance3, function(err){330 err.should.containDeep([{331 msgCat: 'ENTITY',332 msgName: 'RELATION_NOT_ALLOW_MULTIPLE_VALUE',333 msgType: 'E'334 }]);335 done();336 })337 });338 it('should be failed to clear emails, as it is [1..n]', function (done) {339 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,340 r_email : [{action:'delete', EMAIL: 'dh999@gmail.com', PRIMARY:1},341 {action:'delete', EMAIL: 'dh999@sap.com'},342 {action:'delete', EMAIL: 'dh999@hotmail.com', PRIMARY:0}]};343 entity.changeInstance(instance3, function(err){344 err.should.containDeep([{345 msgCat: 'ENTITY',346 msgName: 'MANDATORY_RELATION_MISSING',347 msgType: 'E'348 }]);349 done();350 })351 });352 it('should update the emails successfully', function (done) {353 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,354 r_email : [355 {action:'delete', EMAIL: 'dh999@gmail.com', PRIMARY:1},356 {action:'delete', EMAIL: 'dh999@sap.com'},357 {action:'delete', EMAIL: 'dh999@hotmail.com', PRIMARY:0},358 {action:'add', EMAIL: 'dh999@hotmail.com', PRIMARY:1}]};359 entity.changeInstance(instance3, function(err){360 should(err).eql(null);361 done();362 })363 });364 it('should fail to delete r_user as it is [1..1]', function (done) {365 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,366 r_user : {action: 'delete',USER_ID: 'DH999'}};367 entity.changeInstance(instance3, function(err){368 err.should.containDeep([{369 msgCat: 'ENTITY',370 msgName: 'MANDATORY_RELATION_MISSING',371 msgType: 'E'372 }]);373 done();374 })375 });376 it('should be failed to change to an invalid gender', function (done) {377 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,378 person : {action: 'update', GENDER: 'INVALID'} };379 entity.changeInstance(instance3, function(err){380 err.should.containDeep([{381 msgCat: 'ENTITY',382 msgName: 'INVALID_VALUE_IN_DOMAIN',383 msgType: 'E'384 }]);385 done();386 })387 });388 it('should disable the relations & relationships of role employee', function (done) {389 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,390 person : {action: 'update', SYSTEM_ACCESS: ''}};391 entity.changeInstance(instance3, function(err){392 should(err).eql(null);393 entity.getInstanceByGUID(instance.INSTANCE_GUID, function (err, instance2) {394 should(err).eql(null);395 (instance2.r_user === undefined).should.true();396 (instance2.r_personalization === undefined).should.true();397 instance2.relationships.length.should.eql(0);398 instance3.person.SYSTEM_ACCESS = 'PORTAL';399 entity.changeInstance(instance3, function (err) {400 should(err).eql(null);401 done();402 });403 });404 });405 });406 it('should fail to change a person with invalid relation', function (done) {407 let instance3 = {408 ENTITY_ID: 'person', INSTANCE_GUID: wifeInstanceGUID,409 r_user : {USER_ID: 'DH998', USER_NAME:'Jessy', DISPLAY_NAME: 'Jessy Huang'}410 };411 entity.changeInstance(instance3, function (err) {412 err.should.containDeep([{413 msgCat: 'ENTITY',414 msgName: 'RELATION_NOT_VALID',415 msgType: 'E'416 }]);417 done();418 });419 });420 it('should fail to change a person with invalid relationship', function (done) {421 let instance3 = {422 ENTITY_ID: 'person', INSTANCE_GUID: wifeInstanceGUID,423 relationships: [424 { RELATIONSHIP_ID: 'rs_user_role',425 values:[426 { action: 'add', SYNCED: 0,427 PARTNER_INSTANCES:[428 {ENTITY_ID:'permission',ROLE_ID:'system_role',INSTANCE_GUID:'7B36CB959C06B2CAEB89C93EDFB30510' }429 ]}430 ]431 }432 ]433 };434 entity.changeInstance(instance3, function (err) {435 err.should.containDeep([{436 msgCat: 'ENTITY',437 msgName: 'RELATIONSHIP_NOT_VALID',438 msgType: 'E'439 }]);440 done();441 });442 });443 it('should change the female person successfully', function (done) {444 let instance3 = {445 ENTITY_ID: 'person', INSTANCE_GUID: wifeInstanceGUID,446 person: {action: 'update', SYSTEM_ACCESS: 'PORTAL'},447 r_user: {USER_ID: 'DH998', USER_NAME:'Jessy', DISPLAY_NAME: 'Jessy Huang'}448 };449 entity.changeInstance(instance3, function (err) {450 should(err).eql(null);451 done();452 });453 });454 it('should report an error as r_user is [1..1] relation', function (done) {455 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,456 r_user : {USER_ID: 'DH998', DISPLAY_NAME: 'Zhang Kai', FAMILY_NAME: 'Zhang'}};457 entity.changeInstance(instance3, function(err){458 err.should.containDeep([{459 msgCat: 'ENTITY',460 msgName: 'RELATION_NOT_ALLOW_MULTIPLE_VALUE',461 msgType: 'E'462 }]);463 done();464 })465 });466 it('should fail: [1..1] relation cannot be deleted', function (done) {467 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,468 r_user : {action: 'delete', USER_ID: 'DH999'}469 };470 entity.changeInstance(instance3, function(err){471 err.should.containDeep([{472 msgCat: 'ENTITY',473 msgName: 'MANDATORY_RELATION_MISSING',474 msgType: 'E'475 }]);476 done();477 })478 });479 it('should fail: [1..1] relation has multiple deletions', function (done) {480 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,481 r_user : [482 {action: 'delete', USER_ID: 'DH999'},483 {action: 'delete', USER_ID: 'DH997'},484 {action: 'add', USER_ID: 'DH999', DISPLAY_NAME: 'Zhang Kai2', FAMILY_NAME: 'Zhang'},485 ]486 };487 entity.changeInstance(instance3, function(err){488 err.should.containDeep([{489 msgCat: 'ENTITY',490 msgName: 'MULTIPLE_DELETION_ON_11CARDINALITY',491 msgType: 'E'492 }]);493 done();494 })495 });496 it('should fail: [1..1] relation has a combined add and wrong deletion', function (done) {497 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,498 r_user : [499 {action: 'delete', USER_ID: 'DH998'},500 {action: 'add', USER_ID: 'DH999', DISPLAY_NAME: 'Zhang Kai2', FAMILY_NAME: 'Zhang'},501 ]502 };503 entity.changeInstance(instance3, function(err){504 err.should.containDeep([{505 msgCat: 'ENTITY',506 msgName: 'RELATION_NOT_ALLOW_MULTIPLE_VALUE',507 msgType: 'E'508 }]);509 done();510 })511 });512 it('should success: [1..1] relation has a combined add and delete', function (done) {513 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,514 r_user : [515 {action: 'delete', USER_ID: 'DH999'},516 {action: 'add', USER_ID: 'DH999', DISPLAY_NAME: 'Zhang Kai2', FAMILY_NAME: 'Zhang'},517 ]518 };519 entity.changeInstance(instance3, function(err){520 should(err).eql(null);521 done();522 })523 });524 it('should fail: [0..1] relation has already a persisted entry', function (done) {525 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,526 r_personalization : {USER_ID: 'DH999', TIMEZONE: 'UTC+8', LANGUAGE: 'ZH'}};527 entity.changeInstance(instance3, function(err){528 err.should.containDeep([{529 msgCat: 'ENTITY',530 msgName: 'RELATION_NOT_ALLOW_MULTIPLE_VALUE',531 msgType: 'E'532 }]);533 done();534 })535 });536 it('should fail: [0..1] relation has multiple adding actions', function (done) {537 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,538 r_personalization : [539 {USER_ID: 'DH999', TIMEZONE: 'UTC+8', LANGUAGE: 'EN'},540 {USER_ID: 'DH997', TIMEZONE: 'UTC+8', LANGUAGE: 'EN'},541 {action: 'delete', USER_ID: 'DH999'},542 ]543 };544 entity.changeInstance(instance3, function(err){545 err.should.containDeep([{546 msgCat: 'ENTITY',547 msgName: 'RELATION_NOT_ALLOW_MULTIPLE_VALUE',548 msgType: 'E'549 }]);550 done();551 })552 });553 it('should success: [0..1] relation has a combined add and delete actions', function (done) {554 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,555 r_personalization : [556 {action: 'delete', USER_ID: 'DH999'},557 {USER_ID: 'DH999', TIMEZONE: 'UTC+8', LANGUAGE: 'EN'}558 ]559 };560 entity.changeInstance(instance3, function(err){561 should(err).eql(null);562 done();563 })564 });565 it('should success: [0..1] relation can be deleted', function (done) {566 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,567 r_personalization : [568 {action: 'delete', USER_ID: 'DH999'}569 ]570 };571 entity.changeInstance(instance3, function(err){572 should(err).eql(null);573 done();574 })575 });576 it('should success: [0..1] relation is restored', function (done) {577 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,578 r_personalization : {USER_ID: 'DH999', TIMEZONE: 'UTC+8', LANGUAGE: 'EN'}579 };580 entity.changeInstance(instance3, function(err){581 should(err).eql(null);582 done();583 })584 });585 });586 describe('Relationship tests(time dependent)', function () {587 let instance3;588 before(function () {589 instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID};590 });591 it('should report an error of RELATIONSHIP_ACTION_INVALID', function (done) {592 instance3.relationships = [593 { RELATIONSHIP_ID: 'rs_user_role',594 values:[595 { action: 'aa', VALID_TO:'2030-12-31 00:00:00', SYNCED: 1}]596 }597 ];598 entity.changeInstance(instance3, function (err) {599 err.should.containDeep([ {600 msgCat: 'ENTITY', msgName: 'RELATIONSHIP_ACTION_INVALID', msgType: 'E'} ]);601 done();602 })603 });604 it('should report an error of RELATIONSHIP_NOT_VALID', function (done) {605 instance3.relationships = [606 { RELATIONSHIP_ID: 'rs_mtest01',607 values:[608 { action: 'extend', VALID_TO:'2030-12-31 00:00:00', SYNCED: 1}]609 }610 ];611 entity.changeInstance(instance3, function (err) {612 err.should.containDeep([ {613 msgCat: 'ENTITY', msgName: 'RELATIONSHIP_NOT_VALID', msgType: 'E'} ]);614 done();615 })616 });617 it('should report an error of RELATIONSHIP_INSTANCE_GUID_MISSING', function (done) {618 instance3.relationships = [619 { RELATIONSHIP_ID: 'rs_user_role',620 values:[621 { action: 'update', SYNCED: 1}]622 }623 ];624 entity.changeInstance(instance3, function (err) {625 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'RELATIONSHIP_INSTANCE_GUID_MISSING', msgType: 'E'} ]);626 done();627 })628 });629 it('should report an error of PARTNER_INSTANCE_GUID_MISSING', function (done) {630 instance3.relationships = [631 { RELATIONSHIP_ID: 'rs_user_role',632 values:[633 { action: 'add', SYNCED: 1}634 ]635 }636 ];637 entity.changeInstance(instance3, function (err) {638 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'PARTNER_INSTANCES_MISSING', msgType: 'E'} ]);639 done();640 })641 });642 it('should report an error of INVOLVED_ROLE_NUMBER_INCORRECT', function (done) {643 instance3.relationships = [644 { RELATIONSHIP_ID: 'rs_user_role',645 values:[646 { action: 'add', SYNCED: 0,647 PARTNER_INSTANCES:[648 {ENTITY_ID:'permission',ROLE_ID:'system_role',INSTANCE_GUID:'7B36CB959C06B2CAEB89C93EDFB30510' },649 {ENTITY_ID:'permission',ROLE_ID:'system_role',INSTANCE_GUID:'AC560C8786095BB7B4842ABA2F323478' }650 ]}651 ]652 }653 ];654 entity.changeInstance(instance3, function (err) {655 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'INVOLVED_ROLE_NUMBER_INCORRECT', msgType: 'E'} ]);656 done();657 })658 });659 it('should report an error of ROLE_NOT_VALID', function (done) {660 instance3.relationships = [661 { RELATIONSHIP_ID: 'rs_user_role',662 values:[663 { action: 'add', SYNCED: 0,664 PARTNER_INSTANCES:[665 {ENTITY_ID:'permission',ROLE_ID:'system_role1',INSTANCE_GUID:'7B36CB959C06B2CAEB89C93EDFB30510' }666 ]}667 ]668 }669 ];670 entity.changeInstance(instance3, function (err) {671 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'ROLE_NOT_VALID', msgType: 'E'} ]);672 done();673 })674 });675 it('should report an error of NEW_RELATIONSHIP_ADD_TO_BEFORE ', function (done) {676 instance3.relationships = [677 { RELATIONSHIP_ID: 'rs_marriage',678 values:[679 { action: 'add', VALID_FROM:'2017-12-31 00:00:00', VALID_TO:'2030-12-31 00:00:00', REG_PLACE: 'SH',680 PARTNER_INSTANCES:[681 {ENTITY_ID:'person',ROLE_ID:'wife',INSTANCE_GUID: wifeInstanceGUID }682 ]}683 ]684 }685 ];686 entity.changeInstance(instance3, function (err) {687 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'NEW_RELATIONSHIP_ADD_TO_BEFORE', msgType: 'E'} ]);688 done();689 })690 });691 it('should report an error of VALID_TO_BEFORE_VALID_FROM ', function (done) {692 instance3.relationships = [693 { RELATIONSHIP_ID: 'rs_marriage',694 values:[695 { action: 'add', VALID_FROM:'2031-12-31 00:00:00', VALID_TO:'2030-12-31 00:00:00', REG_PLACE: 'SH',696 PARTNER_INSTANCES:[697 {ENTITY_ID: 'person', ROLE_ID: 'wife', INSTANCE_GUID: wifeInstanceGUID }698 ]}699 ]700 }701 ];702 entity.changeInstance(instance3, function (err) {703 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'VALID_TO_BEFORE_VALID_FROM', msgType: 'E'} ]);704 done();705 })706 });707 it('should report an error of ENTITY_INSTANCE_NOT_EXIST', function (done) {708 instance3.relationships = [709 { RELATIONSHIP_ID: 'rs_marriage',710 values:[711 { action: 'add', VALID_TO:'2028-12-31 00:00:00',712 PARTNER_INSTANCES:[713 {ENTITY_ID:'person',ROLE_ID:'wife',INSTANCE_GUID:'7B36CB959C06B2CAEB89C93EDFB30510' }714 ]}715 ]716 }717 ];718 entity.changeInstance(instance3, function (err) {719 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'ENTITY_INSTANCE_NOT_EXIST', msgType: 'E'}]);720 done();721 })722 });723 it('should report an error of RELATIONSHIP_INSTANCE_NOT_EXIST', function (done) {724 instance3.relationships = [725 { RELATIONSHIP_ID: 'rs_user_role',726 values:[727 { action: 'update', RELATIONSHIP_INSTANCE_GUID: '9F86F86198B711E8A69A2DDC7A79514A',SYNCED: '1'},728 ]729 }730 ];731 entity.changeInstance(instance3, function (err) {732 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'RELATIONSHIP_INSTANCE_NOT_EXIST', msgType: 'E'}]);733 done();734 })735 });736 it('should report an error of RELATIONSHIP_INSTANCE_OVERLAP [1..1]', function (done) {737 instance3.relationships = [738 { RELATIONSHIP_ID: 'rs_marriage',739 values:[740 { action: 'add', VALID_FROM:'2025-12-31 00:00:00', VALID_TO:'2030-12-31 00:00:00', REG_PLACE: 'HM',741 PARTNER_INSTANCES:[742 {ENTITY_ID:'person',ROLE_ID:'wife',INSTANCE_GUID: wifeInstanceGUID }743 ]},744 { action: 'add', VALID_FROM:'2027-12-31 00:00:00', VALID_TO:'2035-12-31 00:00:00', REG_PLACE: 'SH',745 PARTNER_INSTANCES:[746 {ENTITY_ID:'person',ROLE_ID:'wife',INSTANCE_GUID: wifeInstanceGUID }747 ]}748 ]749 }750 ];751 entity.changeInstance(instance3, function (err) {752 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'RELATIONSHIP_INSTANCE_OVERLAP', msgType: 'E'}]);753 done();754 })755 });756 it.skip('should report an error of RELATIONSHIP_INSTANCE_OVERLAP [1..n]', function (done) {757 instance3.relationships = [758 { RELATIONSHIP_ID: 'rs_marriage',759 values:[760 { action: 'add', VALID_FROM:'2020-12-31 00:00:00', VALID_TO:'2030-12-31 00:00:00',761 PARTNER_INSTANCES:[762 {ENTITY_ID:'person',ROLE_ID:'wife',INSTANCE_GUID:'5F50DE92743683E1ED7F964E5B9F6167' }763 ]},764 { action: 'add', VALID_FROM:'2025-12-31 00:00:00', VALID_TO:'2035-12-31 00:00:00',765 PARTNER_INSTANCES:[766 {ENTITY_ID:'person',ROLE_ID:'wife',INSTANCE_GUID:'1483BE56BDA717184CD170467A214695' }767 ]}768 ]769 }770 ];771 entity.changeInstance(instance3, function (err) {772 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'RELATIONSHIP_INSTANCE_OVERLAP', msgType: 'E'}]);773 done();774 })775 });776 it.skip('should report an error of RELATIONSHIP_INSTANCE_OVERLAP [1..n] in DB', function (done) {777 instance3.relationships = [778 { RELATIONSHIP_ID: 'rs_user_role',779 values:[780 { action: 'add', VALID_FROM:'2020-12-31 00:00:00', VALID_TO:'2030-12-31 00:00:00', SYNCED: 1,781 PARTNER_INSTANCES:[782 {ENTITY_ID:'permission',ROLE_ID:'system_role',INSTANCE_GUID:'5F50DE92743683E1ED7F964E5B9F6167' }783 ]}784 ]785 }786 ];787 entity.changeInstance(instance3, function (err) {788 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'RELATIONSHIP_INSTANCE_OVERLAP', msgType: 'E'}]);789 done();790 })791 });792 let instance2;793 it('should successfully add 3 relationships', function (done) {794 instance3.relationships = [795 { RELATIONSHIP_ID: 'rs_user_role',796 values:[797 { action: 'add', SYNCED: 1,798 PARTNER_INSTANCES:[799 {ENTITY_ID:'permission',ROLE_ID:'system_role',INSTANCE_GUID:'AF7E5550E7E511E992DC7BC6FE1F471B' }800 ]}801 ]802 },803 {804 RELATIONSHIP_ID: 'rs_marriage',805 values:[806 { action: 'add', REG_PLACE: 'Shanghai', COUNTRY: 'CHINA',807 PARTNER_INSTANCES:[808 {ENTITY_ID:'person',ROLE_ID:'wife',INSTANCE_GUID: wifeInstanceGUID }809 ]810 },811 { action: 'add', VALID_FROM: '2050-12-31 00:00:00', REG_PLACE: 'Dark side of Moon',812 PARTNER_INSTANCES:[813 {ENTITY_ID:'person',ROLE_ID:'wife',INSTANCE_GUID: '430C8BB0E1C611E8877F9D5C9668A7A3' }814 ]815 }816 ]817 }818 ];819 entity.changeInstance(instance3, function (err) {820 should(err).eql(null);821 entity.getInstanceByID({RELATION_ID: 'r_user', USER_ID: 'DH999'}, function (err, newInstance){822 should(err).eql(null);823 instance2 = newInstance;824 done();825 });826 })827 });828 it('should report an error of RELATIONSHIP_INSTANCE_OVERLAP [1..1] in DB', function (done) {829 instance3.relationships = [830 { RELATIONSHIP_ID: 'rs_marriage',831 values:[832 { action: 'add', VALID_FROM:'2025-12-31 00:00:00', VALID_TO:'2030-12-31 00:00:00',833 PARTNER_INSTANCES:[834 {ENTITY_ID:'person',ROLE_ID:'wife',INSTANCE_GUID: wifeInstanceGUID }835 ]}836 ]837 }838 ];839 entity.changeInstance(instance3, function (errs) {840 should(errs).containDeep([{msgCat: 'ENTITY', msgName: 'RELATIONSHIP_INSTANCE_OVERLAP', msgType: 'E'}]);841 done();842 })843 });844 /**845 * Current relationships in DB846 * [ { RELATIONSHIP_ID: 'rs_marriage', SELF_ROLE_ID: 'husband',847 values:848 [{ RELATIONSHIP_INSTANCE_GUID: '485769E06E5311E9A28C5B3C9CFBBB00',849 PARTNER_INSTANCES: [{ ENTITY_ID: 'person', ROLE_ID: 'wife', INSTANCE_GUID: '4835B1106E5311E9A28C5B3C9CFBBB00' } ],850 VALID_FROM: '2019-05-04 17:59:18', VALID_TO: '2029-05-04 17:59:18', REG_PLACE: Shanghai, COUNTRY: CHINA },851 { RELATIONSHIP_INSTANCE_GUID: '485769E06E5311E9A28C5B3C9CFBBB00',852 PARTNER_INSTANCES: [{ ENTITY_ID: 'person', ROLE_ID: 'wife', INSTANCE_GUID: '430C8BB0E1C611E8877F9D5C9668A7A3' } ],853 VALID_FROM: '2050-12-31 00:00:00', VALID_TO: '2060-12-28 00:00:00', REG_PLACE: 'Dark side of Moon', COUNTRY: null },854 ]},855 { RELATIONSHIP_ID: 'rs_user_role', SELF_ROLE_ID: 'system_user',856 values:857 [{ RELATIONSHIP_INSTANCE_GUID: '4829A3206E5311E9A28C5B3C9CFBBB00', SYNCED: '0',858 PARTNER_INSTANCES: [{ENTITY_ID:'permission',ROLE_ID:'system_role',INSTANCE_GUID:'5F50DE92743683E1ED7F964E5B9F6167' } ]},859 { RELATIONSHIP_INSTANCE_GUID: '483A93106E5311E9A28C5B3C9CFBBB00', SYNCED: '1',860 PARTNER_INSTANCES: [{ENTITY_ID:'permission',ROLE_ID:'system_role',INSTANCE_GUID:'F0EF0C4174A883BF639E2EB0C8735239' } ]},861 { RELATIONSHIP_INSTANCE_GUID: '485742D06E5311E9A28C5B3C9CFBBB00', SYNCED: '1',862 PARTNER_INSTANCES: [{ENTITY_ID:'permission',ROLE_ID:'system_role',INSTANCE_GUID:'F914BC7E2BD65D42A0B17FBEAD8E1AF2' } ]}863 ]}864 ]865 */866 it('should read the instance', function (done) {867 entity.getInstanceByID({RELATION_ID: 'r_user', USER_ID: 'DH999'}, function (err, instancex){868 should(err).eql(null);869 instance2 = instancex;870 done();871 });872 });873 it('should get pieces of an instance with additional partner entity information', function (done) {874 let piece = {875 RELATIONS: ['r_user'],876 RELATIONSHIPS: [877 {RELATIONSHIP_ID: 'rs_marriage',878 PARTNER_ENTITY_PIECES: {879 RELATIONSHIPS: ['rs_marriage']880 }}] };881 entity.getInstancePieceByGUID(instance.INSTANCE_GUID, piece, function (err, instancePiece) {882 should(err).eql(null);883 // instancePiece.relationships[0].values.forEach(value => console.log(value.PARTNER_INSTANCES[0]));884 instancePiece.r_user.should.containDeep(instance2.r_user);885 instancePiece.relationships[0].values[0].PARTNER_INSTANCES[0].should.containDeep(886 { ENTITY_ID: 'person',887 ROLE_ID: 'wife',888 INSTANCE_GUID: wifeInstanceGUID,889 relationships:890 [ { RELATIONSHIP_ID: 'rs_marriage',891 SELF_ROLE_ID: 'wife'} ],892 });893 done();894 })895 });896 it('should get pieces of an instance with complex partner information', function (done) {897 let piece = {898 RELATIONSHIPS:899 [900 {901 RELATIONSHIP_ID: 'rs_marriage',902 PARTNER_ENTITY_PIECES: [903 { ENTITY_ID: 'person',904 piece: {RELATIONS: ['r_user'], RELATIONSHIPS: ['rs_marriage']}905 }906 ]907 },908 {909 RELATIONSHIP_ID: 'rs_user_role',910 PARTNER_ENTITY_PIECES: [911 { ENTITY_ID: 'permission',912 piece: {RELATIONS: ['r_role'], RELATIONSHIPS: ['rs_user_role']}913 }914 ]915 },916 ]917 };918 entity.getInstancePieceByGUID(instance.INSTANCE_GUID, piece, function (err, instancePiece) {919 should(err).eql(null);920 instancePiece.relationships.should.containDeep([921 { RELATIONSHIP_ID: 'rs_marriage',922 SELF_ROLE_ID: 'husband'},923 { RELATIONSHIP_ID: 'rs_user_role',924 SELF_ROLE_ID: 'system_user'},925 ]);926 done();927 })928 });929 it('should report an error of RELATIONSHIP_DELETION_NOT_ALLOWED', function (done) {930 let userRoleRelationship = instance2.relationships.find(function (relationship) {931 return relationship.RELATIONSHIP_ID === 'rs_marriage';932 });933 let currentRelationshipGUID = userRoleRelationship.values.find(function (value) {934 return value.PARTNER_INSTANCES[0].INSTANCE_GUID === wifeInstanceGUID;935 }).RELATIONSHIP_INSTANCE_GUID;936 instance3.relationships = [937 { RELATIONSHIP_ID: 'rs_marriage',938 values:[939 { action: 'delete', RELATIONSHIP_INSTANCE_GUID: currentRelationshipGUID }940 ]941 }942 ];943 entity.changeInstance(instance3, function (err) {944 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'RELATIONSHIP_DELETION_NOT_ALLOWED', msgType: 'E'}]);945 done();946 })947 });948 it('should report an error of FUTURE_RELATIONSHIP', function (done) {949 let userRoleRelationship = instance2.relationships.find(function (relationship) {950 return relationship.RELATIONSHIP_ID === 'rs_marriage';951 });952 let futureRelationshipGUID = userRoleRelationship.values.find(function (value) {953 return value.PARTNER_INSTANCES[0].INSTANCE_GUID === '430C8BB0E1C611E8877F9D5C9668A7A3';954 }).RELATIONSHIP_INSTANCE_GUID;955 instance3.relationships = [956 { RELATIONSHIP_ID: 'rs_marriage',957 values:[958 { action: 'expire', RELATIONSHIP_INSTANCE_GUID: futureRelationshipGUID},959 ]960 }961 ];962 entity.changeInstance(instance3, function (err) {963 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'FUTURE_RELATIONSHIP', msgType: 'E'}]);964 done();965 })966 });967 it('should expire an active relationship', function (done) {968 let userRoleRelationship = instance2.relationships.find(function (relationship) {969 return relationship.RELATIONSHIP_ID === 'rs_marriage';970 });971 let currentRelationshipGUID = userRoleRelationship.values.find(function (value) {972 return value.PARTNER_INSTANCES[0].INSTANCE_GUID === wifeInstanceGUID;973 }).RELATIONSHIP_INSTANCE_GUID;974 instance3.relationships = [975 { RELATIONSHIP_ID: 'rs_marriage',976 values:[977 { action:'expire', RELATIONSHIP_INSTANCE_GUID: currentRelationshipGUID},978 ]979 }980 ];981 entity.changeInstance(instance3, function (err) {982 should(err).eql(null);983 done();984 })985 });986 it('should report an error of CHANGE_TO_EXPIRED_RELATIONSHIP', function (done) {987 let userRoleRelationship = instance2.relationships.find(function (relationship) {988 return relationship.RELATIONSHIP_ID === 'rs_marriage';989 });990 let currentRelationshipGUID = userRoleRelationship.values.find(function (value) {991 return value.PARTNER_INSTANCES[0].INSTANCE_GUID === wifeInstanceGUID;992 }).RELATIONSHIP_INSTANCE_GUID;993 instance3.relationships = [994 { RELATIONSHIP_ID: 'rs_marriage', REG_PLACE: 'HAIMEN',995 values:[996 { action:'update', RELATIONSHIP_INSTANCE_GUID: currentRelationshipGUID},997 ]998 }999 ];1000 entity.changeInstance(instance3, function (err) {1001 err.should.containDeep([{msgCat: 'ENTITY', msgName: 'CHANGE_TO_EXPIRED_RELATIONSHIP', msgType: 'E'}]);1002 done();1003 })1004 });1005 it('should delete a future relationship', function (done) {1006 let marriageRelationship = instance2.relationships.find(function (relationship) {1007 return relationship.RELATIONSHIP_ID === 'rs_marriage';1008 });1009 let futureRelationshipGUID = marriageRelationship.values.find(function (value) {1010 return new Date(value.VALID_FROM) > new Date();1011 }).RELATIONSHIP_INSTANCE_GUID;1012 instance3.relationships = [1013 { RELATIONSHIP_ID: 'rs_marriage',1014 values:[1015 { action:'delete', RELATIONSHIP_INSTANCE_GUID: futureRelationshipGUID},1016 ]1017 }1018 ];1019 entity.changeInstance(instance3, function (err) {1020 should(err).eql(null);1021 done();1022 })1023 })1024 });1025 describe('Relationship tests(time independent)', function () {1026 let instance4;1027 let relationshipGUID;1028 before(function () { // Using the category: Demo1029 instance4 = {ENTITY_ID: 'category', INSTANCE_GUID: '3D9D0AE02A1611E9BBE39B9C6748A022'};1030 });1031 it('should report an error of RELATIONSHIP_IS_NOT_TIME_DEPENDENT', function (done) {1032 instance4.relationships = [1033 { RELATIONSHIP_ID: 'rs_app_category',1034 values:[1035 { action: 'expire', RELATIONSHIP_INSTANCE_GUID: '6A56A3D02A1A11E981F3C33C6FB0A7C1'}]1036 }1037 ];1038 entity.changeInstance(instance4, function (err) {1039 err.should.containDeep([ {1040 msgCat: 'ENTITY', msgName: 'RELATIONSHIP_IS_NOT_TIME_DEPENDENT', msgType: 'E'} ]);1041 done();1042 })1043 });1044 it('should report an error of RELATIONSHIP_IS_NOT_TIME_DEPENDENT', function (done) {1045 instance4.relationships = [1046 { RELATIONSHIP_ID: 'rs_app_category',1047 values:[1048 { action: 'extend', RELATIONSHIP_INSTANCE_GUID: '6A56A3D02A1A11E981F3C33C6FB0A7C1'}]1049 }1050 ];1051 entity.changeInstance(instance4, function (err) {1052 err.should.containDeep([ {1053 msgCat: 'ENTITY', msgName: 'RELATIONSHIP_IS_NOT_TIME_DEPENDENT', msgType: 'E'} ]);1054 done();1055 })1056 });1057 it('should report an error of RELATIONSHIP_INSTANCE_OVERLAP before inserting', function (done) {1058 instance4.relationships = [1059 { RELATIONSHIP_ID: 'rs_app_category',1060 values:[1061 { action: 'add',1062 PARTNER_INSTANCES:[ // App Modeling1063 {ENTITY_ID:'app',ROLE_ID:'portal_app',INSTANCE_GUID:'568822C02A0B11E98FB33576955DB73A' }1064 ]},1065 { action: 'add',1066 PARTNER_INSTANCES:[ // App Modeling1067 {ENTITY_ID:'app',ROLE_ID:'portal_app',INSTANCE_GUID:'568822C02A0B11E98FB33576955DB73A' }1068 ]}1069 ]1070 }1071 ];1072 entity.changeInstance(instance4, function (err) {1073 err.should.containDeep([ {1074 msgCat: 'ENTITY', msgName: 'RELATIONSHIP_INSTANCE_OVERLAP', msgType: 'E'} ]);1075 done();1076 })1077 });1078 it('should report an error of RELATIONSHIP_INSTANCE_OVERLAP after inserting', function (done) {1079 instance4.relationships = [1080 { RELATIONSHIP_ID: 'rs_app_category',1081 values:[1082 { action: 'add',1083 PARTNER_INSTANCES:[ // App Bubble1084 {ENTITY_ID:'app',ROLE_ID:'portal_app',INSTANCE_GUID:'ABAB7C202A0B11E98FB33576955DB73A' }1085 ]}1086 ]1087 }1088 ];1089 entity.changeInstance(instance4, function (err) {1090 err.should.containDeep([ {1091 msgCat: 'ENTITY', msgName: 'RELATIONSHIP_INSTANCE_OVERLAP', msgType: 'E'} ]);1092 done();1093 })1094 });1095 it('should add an app to the category successfully', function (done) {1096 instance4.relationships = [1097 { RELATIONSHIP_ID: 'rs_app_category',1098 values:[1099 { action: 'add',1100 PARTNER_INSTANCES:[ // App Modeling1101 {ENTITY_ID:'app',ROLE_ID:'portal_app',INSTANCE_GUID:'568822C02A0B11E98FB33576955DB73A' }1102 ]}1103 ]1104 }1105 ];1106 entity.changeInstance(instance4, function (err) {1107 should(err).eql(null);1108 entity.getInstanceByGUID('568822C02A0B11E98FB33576955DB73A', function (err, result) {1109 const relationship = result['relationships'].find( relationship => relationship.RELATIONSHIP_ID === 'rs_app_category');1110 relationshipGUID = relationship.values.find(1111 value => value.PARTNER_INSTANCES[0].INSTANCE_GUID === '3D9D0AE02A1611E9BBE39B9C6748A022')1112 .RELATIONSHIP_INSTANCE_GUID;1113 done();1114 });1115 })1116 });1117 it('should delete an app from the category successfully', function (done) {1118 instance4.relationships = [1119 { RELATIONSHIP_ID: 'rs_app_category',1120 values:[1121 { action: 'delete', RELATIONSHIP_INSTANCE_GUID: relationshipGUID}1122 ]1123 }1124 ];1125 entity.changeInstance(instance4, function (err) {1126 should(err).eql(null);1127 done();1128 })1129 })1130 });1131 describe('Overwrite an Entity', function () {1132 it('should report error as relationship not allow overwrite', function (done) {1133 let overwriteInstance = {1134 INSTANCE_GUID: instance.INSTANCE_GUID, ENTITY_ID: 'person',1135 person: {GENDER: 'male', HEIGHT: 171,HOBBY: 'Reading, Movie, Coding, Bike',1136 FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743E' },1137 r_employee:1138 [{USER_ID: 'DH999', COMPANY_ID: 'Darkhouse', DEPARTMENT_ID: 'Development',1139 TITLE: 'Developer', GENDER: 'Male'1140 }],1141 r_email:1142 [{EMAIL: 'dh999@hotmail.com', TYPE: null, PRIMARY: 1}],1143 r_user:1144 [{USER_ID: 'DH999', USER_NAME: 'VINCEZK', PASSWORD: null, PWD_STATE: null, LOCK: null,1145 DISPLAY_NAME: 'Zhang Kai', FAMILY_NAME: 'Zhang',GIVEN_NAME: null, MIDDLE_NAME: null1146 }],1147 relationships:[]1148 };1149 entity.overwriteInstance(overwriteInstance, function (err) {1150 err.should.containDeep([{msgName: 'OVERWRITE_RELATIONSHIPS_NOT_ALLOWED'}]);1151 done()1152 })1153 });1154 it('should report error as primary key is missing', function (done) {1155 let overwriteInstance = {1156 INSTANCE_GUID: instance.INSTANCE_GUID, ENTITY_ID: 'person',1157 person: {GENDER: 'male', HEIGHT: 171,HOBBY: 'Reading, Movie, Coding, Bike',1158 FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743E' },1159 r_employee:1160 [{COMPANY_ID: 'Darkhouse', DEPARTMENT_ID: 'Development',1161 TITLE: 'Developer', GENDER: 'Male'1162 }],1163 r_email:1164 [{EMAIL: 'dh999@hotmail.com', TYPE: null, PRIMARY: 1}],1165 r_user:1166 [{USER_NAME: 'VINCEZK', PASSWORD: null, PWD_STATE: null, LOCK: null,1167 DISPLAY_NAME: 'Zhang Kai', FAMILY_NAME: 'Zhang',GIVEN_NAME: null, MIDDLE_NAME: null1168 }]1169 };1170 entity.overwriteInstance(overwriteInstance, function (err) {1171 err.should.containDeep([{msgName: 'PRIMARY_KEY_MISSING'}]);1172 done()1173 })1174 });1175 it('should overwrite the instance successfully', function (done) {1176 let overwriteInstance = {1177 INSTANCE_GUID: instance.INSTANCE_GUID, ENTITY_ID: 'person',1178 person: {GENDER: 'Male', HEIGHT: 1.80, HOBBY: 'Reading, Movie',1179 FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743E'},1180 r_employee:1181 [{USER_ID: 'DH999', COMPANY_ID: 'DARKHOUSE', DEPARTMENT_ID: 'Development',1182 TITLE: 'Developer', GENDER: 'Male'1183 }],1184 r_email:1185 [{EMAIL: 'dh999@outlook.com', TYPE: 'PRIVATE', PRIMARY: 1},1186 {EMAIL: 'dh999@darkhouse.com', TYPE: 'WORK', PRIMARY: 0}],1187 r_user:1188 [{USER_ID: 'DH999', USER_NAME: 'VINCEZK', PASSWORD: null, PWD_STATE: 0, LOCK: null,1189 DISPLAY_NAME: 'Zhang Kai', FAMILY_NAME: 'Zhang',GIVEN_NAME: 'Kai', MIDDLE_NAME: null1190 }],1191 r_address: []1192 };1193 entity.overwriteInstance(overwriteInstance, function (err) {1194 should(err).eql(null);1195 entity.getInstanceByGUID(instance.INSTANCE_GUID, function (err, newInstance) {1196 newInstance.person.should.containDeep([{GENDER: 'Male', HEIGHT: 1.80, HOBBY: 'Reading, Movie',1197 FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743E', TYPE: 'employee', SYSTEM_ACCESS: 'PORTAL' }]);1198 newInstance.r_user.should.containDeep([{USER_ID: 'DH999', USER_NAME: 'VINCEZK', PASSWORD: null, PWD_STATE: 0, LOCK: null,1199 DISPLAY_NAME: 'Zhang Kai', FAMILY_NAME: 'Zhang',GIVEN_NAME: 'Kai', MIDDLE_NAME: null1200 }]);1201 newInstance.r_email.should.containDeep([{EMAIL: 'dh999@outlook.com', TYPE: 'PRIVATE', PRIMARY: 1},1202 {EMAIL: 'dh999@darkhouse.com', TYPE: 'WORK', PRIMARY: 0}]);1203 newInstance.r_employee.should.containDeep([{USER_ID: 'DH999', COMPANY_ID: 'DARKHOUSE', DEPARTMENT_ID: 'DEVELOPMENT',1204 TITLE: 'Developer', GENDER: 'Male'}]);1205 (typeof newInstance.r_address).should.be.equal('undefined');1206 (typeof newInstance.r_personalization).should.be.equal('undefined');1207 done();1208 });1209 })1210 });1211 it('should only overwrite explicated attributes', function (done) {1212 let overwriteInstance = {1213 INSTANCE_GUID: instance.INSTANCE_GUID, ENTITY_ID: 'person',1214 person: { HEIGHT: 1.83},1215 r_employee: {USER_ID: 'DH999'},1216 r_email: [{EMAIL: 'dh999@outlook.com'}, {EMAIL: 'dh999@darkhouse.com'}],1217 r_user: {USER_ID: 'DH999'}1218 };1219 entity.overwriteInstance(overwriteInstance, function (err) {1220 should(err).eql(null);1221 entity.getInstanceByGUID(instance.INSTANCE_GUID, function (err, newInstance) {1222 newInstance.person.should.containDeep([{GENDER: 'Male', HEIGHT: 1.83, HOBBY: 'Reading, Movie',1223 FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743E' }]);1224 newInstance.r_user.should.containDeep([{USER_ID: 'DH999', USER_NAME: 'VINCEZK', PASSWORD: null, PWD_STATE: 0, LOCK: null,1225 DISPLAY_NAME: 'Zhang Kai', FAMILY_NAME: 'Zhang',GIVEN_NAME: 'Kai', MIDDLE_NAME: null1226 }]);1227 newInstance.r_email.should.containDeep([{EMAIL: 'dh999@outlook.com', TYPE: 'PRIVATE', PRIMARY: 1},1228 {EMAIL: 'dh999@darkhouse.com', TYPE: 'WORK', PRIMARY: 0}]);1229 newInstance.r_employee.should.containDeep([{USER_ID: 'DH999', COMPANY_ID: 'DARKHOUSE', DEPARTMENT_ID: 'DEVELOPMENT',1230 TITLE: 'Developer', GENDER: 'Male'}]);1231 done();1232 });1233 })1234 });1235 });1236 describe('Entity Deletion', function () {1237 it('should soft delete an instance by GUID', function (done) {1238 entity.softDeleteInstanceByGUID(instance.INSTANCE_GUID, function (err) {1239 should(err).eql(null);1240 done();1241 })1242 });1243 it('should restore an instance', function (done) {1244 entity.restoreInstanceByGUID(instance.INSTANCE_GUID, function (errs) {1245 should(errs).eql(null);1246 done();1247 })1248 });1249 it('should soft delete an instance by ID', function (done) {1250 entity.softDeleteInstanceByID({RELATION_ID: 'person', FINGER_PRINT: instance.person.FINGER_PRINT}, function (err) {1251 should(err).eql(null);1252 let instance3 = {ENTITY_ID: 'person', INSTANCE_GUID: instance.INSTANCE_GUID,1253 r_user : {action:'update', USER_ID: 'DH999', DISPLAY_NAME: 'Zhang Kai', FAMILY_NAME: 'Zhang'}};1254 entity.changeInstance(instance3, function (err) {1255 err.should.containDeep([{1256 msgCat: 'ENTITY',1257 msgName: 'INSTANCE_MARKED_DELETE',1258 msgType: 'E'1259 }]);1260 done();1261 });1262 })1263 });1264 it('should restore an instance by ID', function (done) {1265 entity.restoreInstanceByID({RELATION_ID: 'person', FINGER_PRINT: instance.person.FINGER_PRINT}, function (err) {1266 should(err).eql(null);1267 done();1268 })1269 });1270 it('should fail to delete the instance from DB', function (done) {1271 entity.hardDeleteByID({RELATION_ID: 'r_user', USER_NAME: 'VINCEZK'}, function (err) {1272 err.should.containDeep([{1273 msgCat: 'ENTITY',1274 msgName: 'INSTANCE_NOT_MARKED_DELETE',1275 msgType: 'E'1276 }]);1277 done();1278 })1279 });1280 it('should soft delete an instance by GUID', function (done) {1281 entity.softDeleteInstanceByGUID(instance.INSTANCE_GUID, function (err) {1282 should(err).eql(null);1283 done();1284 })1285 });1286 it('should delete the instance from DB', function (done) {1287 entity.hardDeleteByGUID(instance.INSTANCE_GUID, function (err) {1288 should(err).eql(null);1289 done();1290 })1291 });1292 it('should delete the female instance from DB', function (done) {1293 entity.softDeleteInstanceByID({RELATION_ID: 'r_employee', USER_ID: 'DH998'}, function (err) {1294 should(err).eql(null);1295 entity.hardDeleteByID({RELATION_ID: 'r_employee', USER_ID: 'DH998'}, function (err) {1296 should(err).eql(null);1297 done();1298 })1299 })1300 })1301 });1302 describe( 'orchestration', function () {1303 const instance1 = { ENTITY_ID: 'person',1304 person: {HEIGHT: 1.75, GENDER: 'Male', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743E', HOBBY:'Game', TYPE: 'employee'},1305 r_email: [{EMAIL: 'DH999@darkhouse.com.cn', TYPE: 'PRIVATE', PRIMARY:1}],1306 r_employee: {USER_ID: 'DH999', COMPANY_ID:'DARKHOUSE', DEPARTMENT_ID: 'Development', TITLE: 'Developer', GENDER:'Male'}1307 };1308 const instance2 = { ENTITY_ID: 'person',1309 person: {HEIGHT: 1.65, GENDER: 'Female', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743F', HOBBY:'Drama', TYPE: 'employee'},1310 r_email: [{EMAIL: 'DH998@darkhouse.com.cn', TYPE: 'PRIVATE', PRIMARY:1}],1311 r_employee: {USER_ID: 'DH998', COMPANY_ID:'DARKHOUSE', DEPARTMENT_ID: 'Development', TITLE: 'Tester', GENDER:'Female'},1312 relationships: [{ RELATIONSHIP_ID: 'rs_marriage', values:[1313 { action: 'add', VALID_FROM:'', VALID_TO:'2030-12-31 00:00:00', REG_PLACE: 'SH',1314 PARTNER_INSTANCES:[{ENTITY_ID:'person',ROLE_ID:'husband',INSTANCE_GUID: '', NO_EXISTING_CHECK: true}]}]}]};1315 const instance3 = { ENTITY_ID: 'person',1316 person: {HEIGHT: 1.65, GENDER: 'Female', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743G', HOBBY:'Drawing', TYPE: 'employee'},1317 r_email: [{EMAIL: 'DH997@darkhouse.com.cn', TYPE: 'PRIVATE', PRIMARY:1}],1318 r_employee: {USER_ID: 'DH997', COMPANY_ID:'DARKHOUSE', DEPARTMENT_ID: 'Development', TITLE: 'Developer', GENDER:'Female'},1319 };1320 const operations = [1321 {1322 action: 'createInstance',1323 noCommit: true,1324 instance: instance11325 },1326 {1327 action: 'createInstance',1328 noCommit: true,1329 replacements: [{1330 movePath: [0, 'result', 'instance', 'INSTANCE_GUID'],1331 toPath: ['relationships', 0, 'values', 0, 'PARTNER_INSTANCES', 0, 'INSTANCE_GUID']1332 }],1333 instance: instance21334 }1335 ];1336 it('should create a husband and wife pair', function (done) {1337 entity.orchestrate( operations, function (errs, results) {1338 should(errs).eql(null);1339 done();1340 })1341 });1342 it('should return a husband and wife pair', function (done) {1343 const getOperations = [1344 {1345 action: 'getInstancePieceByGUID',1346 instance: {INSTANCE_GUID: operations[0].result.instance.INSTANCE_GUID,1347 RELATIONS: ['person', 'r_email', 'r_employee'], RELATIONSHIPS: ['rs_marriage']}1348 },1349 {1350 action: 'getInstancePieceByGUID',1351 instance: {INSTANCE_GUID: operations[1].result.instance.INSTANCE_GUID,1352 RELATIONS: ['person', 'r_email', 'r_employee'], RELATIONSHIPS: ['rs_marriage']}1353 }1354 ];1355 entity.orchestrate( getOperations, function (errs, results) {1356 should(errs).eql(null);1357 results[0].result.instance.should.containDeep(1358 { ENTITY_ID: 'person',1359 relationships: [{ RELATIONSHIP_ID: 'rs_marriage', SELF_ROLE_ID: 'husband',1360 values: [{PARTNER_INSTANCES: [{ ENTITY_ID: 'person', ROLE_ID: 'wife'} ], REG_PLACE: 'SH', COUNTRY: null}] } ],1361 person: [{GENDER: 'Male', HEIGHT: 1.75, HOBBY: 'Game', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743E',1362 TYPE: 'employee', SYSTEM_ACCESS: null, BIRTHDAY: null } ],1363 r_email: [{ EMAIL: 'DH999@darkhouse.com.cn', TYPE: 'PRIVATE', PRIMARY: 1 } ],1364 r_employee: [{USER_ID: 'DH999', COMPANY_ID: 'DARKHOUSE', DEPARTMENT_ID: 'DEVELOPMENT',1365 TITLE: 'Developer', GENDER: 'Male' } ] });1366 results[1].result.instance.should.containDeep(1367 { ENTITY_ID: 'person',1368 relationships: [{ RELATIONSHIP_ID: 'rs_marriage', SELF_ROLE_ID: 'wife',1369 values: [{PARTNER_INSTANCES: [{ ENTITY_ID: 'person', ROLE_ID: 'husband'} ], REG_PLACE: 'SH', COUNTRY: null}] } ],1370 person: [{GENDER: 'Female', HEIGHT: 1.65, HOBBY: 'Drama', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743F',1371 TYPE: 'employee', SYSTEM_ACCESS: null, BIRTHDAY: null } ],1372 r_email: [{ EMAIL: 'DH998@darkhouse.com.cn', TYPE: 'PRIVATE', PRIMARY: 1 } ],1373 r_employee: [{USER_ID: 'DH998', COMPANY_ID: 'DARKHOUSE', DEPARTMENT_ID: 'DEVELOPMENT',1374 TITLE: 'Tester', GENDER: 'Female' } ] });1375 done();1376 })1377 });1378 it('should create a new female person and change the relationship', function (done) {1379 const changeOperations = [1380 {1381 action: 'createInstance',1382 noCommit: true,1383 instance: instance31384 },1385 {1386 action: 'changeInstance',1387 noCommit: true,1388 replacements: [{1389 movePath: [0, 'result', 'instance', 'INSTANCE_GUID'],1390 toPath: ['relationships', 0, 'values', 1, 'PARTNER_INSTANCES', 0, 'INSTANCE_GUID']1391 }],1392 instance: {1393 ENTITY_ID: 'person', INSTANCE_GUID: instance1.INSTANCE_GUID,1394 relationships: [{ RELATIONSHIP_ID: 'rs_marriage', values:[1395 { action: 'expire', RELATIONSHIP_INSTANCE_GUID: instance2.relationships[0].values[0].RELATIONSHIP_INSTANCE_GUID},1396 { action: 'add', VALID_FROM:'', VALID_TO:'2030-12-31 00:00:00', REG_PLACE: 'SH',1397 PARTNER_INSTANCES:[{ENTITY_ID:'person',ROLE_ID:'wife',INSTANCE_GUID: '', NO_EXISTING_CHECK: true}]}]}]1398 }1399 }1400 ];1401 entity.orchestrate( changeOperations, function (errs) {1402 should(errs).eql(null);1403 done();1404 })1405 });1406 it('should return a husband and 2 wives', function (done) {1407 const getOperations = [1408 {1409 action: 'getInstancePieceByGUID',1410 instance: {INSTANCE_GUID: instance1.INSTANCE_GUID,1411 RELATIONSHIPS: ['rs_marriage']}1412 },1413 {1414 action: 'getInstancePieceByGUID',1415 instance: {INSTANCE_GUID: instance2.INSTANCE_GUID,1416 RELATIONSHIPS: ['rs_marriage']}1417 },1418 {1419 action: 'getInstancePieceByGUID',1420 instance: {INSTANCE_GUID: instance3.INSTANCE_GUID,1421 RELATIONS: ['person', 'r_email', 'r_employee'], RELATIONSHIPS: ['rs_marriage']}1422 }1423 ];1424 entity.orchestrate( getOperations, function (errs, results) {1425 should(errs).eql(null);1426 results[0].result.instance.should.containDeep(1427 { relationships:1428 [{ RELATIONSHIP_ID: 'rs_marriage', SELF_ROLE_ID: 'husband',1429 values: [{PARTNER_INSTANCES: [{ ENTITY_ID: 'person', ROLE_ID: 'wife'} ], REG_PLACE: 'SH', COUNTRY: null}] } ]1430 });1431 results[1].result.instance.relationships[0].values[0].VALID_FROM.should.eql(1432 results[1].result.instance.relationships[0].values[0].VALID_TO1433 );1434 results[2].result.instance.should.containDeep(1435 { ENTITY_ID: 'person',1436 relationships: [{ RELATIONSHIP_ID: 'rs_marriage', SELF_ROLE_ID: 'wife',1437 values: [{PARTNER_INSTANCES: [{ ENTITY_ID: 'person', ROLE_ID: 'husband'} ], REG_PLACE: 'SH', COUNTRY: null}] } ],1438 person: [{GENDER: 'Female', HEIGHT: 1.65, HOBBY: 'Drawing', FINGER_PRINT: 'CA67DE15727C72961EB4B6B59B76743G',1439 TYPE: 'employee', SYSTEM_ACCESS: null, BIRTHDAY: null } ],1440 r_email: [{ EMAIL: 'DH997@darkhouse.com.cn', TYPE: 'PRIVATE', PRIMARY: 1 } ],1441 r_employee: [{USER_ID: 'DH997', COMPANY_ID: 'DARKHOUSE', DEPARTMENT_ID: 'DEVELOPMENT',1442 TITLE: 'Developer', GENDER: 'Female' } ] });1443 done();1444 })1445 });1446 it('should delete all the instances', function (done) {1447 const deleteOperations = [1448 {1449 action: 'softDeleteInstanceByGUID',1450 instance: {INSTANCE_GUID: instance1.INSTANCE_GUID}1451 },1452 {1453 action: 'softDeleteInstanceByGUID',1454 instance: {INSTANCE_GUID: instance2.INSTANCE_GUID}1455 },1456 {1457 action: 'softDeleteInstanceByGUID',1458 instance: {INSTANCE_GUID: instance3.INSTANCE_GUID}1459 },1460 {1461 action: 'hardDeleteByGUID',1462 instance: {INSTANCE_GUID: instance1.INSTANCE_GUID}1463 },1464 {1465 action: 'hardDeleteByGUID',1466 instance: {INSTANCE_GUID: instance2.INSTANCE_GUID}1467 },1468 {1469 action: 'hardDeleteByGUID',1470 instance: {INSTANCE_GUID: instance3.INSTANCE_GUID}1471 }1472 ];1473 entity.orchestrate( deleteOperations, function (errs) {1474 should(errs).eql(null);1475 done();1476 })1477 });1478 });1479 after('Close the MDB', function (done) {1480 entity.entityDB.closeMDB(done);1481 })...

Full Screen

Full Screen

nav-controller.spec.ts

Source:nav-controller.spec.ts Github

copy

Full Screen

1import { mockNavController, mockView, mockViews,2 MockView1, MockView2, MockView3, MockView4, MockView5 } from '../../util/mock-providers';3import { NavControllerBase } from '../nav-controller-base';4import { NavOptions, DIRECTION_FORWARD, DIRECTION_BACK } from '../nav-util';5import { ViewController } from '../view-controller';6describe('NavController', () => {7 describe('push and pop', () => {8 it('should push multiple times and pop multiple times', () => {9 let push1Done = jasmine.createSpy('PushDone');10 let push2Done = jasmine.createSpy('PushDone');11 let push3Done = jasmine.createSpy('PushDone');12 let push4Done = jasmine.createSpy('PushDone');13 let pop1Done = jasmine.createSpy('PopDone');14 let pop2Done = jasmine.createSpy('PopDone');15 let pop3Done = jasmine.createSpy('PopDone');16 // Push 117 nav.push(MockView1, null, { animate: false }, push1Done);18 let hasCompleted = true;19 let requiresTransition = true;20 expect(push1Done).toHaveBeenCalledWith(21 hasCompleted, requiresTransition, 'MockView1', undefined, DIRECTION_FORWARD22 );23 expect(nav.length()).toEqual(1);24 expect(nav.getByIndex(0).component).toEqual(MockView1);25 // Push 226 nav.push(MockView2, null, { animate: false }, push2Done);27 expect(push2Done).toHaveBeenCalledWith(28 hasCompleted, requiresTransition, 'MockView2', 'MockView1', DIRECTION_FORWARD29 );30 expect(nav.length()).toEqual(2);31 expect(nav.getByIndex(0).component).toEqual(MockView1);32 expect(nav.getByIndex(1).component).toEqual(MockView2);33 // Push 334 nav.push(MockView3, null, { animate: false }, push3Done);35 expect(push3Done).toHaveBeenCalledWith(36 hasCompleted, requiresTransition, 'MockView3', 'MockView2', DIRECTION_FORWARD37 );38 expect(nav.length()).toEqual(3);39 expect(nav.getByIndex(0).component).toEqual(MockView1);40 expect(nav.getByIndex(1).component).toEqual(MockView2);41 expect(nav.getByIndex(2).component).toEqual(MockView3);42 // Push 443 nav.push(MockView4, null, { animate: false }, push4Done);44 expect(push4Done).toHaveBeenCalledWith(45 hasCompleted, requiresTransition, 'MockView4', 'MockView3', DIRECTION_FORWARD46 );47 expect(nav.length()).toEqual(4);48 expect(nav.getByIndex(0).component).toEqual(MockView1);49 expect(nav.getByIndex(1).component).toEqual(MockView2);50 expect(nav.getByIndex(2).component).toEqual(MockView3);51 expect(nav.getByIndex(3).component).toEqual(MockView4);52 // Pop 153 nav.pop({ animate: false }, pop1Done);54 expect(pop1Done).toHaveBeenCalledWith(55 hasCompleted, requiresTransition, 'MockView3', 'MockView4', DIRECTION_BACK56 );57 expect(nav.length()).toEqual(3);58 expect(nav.getByIndex(0).component).toEqual(MockView1);59 expect(nav.getByIndex(1).component).toEqual(MockView2);60 expect(nav.getByIndex(2).component).toEqual(MockView3);61 // Pop 262 nav.pop({ animate: false }, pop2Done);63 expect(pop2Done).toHaveBeenCalledWith(64 hasCompleted, requiresTransition, 'MockView2', 'MockView3', DIRECTION_BACK65 );66 expect(nav.length()).toEqual(2);67 expect(nav.getByIndex(0).component).toEqual(MockView1);68 expect(nav.getByIndex(1).component).toEqual(MockView2);69 // Pop 370 nav.pop({ animate: false }, pop3Done);71 expect(pop3Done).toHaveBeenCalledWith(72 hasCompleted, requiresTransition, 'MockView1', 'MockView2', DIRECTION_BACK73 );74 expect(nav.length()).toEqual(1);75 expect(nav.getByIndex(0).component).toEqual(MockView1);76 });77 });78 describe('push', () => {79 it('should push a component as the first view', () => {80 nav.push(MockView1, null, null, trnsDone);81 let hasCompleted = true;82 let requiresTransition = true;83 expect(trnsDone).toHaveBeenCalledWith(84 hasCompleted, requiresTransition, 'MockView1', undefined, DIRECTION_FORWARD85 );86 expect(nav.length()).toEqual(1);87 expect(nav.getByIndex(0).component).toEqual(MockView1);88 expect(nav.isTransitioning()).toEqual(false);89 });90 it('should push a component as the second view at the end', () => {91 mockViews(nav, [mockView(MockView1)]);92 nav.push(MockView2, null, null, trnsDone);93 let hasCompleted = true;94 let requiresTransition = true;95 expect(trnsDone).toHaveBeenCalledWith(96 hasCompleted, requiresTransition, 'MockView2', 'MockView1', DIRECTION_FORWARD97 );98 expect(nav.length()).toEqual(2);99 expect(nav.getByIndex(0).component).toEqual(MockView1);100 expect(nav.getByIndex(1).component).toEqual(MockView2);101 expect(nav.isTransitioning()).toEqual(false);102 });103 it('should push a ViewController as the second view and fire lifecycles', () => {104 let view1 = mockView();105 let view2 = mockView();106 let instance1 = spyOnLifecycles(view1);107 let instance2 = spyOnLifecycles(view2);108 mockViews(nav, [view1]);109 nav.push(view2, null, null, trnsDone);110 expect(instance1.ionViewDidLoad).not.toHaveBeenCalled();111 expect(instance1.ionViewCanEnter).not.toHaveBeenCalled();112 expect(instance1.ionViewWillEnter).not.toHaveBeenCalled();113 expect(instance1.ionViewDidEnter).not.toHaveBeenCalled();114 expect(instance1.ionViewCanLeave).toHaveBeenCalled();115 expect(instance1.ionViewWillLeave).toHaveBeenCalled();116 expect(instance1.ionViewDidLeave).toHaveBeenCalled();117 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();118 expect(instance2.ionViewDidLoad).toHaveBeenCalled();119 expect(instance2.ionViewCanEnter).toHaveBeenCalled();120 expect(instance2.ionViewWillEnter).toHaveBeenCalled();121 expect(instance2.ionViewDidEnter).toHaveBeenCalled();122 expect(instance2.ionViewCanLeave).not.toHaveBeenCalled();123 expect(instance2.ionViewWillLeave).not.toHaveBeenCalled();124 expect(instance2.ionViewDidLeave).not.toHaveBeenCalled();125 expect(instance2.ionViewWillUnload).not.toHaveBeenCalled();126 let hasCompleted = true;127 let requiresTransition = true;128 expect(trnsDone).toHaveBeenCalledWith(129 hasCompleted, requiresTransition, 'MockView', 'MockView', DIRECTION_FORWARD130 );131 expect(nav.length()).toEqual(2);132 });133 });134 describe('insert', () => {135 it('should not modify the view id', () => {136 let view = mockView(MockView4);137 view.id = 'custom_id';138 nav.insert(0, view);139 expect(view.id).toEqual('custom_id');140 });141 it('should insert at the begining with no async transition', () => {142 let view4 = mockView(MockView4);143 let instance4 = spyOnLifecycles(view4);144 let opts: NavOptions = {};145 mockViews(nav, [mockView(MockView1), mockView(MockView2), mockView(MockView3)]);146 nav.insert(0, view4, null, opts, trnsDone);147 expect(instance4.ionViewDidLoad).not.toHaveBeenCalled();148 expect(instance4.ionViewCanEnter).not.toHaveBeenCalled();149 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();150 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();151 expect(instance4.ionViewCanLeave).not.toHaveBeenCalled();152 expect(instance4.ionViewWillLeave).not.toHaveBeenCalled();153 expect(instance4.ionViewDidLeave).not.toHaveBeenCalled();154 expect(instance4.ionViewWillUnload).not.toHaveBeenCalled();155 let hasCompleted = true;156 let requiresTransition = false;157 expect(trnsDone).toHaveBeenCalledWith(158 hasCompleted, requiresTransition, undefined, undefined, undefined159 );160 expect(nav.length()).toEqual(4);161 expect(nav.first().component).toEqual(MockView4);162 expect(nav.last().component).toEqual(MockView3);163 });164 it('should insert at the end when given -1', () => {165 let opts: NavOptions = {};166 mockViews(nav, [mockView(MockView1)]);167 nav.insert(-1, MockView2, null, opts, trnsDone);168 let hasCompleted = true;169 let requiresTransition = true;170 expect(trnsDone).toHaveBeenCalledWith(171 hasCompleted, requiresTransition, 'MockView2', 'MockView1', DIRECTION_FORWARD172 );173 expect(nav.length()).toEqual(2);174 expect(nav.last().component).toEqual(MockView2);175 });176 it('should insert at the end when given a number greater than actual length', () => {177 mockViews(nav, [mockView(MockView1)]);178 nav.insert(9999, MockView2, null, null, trnsDone);179 let hasCompleted = true;180 let requiresTransition = true;181 expect(trnsDone).toHaveBeenCalledWith(182 hasCompleted, requiresTransition, 'MockView2', 'MockView1', DIRECTION_FORWARD183 );184 expect(nav.length()).toEqual(2);185 expect(nav.last().component).toEqual(MockView2);186 });187 it('should not insert if null view', () => {188 mockViews(nav, [mockView(MockView1)]);189 nav.insert(-1, null, null, null, trnsDone);190 let hasCompleted = false;191 let requiresTransition = false;192 let rejectReason = 'invalid views to insert';193 expect(trnsDone).toHaveBeenCalledWith(hasCompleted, requiresTransition, rejectReason);194 expect(nav.length()).toEqual(1);195 expect(nav.last().component).toEqual(MockView1);196 });197 it('should not insert any view in the stack if canLeave returns false', () => {198 let view1 = mockView(MockView1);199 let view2 = mockView(MockView2);200 let view3 = mockView(MockView3);201 mockViews(nav, [view1, view2]);202 let instance2 = spyOnLifecycles(view2);203 let count = 0;204 instance2.ionViewCanLeave = function () {205 count++;206 return (count === 3);207 };208 nav.push(view3);209 expect(nav.length()).toEqual(2);210 nav.push(view3);211 expect(nav.length()).toEqual(2);212 nav.push(view3);213 expect(nav.length()).toEqual(3);214 });215 it('should not remove any view from the stack if canLeave returns false', () => {216 let view1 = mockView(MockView1);217 let view2 = mockView(MockView2);218 mockViews(nav, [view1, view2]);219 let instance2 = spyOnLifecycles(view2);220 let count = 0;221 instance2.ionViewCanLeave = function () {222 count++;223 return (count === 3);224 };225 nav.pop();226 expect(nav.length()).toEqual(2);227 nav.pop();228 expect(nav.length()).toEqual(2);229 nav.pop();230 expect(nav.length()).toEqual(1);231 });232 });233 describe('insertPages', () => {234 it('should insert all pages in the middle', () => {235 let view4 = mockView(MockView4);236 let instance4 = spyOnLifecycles(view4);237 mockViews(nav, [mockView(MockView1), mockView(MockView2), mockView(MockView3)]);238 nav.insertPages(1, [view4, mockView(MockView5)], null, trnsDone);239 expect(instance4.ionViewDidLoad).not.toHaveBeenCalled();240 expect(instance4.ionViewCanEnter).not.toHaveBeenCalled();241 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();242 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();243 expect(instance4.ionViewCanLeave).not.toHaveBeenCalled();244 expect(instance4.ionViewWillLeave).not.toHaveBeenCalled();245 expect(instance4.ionViewDidLeave).not.toHaveBeenCalled();246 expect(instance4.ionViewWillUnload).not.toHaveBeenCalled();247 let hasCompleted = true;248 let requiresTransition = false;249 expect(trnsDone).toHaveBeenCalledWith(250 hasCompleted, requiresTransition, undefined, undefined, undefined251 );252 expect(nav.length()).toEqual(5);253 expect(nav.getByIndex(0).component).toEqual(MockView1);254 expect(nav.getByIndex(1).component).toEqual(MockView4);255 expect(nav.getByIndex(2).component).toEqual(MockView5);256 expect(nav.getByIndex(3).component).toEqual(MockView2);257 expect(nav.getByIndex(4).component).toEqual(MockView3);258 expect(nav.getByIndex(1)._nav).toEqual(nav);259 expect(nav.getByIndex(2)._nav).toEqual(nav);260 });261 });262 describe('pop', () => {263 it('should not pop when no views in the stack', () => {264 nav.pop(null, trnsDone);265 let hasCompleted = false;266 let requiresTransition = false;267 expect(trnsDone).toHaveBeenCalledWith(268 hasCompleted, requiresTransition, 'no views in the stack to be removed'269 );270 expect(nav.length()).toEqual(0);271 expect(nav.isTransitioning()).toEqual(false);272 });273 it('should remove the last view and fire lifecycles', () => {274 let view1 = mockView(MockView1);275 let view2 = mockView(MockView2);276 mockViews(nav, [view1, view2]);277 let instance1 = spyOnLifecycles(view1);278 let instance2 = spyOnLifecycles(view2);279 nav.pop(null, trnsDone);280 expect(instance1.ionViewDidLoad).toHaveBeenCalled();281 expect(instance1.ionViewCanEnter).toHaveBeenCalled();282 expect(instance1.ionViewWillEnter).toHaveBeenCalled();283 expect(instance1.ionViewDidEnter).toHaveBeenCalled();284 expect(instance1.ionViewCanLeave).not.toHaveBeenCalled();285 expect(instance1.ionViewWillLeave).not.toHaveBeenCalled();286 expect(instance1.ionViewDidLeave).not.toHaveBeenCalled();287 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();288 expect(instance2.ionViewDidLoad).not.toHaveBeenCalled();289 expect(instance2.ionViewCanEnter).not.toHaveBeenCalled();290 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();291 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();292 expect(instance2.ionViewCanLeave).toHaveBeenCalled();293 expect(instance2.ionViewWillLeave).toHaveBeenCalled();294 expect(instance2.ionViewDidLeave).toHaveBeenCalled();295 expect(instance2.ionViewWillUnload).toHaveBeenCalled();296 let hasCompleted = true;297 let requiresTransition = true;298 expect(trnsDone).toHaveBeenCalledWith(299 hasCompleted, requiresTransition, 'MockView1', 'MockView2', DIRECTION_BACK300 );301 expect(nav.length()).toEqual(1);302 expect(nav.getByIndex(0).component).toEqual(MockView1);303 expect(nav.isTransitioning()).toEqual(false);304 });305 });306 describe('popTo', () => {307 it('should pop to a view', () => {308 let view1 = mockView(MockView1);309 let view2 = mockView(MockView2);310 let view3 = mockView(MockView3);311 mockViews(nav, [view1, view2, view3]);312 nav.popTo(view2, null, trnsDone);313 let hasCompleted = true;314 let requiresTransition = true;315 expect(trnsDone).toHaveBeenCalledWith(316 hasCompleted, requiresTransition, 'MockView2', 'MockView3', DIRECTION_BACK317 );318 expect(nav.length()).toEqual(2);319 expect(nav.getByIndex(0).component).toEqual(MockView1);320 expect(nav.getByIndex(1).component).toEqual(MockView2);321 });322 it('should pop to using an index number', () => {323 let view1 = mockView(MockView1);324 let view2 = mockView(MockView2);325 let view3 = mockView(MockView3);326 let view4 = mockView(MockView4);327 mockViews(nav, [view1, view2, view3, view4]);328 nav.popTo(1, null, trnsDone);329 let hasCompleted = true;330 let requiresTransition = true;331 expect(trnsDone).toHaveBeenCalledWith(332 hasCompleted, requiresTransition, 'MockView2', 'MockView4', DIRECTION_BACK333 );334 expect(nav.length()).toEqual(2);335 expect(nav.getByIndex(0).component).toEqual(MockView1);336 expect(nav.getByIndex(1).component).toEqual(MockView2);337 });338 it('should pop to first using an index number', () => {339 let view1 = mockView(MockView1);340 let view2 = mockView(MockView2);341 let view3 = mockView(MockView3);342 let view4 = mockView(MockView4);343 mockViews(nav, [view1, view2, view3, view4]);344 let instance1 = spyOnLifecycles(view1);345 let instance2 = spyOnLifecycles(view2);346 let instance3 = spyOnLifecycles(view3);347 let instance4 = spyOnLifecycles(view4);348 nav.popTo(0, null, trnsDone);349 expect(instance1.ionViewDidLoad).toHaveBeenCalled();350 expect(instance1.ionViewCanEnter).toHaveBeenCalled();351 expect(instance1.ionViewWillEnter).toHaveBeenCalled();352 expect(instance1.ionViewDidEnter).toHaveBeenCalled();353 expect(instance1.ionViewCanLeave).not.toHaveBeenCalled();354 expect(instance1.ionViewWillLeave).not.toHaveBeenCalled();355 expect(instance1.ionViewDidLeave).not.toHaveBeenCalled();356 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();357 expect(instance2.ionViewDidLoad).not.toHaveBeenCalled();358 expect(instance2.ionViewCanEnter).not.toHaveBeenCalled();359 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();360 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();361 expect(instance2.ionViewCanLeave).not.toHaveBeenCalled();362 expect(instance2.ionViewWillLeave).toHaveBeenCalled();363 expect(instance2.ionViewDidLeave).toHaveBeenCalled();364 expect(instance2.ionViewWillUnload).toHaveBeenCalled();365 expect(instance3.ionViewDidLoad).not.toHaveBeenCalled();366 expect(instance3.ionViewCanEnter).not.toHaveBeenCalled();367 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();368 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();369 expect(instance3.ionViewCanLeave).not.toHaveBeenCalled();370 expect(instance3.ionViewWillLeave).toHaveBeenCalled();371 expect(instance3.ionViewDidLeave).toHaveBeenCalled();372 expect(instance3.ionViewWillUnload).toHaveBeenCalled();373 expect(instance4.ionViewDidLoad).not.toHaveBeenCalled();374 expect(instance4.ionViewCanEnter).not.toHaveBeenCalled();375 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();376 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();377 expect(instance4.ionViewCanLeave).toHaveBeenCalled();378 expect(instance4.ionViewWillLeave).toHaveBeenCalled();379 expect(instance4.ionViewDidLeave).toHaveBeenCalled();380 expect(instance4.ionViewWillUnload).toHaveBeenCalled();381 let hasCompleted = true;382 let requiresTransition = true;383 expect(trnsDone).toHaveBeenCalledWith(384 hasCompleted, requiresTransition, 'MockView1', 'MockView4', DIRECTION_BACK385 );386 expect(nav.length()).toEqual(1);387 expect(nav.getByIndex(0).component).toEqual(MockView1);388 });389 });390 describe('popToRoot', () => {391 it('should pop to the first view', () => {392 let view1 = mockView(MockView1);393 let view2 = mockView(MockView2);394 let view3 = mockView(MockView3);395 let view4 = mockView(MockView4);396 mockViews(nav, [view1, view2, view3, view4]);397 let instance1 = spyOnLifecycles(view1);398 let instance2 = spyOnLifecycles(view2);399 let instance3 = spyOnLifecycles(view3);400 let instance4 = spyOnLifecycles(view4);401 nav.popToRoot(null, trnsDone);402 expect(instance1.ionViewDidLoad).toHaveBeenCalled();403 expect(instance1.ionViewCanEnter).toHaveBeenCalled();404 expect(instance1.ionViewWillEnter).toHaveBeenCalled();405 expect(instance1.ionViewDidEnter).toHaveBeenCalled();406 expect(instance1.ionViewCanLeave).not.toHaveBeenCalled();407 expect(instance1.ionViewWillLeave).not.toHaveBeenCalled();408 expect(instance1.ionViewDidLeave).not.toHaveBeenCalled();409 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();410 expect(instance2.ionViewDidLoad).not.toHaveBeenCalled();411 expect(instance2.ionViewCanEnter).not.toHaveBeenCalled();412 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();413 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();414 expect(instance2.ionViewCanLeave).not.toHaveBeenCalled();415 expect(instance2.ionViewWillLeave).toHaveBeenCalled();416 expect(instance2.ionViewDidLeave).toHaveBeenCalled();417 expect(instance2.ionViewWillUnload).toHaveBeenCalled();418 expect(instance3.ionViewDidLoad).not.toHaveBeenCalled();419 expect(instance3.ionViewCanEnter).not.toHaveBeenCalled();420 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();421 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();422 expect(instance3.ionViewCanLeave).not.toHaveBeenCalled();423 expect(instance3.ionViewWillLeave).toHaveBeenCalled();424 expect(instance3.ionViewDidLeave).toHaveBeenCalled();425 expect(instance3.ionViewWillUnload).toHaveBeenCalled();426 expect(instance4.ionViewDidLoad).not.toHaveBeenCalled();427 expect(instance4.ionViewCanEnter).not.toHaveBeenCalled();428 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();429 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();430 expect(instance4.ionViewCanLeave).toHaveBeenCalled();431 expect(instance4.ionViewWillLeave).toHaveBeenCalled();432 expect(instance4.ionViewDidLeave).toHaveBeenCalled();433 expect(instance4.ionViewWillUnload).toHaveBeenCalled();434 let hasCompleted = true;435 let requiresTransition = true;436 expect(trnsDone).toHaveBeenCalledWith(437 hasCompleted, requiresTransition, 'MockView1', 'MockView4', DIRECTION_BACK438 );439 expect(nav.length()).toEqual(1);440 expect(nav.getByIndex(0).component).toEqual(MockView1);441 });442 });443 describe('remove', () => {444 it('should remove the first three views in the beginning, no last view transition', () => {445 let view1 = mockView(MockView1);446 let view2 = mockView(MockView2);447 let view3 = mockView(MockView3);448 let view4 = mockView(MockView4);449 mockViews(nav, [view1, view2, view3, view4]);450 let instance1 = spyOnLifecycles(view1);451 let instance2 = spyOnLifecycles(view2);452 let instance3 = spyOnLifecycles(view3);453 let instance4 = spyOnLifecycles(view4);454 nav.remove(0, 3, null, trnsDone);455 expect(instance1.ionViewDidLoad).not.toHaveBeenCalled();456 expect(instance1.ionViewCanEnter).not.toHaveBeenCalled();457 expect(instance1.ionViewWillEnter).not.toHaveBeenCalled();458 expect(instance1.ionViewDidEnter).not.toHaveBeenCalled();459 expect(instance1.ionViewCanLeave).not.toHaveBeenCalled();460 expect(instance1.ionViewWillLeave).toHaveBeenCalled();461 expect(instance1.ionViewDidLeave).toHaveBeenCalled();462 expect(instance1.ionViewWillUnload).toHaveBeenCalled();463 expect(instance2.ionViewDidLoad).not.toHaveBeenCalled();464 expect(instance2.ionViewCanEnter).not.toHaveBeenCalled();465 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();466 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();467 expect(instance2.ionViewCanLeave).not.toHaveBeenCalled();468 expect(instance2.ionViewWillLeave).toHaveBeenCalled();469 expect(instance2.ionViewDidLeave).toHaveBeenCalled();470 expect(instance2.ionViewWillUnload).toHaveBeenCalled();471 expect(instance3.ionViewDidLoad).not.toHaveBeenCalled();472 expect(instance3.ionViewCanEnter).not.toHaveBeenCalled();473 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();474 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();475 expect(instance3.ionViewCanLeave).not.toHaveBeenCalled();476 expect(instance3.ionViewWillLeave).toHaveBeenCalled();477 expect(instance3.ionViewDidLeave).toHaveBeenCalled();478 expect(instance3.ionViewWillUnload).toHaveBeenCalled();479 expect(instance4.ionViewDidLoad).not.toHaveBeenCalled();480 expect(instance4.ionViewCanEnter).not.toHaveBeenCalled();481 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();482 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();483 expect(instance4.ionViewCanLeave).not.toHaveBeenCalled();484 expect(instance4.ionViewWillLeave).not.toHaveBeenCalled();485 expect(instance4.ionViewDidLeave).not.toHaveBeenCalled();486 expect(instance4.ionViewWillUnload).not.toHaveBeenCalled();487 let hasCompleted = true;488 let requiresTransition = false;489 expect(trnsDone).toHaveBeenCalledWith(490 hasCompleted, requiresTransition, undefined, undefined, undefined491 );492 expect(nav.length()).toEqual(1);493 expect(nav.getByIndex(0).component).toEqual(MockView4);494 });495 it('should remove two views in the middle', () => {496 let view1 = mockView(MockView1);497 let view2 = mockView(MockView2);498 let view3 = mockView(MockView3);499 let view4 = mockView(MockView4);500 let view5 = mockView(MockView5);501 mockViews(nav, [view1, view2, view3, view4, view5]);502 let instance1 = spyOnLifecycles(view1);503 let instance2 = spyOnLifecycles(view2);504 let instance3 = spyOnLifecycles(view3);505 let instance4 = spyOnLifecycles(view4);506 let instance5 = spyOnLifecycles(view5);507 nav.remove(2, 2, null, trnsDone);508 expect(instance1.ionViewDidLoad).not.toHaveBeenCalled();509 expect(instance1.ionViewCanEnter).not.toHaveBeenCalled();510 expect(instance1.ionViewWillEnter).not.toHaveBeenCalled();511 expect(instance1.ionViewDidEnter).not.toHaveBeenCalled();512 expect(instance1.ionViewCanLeave).not.toHaveBeenCalled();513 expect(instance1.ionViewWillLeave).not.toHaveBeenCalled();514 expect(instance1.ionViewDidLeave).not.toHaveBeenCalled();515 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();516 expect(instance2.ionViewDidLoad).not.toHaveBeenCalled();517 expect(instance2.ionViewCanEnter).not.toHaveBeenCalled();518 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();519 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();520 expect(instance2.ionViewCanLeave).not.toHaveBeenCalled();521 expect(instance2.ionViewWillLeave).not.toHaveBeenCalled();522 expect(instance2.ionViewDidLeave).not.toHaveBeenCalled();523 expect(instance2.ionViewWillUnload).not.toHaveBeenCalled();524 expect(instance3.ionViewDidLoad).not.toHaveBeenCalled();525 expect(instance3.ionViewCanEnter).not.toHaveBeenCalled();526 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();527 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();528 expect(instance3.ionViewCanLeave).not.toHaveBeenCalled();529 expect(instance3.ionViewWillLeave).toHaveBeenCalled();530 expect(instance3.ionViewDidLeave).toHaveBeenCalled();531 expect(instance3.ionViewWillUnload).toHaveBeenCalled();532 expect(instance4.ionViewDidLoad).not.toHaveBeenCalled();533 expect(instance4.ionViewCanEnter).not.toHaveBeenCalled();534 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();535 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();536 expect(instance4.ionViewCanLeave).not.toHaveBeenCalled();537 expect(instance4.ionViewWillLeave).toHaveBeenCalled();538 expect(instance4.ionViewDidLeave).toHaveBeenCalled();539 expect(instance4.ionViewWillUnload).toHaveBeenCalled();540 expect(instance5.ionViewDidLoad).not.toHaveBeenCalled();541 expect(instance5.ionViewCanEnter).not.toHaveBeenCalled();542 expect(instance5.ionViewWillEnter).not.toHaveBeenCalled();543 expect(instance5.ionViewDidEnter).not.toHaveBeenCalled();544 expect(instance5.ionViewCanLeave).not.toHaveBeenCalled();545 expect(instance5.ionViewWillLeave).not.toHaveBeenCalled();546 expect(instance5.ionViewDidLeave).not.toHaveBeenCalled();547 expect(instance5.ionViewWillUnload).not.toHaveBeenCalled();548 let hasCompleted = true;549 let requiresTransition = false;550 expect(trnsDone).toHaveBeenCalledWith(551 hasCompleted, requiresTransition, undefined, undefined, undefined552 );553 expect(nav.length()).toEqual(3);554 expect(nav.getByIndex(0).component).toEqual(MockView1);555 expect(nav.getByIndex(1).component).toEqual(MockView2);556 expect(nav.getByIndex(2).component).toEqual(MockView5);557 });558 it('should remove the last two views at the end', () => {559 let view1 = mockView(MockView1);560 let view2 = mockView(MockView2);561 let view3 = mockView(MockView3);562 let view4 = mockView(MockView4);563 mockViews(nav, [view1, view2, view3, view4]);564 let instance1 = spyOnLifecycles(view1);565 let instance2 = spyOnLifecycles(view2);566 let instance3 = spyOnLifecycles(view3);567 let instance4 = spyOnLifecycles(view4);568 nav.remove(2, 2, null, trnsDone);569 expect(instance1.ionViewDidLoad).not.toHaveBeenCalled();570 expect(instance1.ionViewCanEnter).not.toHaveBeenCalled();571 expect(instance1.ionViewWillEnter).not.toHaveBeenCalled();572 expect(instance1.ionViewDidEnter).not.toHaveBeenCalled();573 expect(instance1.ionViewCanLeave).not.toHaveBeenCalled();574 expect(instance1.ionViewWillLeave).not.toHaveBeenCalled();575 expect(instance1.ionViewDidLeave).not.toHaveBeenCalled();576 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();577 expect(instance2.ionViewDidLoad).toHaveBeenCalled();578 expect(instance2.ionViewCanEnter).toHaveBeenCalled();579 expect(instance2.ionViewWillEnter).toHaveBeenCalled();580 expect(instance2.ionViewDidEnter).toHaveBeenCalled();581 expect(instance2.ionViewCanLeave).not.toHaveBeenCalled();582 expect(instance2.ionViewWillLeave).not.toHaveBeenCalled();583 expect(instance2.ionViewDidLeave).not.toHaveBeenCalled();584 expect(instance2.ionViewWillUnload).not.toHaveBeenCalled();585 expect(instance3.ionViewDidLoad).not.toHaveBeenCalled();586 expect(instance3.ionViewCanEnter).not.toHaveBeenCalled();587 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();588 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();589 expect(instance3.ionViewCanLeave).not.toHaveBeenCalled();590 expect(instance3.ionViewWillLeave).toHaveBeenCalled();591 expect(instance3.ionViewDidLeave).toHaveBeenCalled();592 expect(instance3.ionViewWillUnload).toHaveBeenCalled();593 expect(instance4.ionViewDidLoad).not.toHaveBeenCalled();594 expect(instance4.ionViewCanEnter).not.toHaveBeenCalled();595 expect(instance4.ionViewWillEnter).not.toHaveBeenCalled();596 expect(instance4.ionViewDidEnter).not.toHaveBeenCalled();597 expect(instance4.ionViewCanLeave).toHaveBeenCalled();598 expect(instance4.ionViewWillLeave).toHaveBeenCalled();599 expect(instance4.ionViewDidLeave).toHaveBeenCalled();600 expect(instance4.ionViewWillUnload).toHaveBeenCalled();601 let hasCompleted = true;602 let requiresTransition = true;603 expect(trnsDone).toHaveBeenCalledWith(604 hasCompleted, requiresTransition, 'MockView2', 'MockView4', DIRECTION_BACK605 );606 expect(nav.length()).toEqual(2);607 expect(nav.getByIndex(0).component).toEqual(MockView1);608 expect(nav.getByIndex(1).component).toEqual(MockView2);609 });610 });611 describe('setRoot', () => {612 it('should set a ViewController as the root when its the last view, no transition', () => {613 let view1 = mockView(MockView1);614 let view2 = mockView(MockView2);615 let view3 = mockView(MockView3);616 mockViews(nav, [view1, view2, view3]);617 let instance1 = spyOnLifecycles(view1);618 let instance2 = spyOnLifecycles(view2);619 let instance3 = spyOnLifecycles(view3);620 nav.setRoot(view3, null, null, trnsDone);621 expect(instance1.ionViewDidLoad).not.toHaveBeenCalled();622 expect(instance1.ionViewCanEnter).not.toHaveBeenCalled();623 expect(instance1.ionViewWillEnter).not.toHaveBeenCalled();624 expect(instance1.ionViewDidEnter).not.toHaveBeenCalled();625 expect(instance1.ionViewCanLeave).not.toHaveBeenCalled();626 expect(instance1.ionViewWillLeave).toHaveBeenCalled();627 expect(instance1.ionViewDidLeave).toHaveBeenCalled();628 expect(instance1.ionViewWillUnload).toHaveBeenCalled();629 expect(instance2.ionViewDidLoad).not.toHaveBeenCalled();630 expect(instance2.ionViewCanEnter).not.toHaveBeenCalled();631 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();632 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();633 expect(instance2.ionViewCanLeave).not.toHaveBeenCalled();634 expect(instance2.ionViewWillLeave).toHaveBeenCalled();635 expect(instance2.ionViewDidLeave).toHaveBeenCalled();636 expect(instance2.ionViewWillUnload).toHaveBeenCalled();637 expect(instance3.ionViewDidLoad).not.toHaveBeenCalled();638 expect(instance3.ionViewCanEnter).not.toHaveBeenCalled();639 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();640 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();641 expect(instance3.ionViewCanLeave).not.toHaveBeenCalled();642 expect(instance3.ionViewWillLeave).not.toHaveBeenCalled();643 expect(instance3.ionViewDidLeave).not.toHaveBeenCalled();644 expect(instance3.ionViewWillUnload).not.toHaveBeenCalled();645 let hasCompleted = true;646 let requiresTransition = false;647 expect(trnsDone).toHaveBeenCalledWith(648 hasCompleted, requiresTransition, undefined, undefined, undefined649 );650 expect(nav.length()).toEqual(1);651 expect(nav.getByIndex(0).component).toEqual(MockView3);652 });653 it('should set a ViewController as the root when its the middle view, with transition', () => {654 let view1 = mockView(MockView1);655 let view2 = mockView(MockView2);656 let view3 = mockView(MockView3);657 mockViews(nav, [view1, view2, view3]);658 let instance1 = spyOnLifecycles(view1);659 let instance2 = spyOnLifecycles(view2);660 let instance3 = spyOnLifecycles(view3);661 nav.setRoot(view2, null, null, trnsDone);662 expect(instance1.ionViewDidLoad).not.toHaveBeenCalled();663 expect(instance1.ionViewCanEnter).not.toHaveBeenCalled();664 expect(instance1.ionViewWillEnter).not.toHaveBeenCalled();665 expect(instance1.ionViewDidEnter).not.toHaveBeenCalled();666 expect(instance1.ionViewCanLeave).not.toHaveBeenCalled();667 expect(instance1.ionViewWillLeave).toHaveBeenCalled();668 expect(instance1.ionViewDidLeave).toHaveBeenCalled();669 expect(instance1.ionViewWillUnload).toHaveBeenCalled();670 expect(instance2.ionViewDidLoad).toHaveBeenCalled();671 expect(instance2.ionViewCanEnter).toHaveBeenCalled();672 expect(instance2.ionViewWillEnter).toHaveBeenCalled();673 expect(instance2.ionViewDidEnter).toHaveBeenCalled();674 expect(instance2.ionViewCanLeave).not.toHaveBeenCalled();675 expect(instance2.ionViewWillLeave).not.toHaveBeenCalled();676 expect(instance2.ionViewDidLeave).not.toHaveBeenCalled();677 expect(instance2.ionViewWillUnload).not.toHaveBeenCalled();678 expect(instance3.ionViewDidLoad).not.toHaveBeenCalled();679 expect(instance3.ionViewCanEnter).not.toHaveBeenCalled();680 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();681 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();682 expect(instance3.ionViewCanLeave).toHaveBeenCalled();683 expect(instance3.ionViewWillLeave).toHaveBeenCalled();684 expect(instance3.ionViewDidLeave).toHaveBeenCalled();685 expect(instance3.ionViewWillUnload).toHaveBeenCalled();686 let hasCompleted = true;687 let requiresTransition = true;688 expect(trnsDone).toHaveBeenCalledWith(689 hasCompleted, requiresTransition, 'MockView2', 'MockView3', DIRECTION_BACK690 );691 expect(nav.length()).toEqual(1);692 expect(nav.getByIndex(0).component).toEqual(MockView2);693 });694 it('should set a ViewController as the root when its the first view, with transition', () => {695 let view1 = mockView(MockView1);696 let view2 = mockView(MockView2);697 let view3 = mockView(MockView3);698 mockViews(nav, [view1, view2, view3]);699 let instance1 = spyOnLifecycles(view1);700 let instance2 = spyOnLifecycles(view2);701 let instance3 = spyOnLifecycles(view3);702 nav.setRoot(view1, null, null, trnsDone);703 expect(instance1.ionViewDidLoad).toHaveBeenCalled();704 expect(instance1.ionViewCanEnter).toHaveBeenCalled();705 expect(instance1.ionViewWillEnter).toHaveBeenCalled();706 expect(instance1.ionViewDidEnter).toHaveBeenCalled();707 expect(instance1.ionViewCanLeave).not.toHaveBeenCalled();708 expect(instance1.ionViewWillLeave).not.toHaveBeenCalled();709 expect(instance1.ionViewDidLeave).not.toHaveBeenCalled();710 expect(instance1.ionViewWillUnload).not.toHaveBeenCalled();711 expect(instance2.ionViewDidLoad).not.toHaveBeenCalled();712 expect(instance2.ionViewCanEnter).not.toHaveBeenCalled();713 expect(instance2.ionViewWillEnter).not.toHaveBeenCalled();714 expect(instance2.ionViewDidEnter).not.toHaveBeenCalled();715 expect(instance2.ionViewCanLeave).not.toHaveBeenCalled();716 expect(instance2.ionViewWillLeave).toHaveBeenCalled();717 expect(instance2.ionViewDidLeave).toHaveBeenCalled();718 expect(instance2.ionViewWillUnload).toHaveBeenCalled();719 expect(instance3.ionViewDidLoad).not.toHaveBeenCalled();720 expect(instance3.ionViewCanEnter).not.toHaveBeenCalled();721 expect(instance3.ionViewWillEnter).not.toHaveBeenCalled();722 expect(instance3.ionViewDidEnter).not.toHaveBeenCalled();723 expect(instance3.ionViewCanLeave).toHaveBeenCalled();724 expect(instance3.ionViewWillLeave).toHaveBeenCalled();725 expect(instance3.ionViewDidLeave).toHaveBeenCalled();726 expect(instance3.ionViewWillUnload).toHaveBeenCalled();727 let hasCompleted = true;728 let requiresTransition = true;729 expect(trnsDone).toHaveBeenCalledWith(730 hasCompleted, requiresTransition, 'MockView1', 'MockView3', DIRECTION_BACK731 );732 expect(nav.length()).toEqual(1);733 expect(nav.getByIndex(0).component).toEqual(MockView1);734 });735 it('should set a page component as the root, with transition', () => {736 let view1 = mockView(MockView1);737 let view2 = mockView(MockView2);738 let view3 = mockView(MockView3);739 mockViews(nav, [view1, view2, view3]);740 let instance1 = spyOnLifecycles(view1);741 let instance2 = spyOnLifecycles(view2);742 let instance3 = spyOnLifecycles(view3);743 nav.setRoot(MockView4, null, null, trnsDone);744 expect(instance1.ionViewWillUnload).toHaveBeenCalled();745 expect(instance2.ionViewWillUnload).toHaveBeenCalled();746 expect(instance3.ionViewWillUnload).toHaveBeenCalled();747 let hasCompleted = true;748 let requiresTransition = true;749 expect(trnsDone).toHaveBeenCalledWith(750 hasCompleted, requiresTransition, 'MockView4', 'MockView3', DIRECTION_BACK751 );752 expect(nav.length()).toEqual(1);753 expect(nav.getByIndex(0).component).toEqual(MockView4);754 });755 });756 describe('setPages', () => {757 it('should set the pages from an array, starting at the root, with transition', () => {758 let view1 = mockView(MockView1);759 let view2 = mockView(MockView2);760 mockViews(nav, [view1, view2]);761 let instance1 = spyOnLifecycles(view1);762 let instance2 = spyOnLifecycles(view2);763 nav.setPages([{page: MockView4}, {page: MockView5}], null, trnsDone);764 expect(instance1.ionViewWillUnload).toHaveBeenCalled();765 expect(instance2.ionViewWillUnload).toHaveBeenCalled();766 let hasCompleted = true;767 let requiresTransition = true;768 expect(trnsDone).toHaveBeenCalledWith(769 hasCompleted, requiresTransition, 'MockView5', 'MockView2', DIRECTION_BACK770 );771 expect(nav.length()).toEqual(2);772 expect(nav.getByIndex(0).component).toEqual(MockView4);773 expect(nav.getByIndex(1).component).toEqual(MockView5);774 });775 });776 describe('_nextTrns', () => {777 it('should not start next transition when already transitioning', () => {778 nav.setTransitioning(true);779 expect(nav._nextTrns()).toEqual(false);780 });781 it('should not start next transition nothing in the queue', () => {782 expect(nav._nextTrns()).toEqual(false);783 });784 });785 let nav: NavControllerBase;786 let trnsDone: jasmine.Spy;787 function spyOnLifecycles(view: ViewController) {788 let instance = view.instance = {789 ionViewDidLoad: () => {},790 ionViewCanEnter: () => { return true; },791 ionViewWillEnter: () => {},792 ionViewDidEnter: () => {},793 ionViewCanLeave: () => {},794 ionViewWillLeave: () => { return true; },795 ionViewDidLeave: () => {},796 ionViewWillUnload: () => {},797 };798 spyOn(instance, 'ionViewDidLoad');799 spyOn(instance, 'ionViewCanEnter');800 spyOn(instance, 'ionViewWillEnter');801 spyOn(instance, 'ionViewDidEnter');802 spyOn(instance, 'ionViewCanLeave');803 spyOn(instance, 'ionViewWillLeave');804 spyOn(instance, 'ionViewDidLeave');805 spyOn(instance, 'ionViewWillUnload');806 return instance;807 }808 beforeEach(() => {809 trnsDone = jasmine.createSpy('TransitionDone');810 nav = mockNavController();811 });...

Full Screen

Full Screen

orderReducer.js

Source:orderReducer.js Github

copy

Full Screen

1import {2 ADD_BASE_INFO_TO_ORDER,3 ADD_PLACE_TO_ORDER,4 DISCARD_ORDER,5 ADD_WARE_HOUSE_TO_ORDER,6 ADD_DELIVERY_TYPE_TO_ORDER,7 CHANGE_PAYMENT_METHOD,8 ADD_RECIEVER_INFO,9 ADD_ORDER_COUPON,10 ADD_ORDER_TOTAL_PRICE,11 FETCH_ORDERS,12} from "../actions/orderActions";13import Order from "../../models/Order";14import Coupon from "../../models/Coupon";15const initialState = {16 orders: [],17};18const orderReducer = (state = initialState, action) => {19 switch (action.type) {20 case FETCH_ORDERS:21 return { orders: state.orders };22 case ADD_BASE_INFO_TO_ORDER:23 const orderInstance = new Order(24 action.id,25 action.ownerId,26 action.cartId,27 "",28 "",29 "",30 "",31 "Доставка до пункту видачі",32 2,33 "",34 "",35 "",36 "",37 [],38 null39 );40 var curOrders = [...state.orders];41 console.log("added order", curOrders.concat(orderInstance).length);42 return {43 orders: curOrders.concat(orderInstance),44 };45 case ADD_PLACE_TO_ORDER:46 var orderInstance2 = state.orders;47 const orderIndex = orderInstance2.findIndex(48 (el) => el.cartId === action.cartId49 );50 console.log(orderInstance2, orderIndex);51 const OrderItem = orderInstance2[orderIndex];52 OrderItem.placeId = action.placeId;53 OrderItem.place = action.place;54 orderInstance2[orderIndex] = OrderItem;55 return {56 orders: orderInstance2,57 };58 case ADD_WARE_HOUSE_TO_ORDER:59 var orderInstance3 = state.orders;60 const orderIndex2 = orderInstance3.findIndex(61 (el) => el.cartId === action.cartId62 );63 const OrderItem2 = orderInstance3[orderIndex2];64 OrderItem2.postId = action.wareHouseId;65 OrderItem2.postDescription = action.wareHouse;66 if (action.CityRef) {67 OrderItem2.placeId = action.CityRef;68 }69 orderInstance3[orderIndex2] = OrderItem2;70 return {71 ...state,72 orders: orderInstance3,73 };74 case ADD_DELIVERY_TYPE_TO_ORDER:75 var orderInstance3 = state.orders;76 const orderIndex3 = orderInstance3.findIndex(77 (el) => el.cartId === action.cartId78 );79 const OrderItem3 = orderInstance3[orderIndex3];80 OrderItem3.postId = action.wareHouseId;81 OrderItem3.postDescription = action.wareHouse;82 if (action.CityRef) {83 OrderItem3.placeId = action.CityRef;84 }85 orderInstance3[orderIndex3] = OrderItem3;86 return {87 ...state,88 orders: orderInstance3,89 };90 case CHANGE_PAYMENT_METHOD:91 var orderInstance3 = state.orders;92 const orderIndex4 = orderInstance3.findIndex(93 (el) => el.cartId === action.cartId94 );95 const OrderItem4 = orderInstance3[orderIndex4];96 OrderItem4.priceMethod = action.paymentMethodKod;97 orderInstance3[orderIndex4] = OrderItem4;98 return {99 ...state,100 orders: orderInstance3,101 };102 case ADD_RECIEVER_INFO:103 var orderInstance3 = state.orders;104 const orderIndex5 = orderInstance3.findIndex(105 (el) => el.cartId === action.cartId106 );107 const OrderItem5 = orderInstance3[orderIndex5];108 OrderItem5.recieverFirstName = action.recieverFirstName;109 OrderItem5.recieverLastName = action.recieverLastName;110 OrderItem5.recieverMiddleName = action.recieverMiddleName;111 OrderItem5.recieverPhone = action.recieverPhone;112 orderInstance3[orderIndex5] = OrderItem5;113 return {114 ...state,115 orders: orderInstance3,116 };117 case ADD_ORDER_COUPON:118 var orderInstance3 = state.orders;119 const orderIndex6 = orderInstance3.findIndex(120 (el) => el.cartId === action.cartId121 );122 const OrderItem6 = orderInstance3[orderIndex6];123 OrderItem6.coupones.push(action.coupon);124 orderInstance3[orderIndex6] = OrderItem6;125 return {126 ...state,127 orders: orderInstance3,128 };129 case ADD_ORDER_TOTAL_PRICE:130 var orderInstance3 = state.orders;131 const orderIndex7 = orderInstance3.findIndex(132 (el) => el.cartId === action.cartId133 );134 const OrderItem7 = orderInstance3[orderIndex7];135 OrderItem7.totalPrice = action.totalPrice;136 orderInstance3[orderIndex7] = OrderItem7;137 return {138 ...state,139 orders: orderInstance3,140 };141 case DISCARD_ORDER:142 var orderInstance3 = state.orders;143 const newOrders = orderInstance3.filter(144 (elem) => elem.cartId !== action.cartId145 );146 return {147 orders: newOrders,148 };149 }150 return state;151};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { instance3 } = require('fast-check-monorepo');2instance3();3const { instance4 } = require('fast-check-monorepo');4instance4();5const { instance5 } = require('fast-check-monorepo');6instance5();7const { instance6 } = require('fast-check-monorepo');8instance6();9const { instance7 } = require('fast-check-monorepo');10instance7();11const { instance8 } = require('fast-check-monorepo');12instance8();13const { instance9 } = require('fast-check-monorepo');14instance9();15const { instance10 } = require('fast-check-monorepo');16instance10();17const { instance11 } = require('fast-check-monorepo');18instance11();19const { instance12 } = require('fast-check-monorepo');20instance12();21const { instance13 } = require('fast-check-monorepo');22instance13();23const { instance14 } = require('fast-check-monorepo');24instance14();25const { instance15 } = require('fast-check-monorepo');26instance15();27const { instance16 } = require('fast-check-monorepo');28instance16();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { instance3 } = require('fast-check-monorepo');2console.log(instance3());3const { instance3 } = require('fast-check-monorepo');4console.log(instance3());5const { instance3 } = require('fast-check-monorepo');6console.log(instance3());7const { instance3 } = require('fast-check-monorepo');8console.log(instance3());9const { instance3 } = require('fast-check-monorepo');10console.log(instance3());11const { instance3 } = require('fast-check-monorepo');12console.log(instance3());13const { instance3 } = require('fast-check-monorepo');14console.log(instance3());15const { instance3 } = require('fast-check-monorepo');16console.log(instance3());17const { instance3 } = require('fast-check-monorepo');18console.log(instance3());19const { instance3 } = require('fast-check-monorepo');20console.log(instance3());21const { instance3 } = require('fast-check-monorepo');22console.log(instance3());23const { instance3 } = require('fast-check-monorepo');24console.log(instance3());25const { instance3 } = require('fast-check-monorepo');26console.log(instance3());

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2console.log(fc.instance3());3{4 "scripts": {5 },6 "dependencies": {7 }8}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { instance3 } = require('fast-check-monorepo');2instance3();3const { instance4 } = require('fast-check-monorepo');4instance4();5const { instance5 } = require('fast-check-monorepo');6instance5();7const { instance6 } = require('fast-check-monorepo');8instance6();9const { instance7 } = require('fast-check-monorepo');10instance7();11const { instance8 } = require('fast-check-monorepo');12instance8();13const { instance9 } = require('fast-check-monorepo');14instance9();15const { instance10 } = require('fast-check-monorepo');16instance10();17const { instance11 } = require('fast-check-monorepo');18instance11();19const { instance12 } = require('fast-check-monorepo');20instance12();21const { instance13 } = require('fast-check-monorepo');22instance13();23const { instance14 } = require('fast-check-monorepo');24instance14();

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check-monorepo/instance1');2fc.instance3.method1();3const fc = require('fast-check-monorepo/instance2');4fc.instance3.method1();5const fc = require('fast-check-monorepo/instance3');6fc.instance3.method1();

Full Screen

Using AI Code Generation

copy

Full Screen

1import { instance3 } from 'fast-check-monorepo';2console.log(instance3);3import { instance3 } from 'fast-check-monorepo';4console.log(instance3);5import { instance3 } from 'fast-check-monorepo';6console.log(instance3);7import { instance3 } from 'fast-check-monorepo';8console.log(instance3);9import { instance3 } from 'fast-check-monorepo';10console.log(instance3);11import { instance3 } from 'fast-check-monorepo';12console.log(instance3);13import { instance3 } from 'fast-check-monorepo';14console.log(instance3);

Full Screen

Using AI Code Generation

copy

Full Screen

1const {instance3} = require('fast-check-monorepo/lib/instance3');2const {instance3} = require('fast-check-monorepo/lib/instance3');3const {instance3} = require('fast-check-monorepo/lib/instance3');4const {instance3} = require('fast-check-monorepo/lib/instance3');5const {instance3} = require('fast-check-monorepo/lib/instance3');6const {instance3} = require('fast-check-monorepo/lib/instance3');7const {instance3} = require('fast-check-monorepo/lib/instance3');8const {instance3} = require('fast-check-monorepo/lib/instance3');9const {instance3} = require('fast-check-monorepo/lib/instance3');10const {instance3} = require('fast-check-monorepo/lib/instance3');11const {instance3} = require('fast-check-monorepo

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 fast-check-monorepo 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