Skip to content

Commit

Permalink
add test for merge
Browse files Browse the repository at this point in the history
  • Loading branch information
adhami3310 committed Jul 25, 2024
1 parent cfdf44c commit e7b2dfa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions reflex/experimental/vars/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from __future__ import annotations

import dataclasses
from functools import cached_property
import sys
from functools import cached_property
from typing import Any, Dict, Type, Union

from reflex.experimental.vars.base import ImmutableVar, LiteralVar
from reflex.experimental.vars.sequence import ArrayVar
from reflex.vars import ImmutableVarData, Var, VarData
Expand Down Expand Up @@ -302,7 +303,8 @@ def __init__(
"""Initialize the object merge operation.
Args:
_var_value: The value of the operation.
left: The left object to merge.
right: The right object to merge.
_var_data: Additional hooks and imports associated with the operation.
"""
super(ObjectMergeOperation, self).__init__(
Expand Down
4 changes: 4 additions & 0 deletions tests/test_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,10 @@ def test_object_operations():
)
assert str(object_var.a) == '({ ["a"] : 1, ["b"] : 2, ["c"] : 3 })["a"]'
assert str(object_var["a"]) == '({ ["a"] : 1, ["b"] : 2, ["c"] : 3 })["a"]'
assert (
str(object_var.merge(LiteralObjectVar({"c": 4, "d": 5})))
== 'Object.assign(({ ["a"] : 1, ["b"] : 2, ["c"] : 3 }), ({ ["c"] : 4, ["d"] : 5 }))'
)


def test_retrival():
Expand Down

0 comments on commit e7b2dfa

Please sign in to comment.