Skip to content

Commit

Permalink
#789: adding retrieve test for mobileMessage - part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Mar 14, 2023
1 parent 861ddbc commit 563202d
Show file tree
Hide file tree
Showing 2 changed files with 232 additions and 0 deletions.
116 changes: 116 additions & 0 deletions test/mobileMessage.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const chai = require('chai');
const chaiFiles = require('chai-files');
// const assert = chai.assert;
chai.use(chaiFiles);
// const cache = require('../lib/util/cache');
const testUtils = require('./utils');
const handler = require('../lib/index');

describe('mobileMessage', () => {
beforeEach(() => {
Expand All @@ -7,4 +13,114 @@ describe('mobileMessage', () => {
afterEach(() => {
testUtils.mockReset();
});

describe('Retrieve ================', () => {
it('Should retrieve a mobileMessage', async () => {
// WHEN
await handler.retrieve('testInstance/testBU', ['mobileMessage']);
// THEN
// get results from cache
// const result = cache.getCache();
// assert.equal(
// result.mobileMessage ? Object.keys(result.mobileMessage).length : 0,
// 2,
// 'only 2 mobileMessages expected'
// );
// assert.deepEqual(
// await testUtils.getActualJson('testExisting_mobileMessage', 'mobileMessage'),
// await testUtils.getExpectedJson('9999999', 'mobileMessage', 'get'),
// 'returned JSON was not equal expected'
// );
// assert.equal(
// testUtils.getAPIHistoryLength(),
// 9,
// 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
// );
return;
});
});
// describe('Deploy ================', () => {
// beforeEach(() => {
// testUtils.mockSetup(true);
// });
// it('Should create & upsert a mobileMessage', async () => {
// // WHEN
// await handler.deploy('testInstance/testBU', ['mobileMessage']);
// // THEN
// // get results from cache
// const result = cache.getCache();
// assert.equal(
// result.mobileMessage ? Object.keys(result.mobileMessage).length : 0,
// 3,
// '3 mobileMessages expected'
// );
// // confirm created item
// assert.deepEqual(
// await testUtils.getActualJson('testNew_mobileMessage', 'mobileMessage'),
// await testUtils.getExpectedJson('9999999', 'mobileMessage', 'post'),
// 'returned JSON was not equal expected for insert mobileMessage'
// );

// // confirm updated item
// assert.deepEqual(
// await testUtils.getActualJson('testExisting_mobileMessage', 'mobileMessage'),
// await testUtils.getExpectedJson('9999999', 'mobileMessage', 'put'), // watch out - mobileMessage api wants put instead of patch for updates
// 'returned JSON was not equal expected for update mobileMessage'
// );

// // check number of API calls
// assert.equal(
// testUtils.getAPIHistoryLength(),
// 7,
// 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
// );
// return;
// });
// });
// describe('Templating ================', () => {
// it('Should create a mobileMessage template via buildTemplate and build it', async () => {
// // download first before we test buildTemplate
// await handler.retrieve('testInstance/testBU', ['mobileMessage']);
// // buildTemplate
// const result = await handler.buildTemplate(
// 'testInstance/testBU',
// 'mobileMessage',
// ['testExisting_mobileMessage'],
// 'testSourceMarket'
// );
// assert.equal(
// result.mobileMessage ? Object.keys(result.mobileMessage).length : 0,
// 1,
// 'only one mobileMessage expected'
// );
// assert.deepEqual(
// await testUtils.getActualTemplateJson(
// 'testExisting_mobileMessage',
// 'mobileMessage'
// ),
// await testUtils.getExpectedJson('9999999', 'mobileMessage', 'template'),
// 'returned template JSON was not equal expected'
// );

// // buildDefinition
// await handler.buildDefinition(
// 'testInstance/testBU',
// 'mobileMessage',
// 'testExisting_mobileMessage',
// 'testTargetMarket'
// );
// assert.deepEqual(
// await testUtils.getActualDeployJson('testExisting_mobileMessage', 'mobileMessage'),
// await testUtils.getExpectedJson('9999999', 'mobileMessage', 'build'),
// 'returned deployment JSON was not equal expected'
// );

// assert.equal(
// testUtils.getAPIHistoryLength(),
// 9,
// 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
// );
// return;
// });
// });
});
116 changes: 116 additions & 0 deletions test/resources/9999999/legacy/v1/beta/mobile/message/get-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"startIndex": 0,
"itemsPerPage": 50,
"totalResults": 1,
"entry": [
{
id: 'NTIzOjc4OjA',
lastUpdated: '2023-03-08T16:30:00Z',
type: 'ExactTarget.Mobile.Sms.Core.Entities.SmsMessageEntity',
name: 'test-jb-new',
text: 'test message jb new',
origin: 'SMS Send',
code: {
id: 'N3Y3RTN6aXBWVUtmdUtGWEpfNW5yUTo4MTow',
createdDate: '2017-05-05T10:32:41.537Z',
lastUpdated: '2017-05-05T10:38:07.217Z',
code: '491771783703',
countryCode: 'DE',
startDate: '2017-05-05T06:00:00Z',
endDate: '2047-05-05T06:00:00Z',
keywordLimit: '1000',
keywordsUsed: '9',
codeType: 'SHARED',
isShortCode: false,
keywordsUsedOther: '0',
isGsmCharacterSetOnly: false,
isMms: false,
isStackIndependant: false,
dipSwitches: 1,
moEngineVersion: 1,
sendableCountries: [Array],
supportsConcatenation: true,
isClientOwned: false,
isOwner: false
},
mtSendDate: '2023-03-07T20:18:00Z',
template: {
id: 'Mzo4MDow',
lastUpdated: '2023-03-08T16:30:30.536Z',
name: 'Outbound',
description: 'Send a SMS message to your subscribers',
icon: 'outbound.png'
},
status: 'Active/Scheduled',
invalidMessage: '',
responseMessage: '',
publishedMessage: "Text '<keyword>' to 491771783703.",
nextJob: {
id: 'NTIzOjc5OjA',
lastUpdated: '2023-03-08T16:30:30.521Z',
type: 'ExactTarget.Mobile.Sms.Core.Entities.SmsJobEntity',
message: [Object],
isTest: false
},
isTest: false,
currentEditStep: 13,
moTimezone: {
offset: 1,
name: '(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna *'
},
optinType: 'NO_OPTIN',
doubleOptinInitialMessage: '',
doubleOptinConfirmMessage: '',
optinMinimumAge: 0,
optinInvalidAgeMessage: '',
numberMessagesPerPeriod: 0,
periodType: 'NO_PERIOD',
optinErrorMessage: '',
triggeredSendId: '00000000-0000-0000-0000-000000000000',
isDuplicationAllowed: true,
triggeredSendName: 'test-jb-3 - 519',
isTimeZoneBased: false,
surveyType: 'NO_SURVEY',
surveyCorrectResponseMessage: '',
surveyTooManyEntriesMessage: '',
isExpireSet: false,
expireHours: 0,
surveyIncorrectResponseMessage: '',
statusId: 2,
doubleOptinValidResponses: 'y|yes',
messagesPerPeriod: 0,
minutesPerPeriod: 0,
subscriberResponseMessage: '',
isSubscriberResponseToAnySubscriptionForShortCode: false,
sendMethod: 'API',
messageObjectId: 'Y3l5cm50Y3EwVWlEQW1od1NZZnIwUTo2MjU6MA',
allowSingleOptin: false,
duplicateOptInResponseMessage: '',
isSentImmediately: true,
nextKeyword: {
id: 'Y0ZDXzVjVHdYVUNlQVJlT2U2dzVKZzo4Njow',
createdDate: '2017-07-05T09:49:59.363Z',
lastUpdated: '2023-03-08T16:30:30.536Z',
code: [Object],
keyword: 'ONEDEVICE_DEV',
startDate: '2017-07-05T09:49:59.257Z',
endDate: '2037-07-05T09:49:59.257Z',
status: 'Active',
createdBy: [Object],
restriction: 'NONE',
keywordType: 'NORMAL',
isInherited: false,
dipSwitches: 0
},
isSuppressMt: false,
smsTriggeredSendDefinitionId: '01cd6436-25bd-ed11-b859-48df37d1dca1',
fromName: '',
concatenateMessage: true,
isFromNameCertificationAccepted: false,
isCertified: false,
outboundSendTypeFlag: 'Audience',
programId: '00000000-0000-0000-0000-000000000000',
outboundSendBehaviorFlag: 'AutoAddSubscribers'
}
]
}

0 comments on commit 563202d

Please sign in to comment.