Skip to content

Commit

Permalink
[tests] getMergeableValuesDelta
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgpearce committed Mar 20, 2024
1 parent 822e036 commit eae4eb5
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
56 changes: 56 additions & 0 deletions test/unit/other/__snapshots__/mergeable-store.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,62 @@ exports[`Deltas getMergeableContentDelta No match remote missing values 1`] = `
]
`;

exports[`Deltas getMergeableValuesDelta Both empty 1`] = `
[
"",
{},
]
`;

exports[`Deltas getMergeableValuesDelta Both match 1`] = `
[
"",
{},
]
`;

exports[`Deltas getMergeableValuesDelta No match local empty 1`] = `
[
"",
{},
]
`;

exports[`Deltas getMergeableValuesDelta No match local missing some values 1`] = `
[
"Hc2DO@000005DK@@",
{},
]
`;

exports[`Deltas getMergeableValuesDelta No match remote empty 1`] = `
[
"Hc2DO@000008DKS9",
{
"v1": [
"Hc2DO@000008DKS9",
1,
],
"v2": [
"Hc2DO@000008DKS9",
2,
],
},
]
`;

exports[`Deltas getMergeableValuesDelta No match remote missing some values 1`] = `
[
"Hc2DO@000008DKS9",
{
"v2": [
"000000000008DKS9",
2,
],
},
]
`;

exports[`Merge Nothing 1`] = `
[
"",
Expand Down
50 changes: 50 additions & 0 deletions test/unit/other/mergeable-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,56 @@ describe('Deltas', () => {
});
});
});

describe('getMergeableValuesDelta', () => {
test('Both empty', () => {
expect(
store1.getMergeableValuesDelta(store2.getMergeableContent()[1][1]),
).toMatchSnapshot();
});

test('Both match', () => {
store1.setValues({v1: 1, v2: 2});
store2.merge(store1);
expect(
store1.getMergeableValuesDelta(store2.getMergeableContent()[1][1]),
).toMatchSnapshot();
});

describe('No match', () => {
test('local empty', () => {
store2.setValues({v1: 1, v2: 2});
expect(
store1.getMergeableValuesDelta(store2.getMergeableContent()[1][1]),
).toMatchSnapshot();
});

test('remote empty', () => {
store1.setValues({v1: 1, v2: 2});
expect(
store1.getMergeableValuesDelta(store2.getMergeableContent()[1][1]),
).toMatchSnapshot();
});

test('local missing some values', () => {
store2.setValues({v1: 1});
store1.merge(store2);
store2.setValue('v2', 2);
expect(
store1.getMergeableValuesDelta(store2.getMergeableContent()[1][1]),
).toMatchSnapshot();
});

test('remote missing some values', () => {
store1.setValues({v1: 1});
store2.merge(store1);
store1.setValue('v2', 2);
expect(
store1.getMergeableValuesDelta(store2.getMergeableContent()[1][1]),
).toMatchSnapshot();
});
});
});
});

describe('getTransactionMergeableChanges', () => {
Expand Down

0 comments on commit eae4eb5

Please sign in to comment.