Merge pull request #1609 from xtuple/4_5_x
[xtuple] / test / models / credit_card.js
1 /*jshint trailing:true, white:true, indent:2, strict:true, curly:true,
2   immed:true, eqeqeq:true, forin:true, latedef:true,
3   newcap:true, noarg:true, undef:true */
4 /*global XT:true, XM:true, XV:true, exports:true, describe:true, it:true, require:true */
5
6 (function () {
7   "use strict";
8
9   var crud = require("../lib/crud"),
10     assert = require("chai").assert;
11
12   var data = exports.data = {
13     recordType: "XM.CreditCard",
14     autoTestAttributes: false,
15     createHash: {
16       customer: 95, // TTOYS
17       creditCardType: "V",
18       name: "John Smith",
19       address1: "123 Main Street",
20       city: "Norfolk",
21       state: "VA",
22       zip: "23510",
23       country: "USA",
24       monthExpired: "05",
25       yearExpired: "2010",
26       number: "4111111111111111",
27       sequence: 500
28     },
29     updateHash: {
30       creditCardType: "M",
31       number: "1234123412341234",
32       sequence: 550
33     },
34     afterSaveActions: [{
35       it: "should mask the first 12 digits of the credit card number",
36       action: function (data, next) {
37         assert.equal(data.model.get("sequence"), 500);
38         assert.equal(data.model.get("name"), "John Smith");
39         assert.equal(data.model.get("number"), "************1111");
40         next();
41       }
42     }],
43     beforeDeleteActions: [{
44       it: "should not allow an update to the number or type",
45       action: function (data, next) {
46         assert.equal(data.model.get("sequence"), 550);
47         assert.equal(data.model.get("creditCardType"), "V");
48         assert.equal(data.model.get("number"), "************1111");
49         next();
50       }
51     }],
52     skipDelete: true
53   };
54
55   describe('Credit card crud test', function () {
56     crud.runAllCrud(data);
57   });
58 }());