const detectIntentToSparkMessage = require('../server.js').detectIntentToSparkMessage;
const sparkToDetectIntent = require('../server.js').sparkToDetectIntent;
const assert = require('assert');

describe('sparkToDetectIntent()', () => {
    const message = {
        text: 'Test Text'
    };

    const dialogflowRequest = {
        session: 'sessionPath',
        queryInput: {
            text: {
                text: 'Test Text',
            },
            languageCode: 'en',
        },
    };

    it('should converts Spark message to a detectIntent request.', async function () {
        assert.deepStrictEqual(sparkToDetectIntent(
            message,'sessionPath'), dialogflowRequest)
    });
});

describe('detectIntentToSparkMessage()', () => {
    const sparkTextMessage = {
        personEmail: 'test123@gmail.com',
        text: 'Test Response Text\n'
    };

    const dialogflowResponse = {
        queryResult: {
            text: 'Test Text',
            languageCode: 'en',
            responseMessages: [{
                text: {
                    text: 'Test Response Text'
                }
            }]
        }
    };
    
    const message = {
        email: 'test123@gmail.com'
    }

    it('should converts detectIntent response to a Spark text message.', async function () {
        assert.deepStrictEqual(detectIntentToSparkMessage(
            dialogflowResponse, message), sparkTextMessage)
    });
});

@@ -276,32 +276,154 @@
 est Text'%0A    %7D;
+%0A    %0A    const sessionPath = 'projects/project123/locations/global/agents/12-34-56/environments/global/sessions/123';    
 %0A%0A    const dial
@@ -457,17 +457,16 @@
 ession: 
-'
 sessionP
@@ -468,17 +468,16 @@
 sionPath
-'
 ,%0A      
@@ -772,17 +772,17 @@
 message,
-'
+ 
 sessionP
@@ -784,17 +784,16 @@
 sionPath
-'
 ), dialo
@@ -907,17 +907,19 @@
         
-p
+toP
 ersonEma

Update server_test.js