Skip to content

Commit

Permalink
serverless#3184 Refactor tests with await and before step
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Sep 24, 2020
1 parent 185b4e8 commit b26eeee
Showing 1 changed file with 33 additions and 49 deletions.
82 changes: 33 additions & 49 deletions lib/classes/Variables.test.js
Expand Up @@ -1360,55 +1360,6 @@ module.exports = {
.populateProperty(property)
.should.eventually.eql('my stage is dev');
});

it('should support ${file(...)} syntax', () => {
return runServerless({
fixture: 'variables',
cliArgs: ['print'],
}).then(result => {
expect(result.serverless.service.custom.importedFile).to.deep.equal({
foo: 'bar',
});
});
});

it('should support ${file(...):key} syntax', () => {
return runServerless({
fixture: 'variables',
cliArgs: ['print'],
}).then(result => {
expect(result.serverless.service.custom.importedFileWithKey).to.equal('bar');
});
});

it('should ignore native CloudFormation variables', () => {
return runServerless({
fixture: 'variables',
cliArgs: ['print'],
}).then(result => {
expect(result.serverless.service.custom.awsVariable).to.equal('${AWS::Region}');
});
});

it('should ignore CloudFormation references', () => {
return runServerless({
fixture: 'variables',
cliArgs: ['print'],
}).then(result => {
expect(result.serverless.service.custom.cloudFormationReference).to.equal(
'${AnotherResource}'
);
});
});

it('should support ${self:key} syntax', () => {
return runServerless({
fixture: 'variables',
cliArgs: ['print'],
}).then(result => {
expect(result.serverless.service.custom.selfReference).to.equal('bar');
});
});
});

describe('#populateVariable()', () => {
Expand Down Expand Up @@ -2786,4 +2737,37 @@ module.exports = {
expect(logWarningSpy.args[0][0]).to.contain('file');
});
});

describe('variable syntax', () => {
let processedConfig = null;
before(async () => {
const result = await runServerless({
fixture: 'variables',
cliArgs: ['print'],
});
processedConfig = result.serverless.service;
});

it('should support ${file(...)} syntax', () => {
expect(processedConfig.custom.importedFile).to.deep.equal({
foo: 'bar',
});
});

it('should support ${file(...):key} syntax', () => {
expect(processedConfig.custom.importedFileWithKey).to.equal('bar');
});

it('should ignore native CloudFormation variables', () => {
expect(processedConfig.custom.awsVariable).to.equal('${AWS::Region}');
});

it('should ignore CloudFormation references', () => {
expect(processedConfig.custom.cloudFormationReference).to.equal('${AnotherResource}');
});

it('should support ${self:key} syntax', () => {
expect(processedConfig.custom.selfReference).to.equal('bar');
});
});
});

0 comments on commit b26eeee

Please sign in to comment.