test: setup Mocha and ask-sdk-test suite for Malayalam calendar skill
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { getMalayalamDate } from '../src/calendar.mjs';
|
||||
import assert from 'node:assert';
|
||||
|
||||
describe('getMalayalamDate unit test', () => {
|
||||
it('Conversion of date 2026-01-01 returns correct Malayalam date', () => {
|
||||
const result = getMalayalamDate(new Date(2026, 0, 1, 0, 0, 0));
|
||||
assert.deepStrictEqual(result, {
|
||||
year: 1201,
|
||||
month: 'Dhanu',
|
||||
day: 17,
|
||||
naksatra: 'Rohini'
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { AlexaTest, LaunchRequestBuilder } from 'ask-sdk-test';
|
||||
import { handler as skillHandler } from '../src/index.mjs';
|
||||
|
||||
const skillSettings = {
|
||||
appId: 'amzn1.ask.skill.fake-app-id',
|
||||
userId: 'amzn1.ask.account.fake-user-id',
|
||||
deviceId: 'amzn1.ask.device.fake-device-id',
|
||||
locale: 'en-US',
|
||||
};
|
||||
|
||||
const alexaTest = new AlexaTest(skillHandler, skillSettings);
|
||||
|
||||
describe('Alexa Malayalam Calendar Skill', () => {
|
||||
alexaTest.test([
|
||||
{
|
||||
request: new LaunchRequestBuilder(skillSettings).build(),
|
||||
saysLike: 'Today is',
|
||||
repromptsNothing: true,
|
||||
},
|
||||
]);
|
||||
});
|
||||
@@ -1,45 +0,0 @@
|
||||
import { handler } from '../src/index.mjs';
|
||||
|
||||
// Mock Alexa LaunchRequest Payload
|
||||
const mockAlexaLaunchRequest = {
|
||||
version: '1.0',
|
||||
session: {
|
||||
new: true,
|
||||
sessionId: 'amzn1.echo-sdk-s-session-mock-id',
|
||||
application: {
|
||||
applicationId: 'amzn1.ask.skill.53645cde-742f-499e-83d3-07ed537bce39'
|
||||
},
|
||||
user: {
|
||||
userId: 'amzn1.ask.account.mockUser'
|
||||
}
|
||||
},
|
||||
context: {
|
||||
System: {
|
||||
application: {
|
||||
applicationId: 'amzn1.ask.skill.53645cde-742f-499e-83d3-07ed537bce39'
|
||||
},
|
||||
user: {
|
||||
userId: 'amzn1.ask.account.mockUser'
|
||||
}
|
||||
}
|
||||
},
|
||||
request: {
|
||||
type: 'LaunchRequest',
|
||||
requestId: 'amzn1.echo-api.request.mockRequestId',
|
||||
timestamp: new Date().toISOString(),
|
||||
locale: 'en-US'
|
||||
}
|
||||
};
|
||||
|
||||
async function runLocalTest() {
|
||||
console.log('🚀 Running Alexa Handler Locally...\n');
|
||||
try {
|
||||
const response = await handler(mockAlexaLaunchRequest, {});
|
||||
console.log('✅ Response Received:\n');
|
||||
console.log(JSON.stringify(response, null, 2));
|
||||
} catch (error) {
|
||||
console.error('❌ Error executing handler locally:', error);
|
||||
}
|
||||
}
|
||||
|
||||
runLocalTest();
|
||||
Reference in New Issue
Block a user