mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
54 lines
1.9 KiB
JavaScript
54 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
const expect = require('chai').expect;
|
|
const sinon = require('sinon');
|
|
const AwsProvider = require('../provider/awsProvider');
|
|
const AwsRemove = require('./index');
|
|
const Serverless = require('../../../Serverless');
|
|
|
|
describe('AwsRemove', () => {
|
|
const serverless = new Serverless();
|
|
const options = {
|
|
stage: 'dev',
|
|
region: 'us-east-1',
|
|
};
|
|
serverless.setProvider('aws', new AwsProvider(serverless));
|
|
const awsRemove = new AwsRemove(serverless, options);
|
|
awsRemove.serverless.cli = new serverless.classes.CLI();
|
|
|
|
describe('#constructor()', () => {
|
|
it('should have hooks', () => expect(awsRemove.hooks).to.be.not.empty);
|
|
|
|
it('should set the provider variable to an instance of AwsProvider', () =>
|
|
expect(awsRemove.provider).to.be.instanceof(AwsProvider));
|
|
|
|
it('should have access to the serverless instance', () => {
|
|
expect(awsRemove.serverless).to.deep.equal(serverless);
|
|
});
|
|
|
|
it('should run promise chain in order', () => {
|
|
const validateStub = sinon
|
|
.stub(awsRemove, 'validate').resolves();
|
|
const emptyS3BucketStub = sinon
|
|
.stub(awsRemove, 'emptyS3Bucket').resolves();
|
|
const removeStackStub = sinon
|
|
.stub(awsRemove, 'removeStack').resolves();
|
|
const monitorStackStub = sinon
|
|
.stub(awsRemove, 'monitorStack').resolves();
|
|
|
|
return awsRemove.hooks['remove:remove']()
|
|
.then(() => {
|
|
expect(validateStub.calledOnce).to.be.equal(true);
|
|
expect(emptyS3BucketStub.calledAfter(validateStub)).to.be.equal(true);
|
|
expect(removeStackStub.calledAfter(emptyS3BucketStub)).to.be.equal(true);
|
|
expect(monitorStackStub.calledAfter(emptyS3BucketStub)).to.be.equal(true);
|
|
|
|
awsRemove.validate.restore();
|
|
awsRemove.emptyS3Bucket.restore();
|
|
awsRemove.removeStack.restore();
|
|
awsRemove.monitorStack.restore();
|
|
});
|
|
});
|
|
});
|
|
});
|