• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

janis-commerce / lambda / 7747286274

01 Feb 2024 08:31PM CUT coverage: 100.0%. Remained the same
7747286274

Pull #15

github

jormaechea
Added SF context object docs
Pull Request #15: Jcn 469 implement state event parameter

263 of 263 branches covered (100.0%)

Branch coverage included in aggregate %.

12 of 12 new or added lines in 4 files covered. (100.0%)

401 of 401 relevant lines covered (100.0%)

17.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/lib/helpers/get-lambda-function-name.js
1
'use strict';
2

3
const startcase = require('lodash/startCase');
1✔
4

5
const LambdaError = require('../lambda-error');
1✔
6

7
/**
8
 * @param {string} string
9
 * @returns {string}
10
 */
11
const dashCaseToTitleCase = string => {
1✔
12

13
        let result = '';
48✔
14

15
        for(let index = 0; index < string.length; index++) {
48✔
16

17
                let character = string[index];
495✔
18

19
                if(string[index - 1] === '-')
495✔
20
                        character = character.toUpperCase();
1✔
21

22
                result += character;
495✔
23
        }
24

25
        return result.substring(0, 1).toUpperCase() + result.substring(1).replace(/-/g, '');
48✔
26
};
27

28
/**
29
 * Get the JANIS Lambda function name
30
 * @param {string} functionName In TitleCase or dash-case
31
 * @returns {string}
32
 */
33
module.exports = (functionName, serviceAccountId, serviceName = process.env.JANIS_SERVICE_NAME) => {
1✔
34

35
        if(!serviceName)
49✔
36
                throw new LambdaError('No Service Name was found', LambdaError.codes.NO_SERVICE);
1✔
37

38
        const serviceTitle = startcase(serviceName).replace(/ /g, '');
48✔
39
        const fullServiceTitle = `Janis${serviceTitle}Service`;
48✔
40

41
        const env = process.env.JANIS_ENV;
48✔
42

43
        const lambdaFunctionName = dashCaseToTitleCase(functionName);
48✔
44

45
        const formattedFunctionName = `${fullServiceTitle}-${env}-${lambdaFunctionName}`;
48✔
46

47
        if(!serviceAccountId)
48✔
48
                return formattedFunctionName;
32✔
49

50
        return `${serviceAccountId}:function:${formattedFunctionName}`;
16✔
51
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc