summaryrefslogtreecommitdiffstats
path: root/services/sync/tests/tps/test_creditcards.js
blob: fea2b8a5416b75d5f1536a2ddd5e244868740b22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/* global Services */
Services.prefs.setBoolPref("services.sync.engine.creditcards", true);

EnableEngines(["creditcards"]);

var phases = {
  phase1: "profile1",
  phase2: "profile2",
  phase3: "profile1",
};

const cc1 = [
  {
    "cc-name": "John Doe",
    "cc-number": "4716179744040592",
    "cc-exp-month": 4,
    "cc-exp-year": 2050,
    "unknown-1": "an unknown field from another client",
    changes: {
      "cc-exp-year": 2051,
    },
  },
];

const cc1_after = [
  {
    "cc-name": "John Doe",
    "cc-number": "4716179744040592",
    "cc-exp-month": 4,
    "cc-exp-year": 2051,
    "unknown-1": "an unknown field from another client",
  },
];

const cc2 = [
  {
    "cc-name": "Timothy Berners-Lee",
    "cc-number": "2221000374457678",
    "cc-exp-month": 12,
    "cc-exp-year": 2050,
  },
];

Phase("phase1", [[CreditCards.add, cc1], [Sync]]);

Phase("phase2", [
  [Sync],
  [CreditCards.verify, cc1],
  [CreditCards.modify, cc1],
  [CreditCards.add, cc2],
  [Sync],
]);

Phase("phase3", [
  [Sync],
  [CreditCards.verifyNot, cc1],
  [CreditCards.verify, cc1_after],
  [CreditCards.verify, cc2],
]);