Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test of persistence is not correctly implemented #922

Open
Losses opened this issue Dec 4, 2022 · 0 comments
Open

Unit test of persistence is not correctly implemented #922

Losses opened this issue Dec 4, 2022 · 0 comments

Comments

@Losses
Copy link

Losses commented Dec 4, 2022

for(idx=0; idx < methods.length; idx++) {
switch (idx) {
case 'D' : options = { partitioned: false, delimited : true }; break;
case 'DA' : options = { partitioned: true, delimited: true }; break;
case 'NDA' : options = { partitioned: false, delimited: false }; break;
case 'NDAA' : options = { partitioned: true, delimited : false }; break;
default : options = {}; break;
}
// do custom destructuring
result = ddb.serializeDestructured(options);
// reinflate from custom destructuring
var cddb = new loki("test.db");
var reinflatedDatabase = cddb.deserializeDestructured(result, options);
cddb.loadJSONObject(reinflatedDatabase);
// assert expectations on reinflated database
expect(cddb.collections.length).toEqual(2);
expect(cddb.collections[0].data.length).toEqual(3);
expect(cddb.collections[0].data[0].val).toEqual(ddb.collections[0].data[0].val);
expect(cddb.collections[0].data[0].$loki).toEqual(ddb.collections[0].data[0].$loki);
expect(cddb.collections[0].data[2].$loki).toEqual(ddb.collections[0].data[2].$loki);
expect(cddb.collections[1].data.length).toEqual(1);
expect(cddb.collections[1].data[0].a).toEqual(ddb.collections[1].data[0].a);
}
});

Since the type of idx is number, so all methods wound not be tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant