test coverage for loading variable getters

This commit is contained in:
Daniel Schep 2019-08-20 14:18:52 -04:00
parent 02fa190d0b
commit e4d29bb9cd

View File

@ -1048,6 +1048,26 @@ describe('PluginManager', () => {
});
});
describe('#loadVariableGetters()', () => {
it('should load the plugin variable getters', () => {
const getTestVariable = async () => 'testVariable'
class VariableGetterPlugin {
constructor(sls) {
this.variableGetters = [[/^test:/, getTestVariable]]
}
}
pluginManager.serverless.variables = {
variableResolvers: [],
customVariableResolverFuncs: {},
}
const pluginInstance = new VariableGetterPlugin();
pluginManager.loadVariableGetters(pluginInstance);
expect(pluginManager.serverless.variables.variableResolvers).to.deep.equal([[/^test:/, 'getTestVariable']])
expect(Object.keys(pluginManager.serverless.variables.customVariableResolverFuncs)).to.deep.equal(['getTestVariable'])
});
});
describe('#getEvents()', () => {
beforeEach(() => {
// eslint-disable-line prefer-arrow-callback