/** * @fileOverview Unit tests for the schemas for the merchant commands * @see {@url http://10.0.10.242/w/tricore_architecture/server_interface/merchant_commands/} */ var _ = require('lodash'); var testHelper = require('./testHelpers.js'); /** * Test data */ const VALID_SESSION_TOKEN = '01234567890abcdefghijklmnopqrstuvwxyzABCDE'; const VALID_DEVICE_TOKEN = '01234567890abcdefghijklmnopqrstuvwxyzABCDE'; /** * Test suite that defines the test command body and expected outcomes for * a range of different bodies across different commands. */ const TEST_SUITE = { ListItems: [ { name: '', valid: true, data: { DeviceToken: VALID_DEVICE_TOKEN, SessionToken: VALID_SESSION_TOKEN, ModifiedSince: '2015-03-02T17:52:40.000Z' } }, { name: 'missing required params', valid: false, expect: { missingRequiredCount: 2, additionalPropsCount: 1 }, data: {invalidAdditionalProp: 'a'} }, { name: 'mistake in every param', valid: false, expect: { errors: [ { dataPath: '.ModifiedSince', keyword: 'pattern' }, { dataPath: '.ModifiedSince', keyword: 'format' } ] }, data: { DeviceToken: VALID_DEVICE_TOKEN, SessionToken: VALID_SESSION_TOKEN, ModifiedSince: 'T03 Mar 2015 17:52:40 GMT' } } ] }; /** * Run the test suite through the test runner */ testHelper.runTestSuite('Schemas: Merchant Commands', TEST_SUITE);