When a ValueObject is cloned using the clone() method, the value of the cloned object is not properly maintained. When attempting to access the value using the get('value') method, the return is null instead of the original value.
Steps to Reproduce:
Import the Branch class from a module containing the ValueObject class.
Create an instance of Branch using the static method init() and assign it to a variable main.
Clone the main instance using the clone() method and assign it to a variable copy.
Attempt to access the value of the main and copy instances using the get('value') method.
Observe that the returned value for the copy instance is null, whereas it should be the same value as the main instance.
Expected Behavior:
The clone() method should create an exact copy of the ValueObject, keeping the original value intact. Therefore, when accessing the value using the get('value') method on the cloned instance (copy), the returned value should be the same as on the original instance (main).
Observed Behavior:
After cloning the ValueObject, the value returned when accessing get('value') on the cloned instance is null, instead of maintaining the original value.
Description:
When a ValueObject is cloned using the clone() method, the value of the cloned object is not properly maintained. When attempting to access the value using the get('value') method, the return is null instead of the original value.
Steps to Reproduce:
Expected Behavior:
The clone() method should create an exact copy of the ValueObject, keeping the original value intact. Therefore, when accessing the value using the get('value') method on the cloned instance (copy), the returned value should be the same as on the original instance (main).
Observed Behavior:
After cloning the ValueObject, the value returned when accessing get('value') on the cloned instance is null, instead of maintaining the original value.
Environment:
Language: TypeScript Framework/Dependency: rich-domain (version v1.23.0) Operating System: linux Browser/Platform: nodejs v20
Sample Code: