Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ActionGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ActionGenerator extends Generator {
return true
}
return `'${input}' is not a valid action name, please make sure that:
The name has at least 3 characters or less than 33 characters.
The name has at least 3 characters or less than 33 characters.
The first character is an alphanumeric character.
The subsequent characters are alphanumeric.
The last character isn't a space.
Expand Down
15 changes: 11 additions & 4 deletions test/lib/ActionGenerator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('implementation', () => {
test('rejects invalid name with a message`', async () => {
const invalidName = 'a'
const invalidNameMessage = `'${invalidName}' is not a valid action name, please make sure that:
The name has at least 3 characters or less than 33 characters.
The name has at least 3 characters or less than 33 characters.
The first character is an alphanumeric character.
The subsequent characters are alphanumeric.
The last character isn't a space.
Expand Down Expand Up @@ -212,18 +212,25 @@ Note: characters can only be split by '-'.
}
})

actionGenerator.addAction('myAction', './templateFile.js', { dependencies: { abc: '1.2.3', def: '4.5.6' }, devDependencies: { xyz: '3.2.1', vuw: '6.5.4' } })
actionGenerator.addAction('myAction', './templateFile.js', {
dependencies: { abc: '1.2.3', def: '4.5.6' },
devDependencies: { xyz: '3.2.1', vuw: '6.5.4' }
})

// 1. test copy action template to right destination
expect(actionGenerator.fs.copyTpl).toHaveBeenCalledWith(n('/fakeTplDir/templateFile.js'), n(`${actionFolderPath}/myAction/index.js`), {}, {}, {})
expect(actionGenerator.fs.copyTpl).toHaveBeenCalledWith(
n('/fakeTplDir/templateFile.js'),
n(`${actionFolderPath}/myAction/index.js`), {}, {}, {})

// 2. test manifest creation with action information, and preserving previous content
expect(utils.writeKeyYAMLConfig).toHaveBeenCalledWith(
actionGenerator,
n('/fakeDestRoot/src/dx-excshell-1/ext.config.yaml'),
'runtimeManifest',
// function path should be checked to be relative to config file
{ packages: { 'dx-excshell-1': { actions: { actionxyz: { function: 'fake.js' }, myAction: { annotations: { 'require-adobe-auth': true }, function: expect.stringContaining('myAction/index.js'), runtime: constants.defaultRuntimeKind, web: 'yes' } } } } })
// 3. make sure wskdebug dev dependency was added to package.json
// 3. make sure (dev)dependencies get added to package.json
expect(utils.addDependencies).toHaveBeenCalledTimes(2)
// prod
expect(utils.addDependencies).toHaveBeenCalledWith(actionGenerator, {
abc: '1.2.3',
Expand Down