@barchart/portfolio-api-common 1.4.2 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ const PositionSchema = require('./../../../lib/serialization/PositionSchema');
2
+
3
+ describe('When positions are serialized', () => {
4
+ 'use strict';
5
+
6
+ describe('for a read operation (user error #1)', () => {
7
+ let position;
8
+ let serialized;
9
+
10
+ beforeEach(() => {
11
+ position = {
12
+ "user": "855e15c0-9e32-40ac-9bd9-5f0cc2780111",
13
+ "portfolio": "c2a743e8-8efa-4a88-9a6c-9202d3fec29f",
14
+ "instrument": {
15
+ "id": "TGAM-CASH-USD",
16
+ "name": "US Dollar",
17
+ "type": "CASH",
18
+ "currency": "USD"
19
+ },
20
+ "position": "a5cdc2e8-d9c6-4a1f-8f05-e271a5824f87",
21
+ "transaction": 2987,
22
+ "cash": true,
23
+ "valuation": "AVG",
24
+ "snapshot": {
25
+ "date": "2020-06-11",
26
+ "open": "222105.56",
27
+ "direction": "LONG",
28
+ "buys": "0",
29
+ "sells": "0",
30
+ "gain": "0",
31
+ "basis": "0",
32
+ "income": "0",
33
+ "value": "0"
34
+ },
35
+ "system": {
36
+ "calculate": {
37
+ "processors": 1
38
+ },
39
+ "locked": false
40
+ }
41
+ };
42
+
43
+ serialized = JSON.stringify(position);
44
+ });
45
+
46
+ describe('and the data is deserialized', () => {
47
+ let deserialized;
48
+
49
+ beforeEach(() => {
50
+ const reviver = PositionSchema.CLIENT.schema.getReviver();
51
+
52
+ deserialized = JSON.parse(serialized, reviver);
53
+ });
54
+
55
+ it('the deserialized data should be an object', () => {
56
+ expect(typeof deserialized).toEqual('object');
57
+ });
58
+
59
+ it('the deserialized data should be correct', () => {
60
+ expect(deserialized.position).toEqual(position.position);
61
+ });
62
+ });
63
+ });
64
+ });
@@ -48,7 +48,7 @@ describe('When transactions are serialized', () => {
48
48
  expect(typeof serialized === 'string').toEqual(true);
49
49
  });
50
50
 
51
- describe('and the serialized data is deserialized', function() {
51
+ describe('and the data is deserialized', () => {
52
52
  let deserialized;
53
53
 
54
54
  beforeEach(() => {