-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #983 from contentstack/development
Staging <- Development
- Loading branch information
Showing
77 changed files
with
2,456 additions
and
275 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 28 additions & 7 deletions
35
packages/contentstack-bulk-publish/test/unit/commands/assets/publish.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
const { describe, it } = require('mocha'); | ||
const AssetsPublish = require('../../../../src/commands/cm/assets/publish'); | ||
const { cliux } = require('@contentstack/cli-utilities'); | ||
const sinon = require('sinon'); | ||
const { expect } = require('chai'); | ||
const { config } = require('dotenv'); | ||
|
||
const { stub } = sinon; | ||
const AssetsPublish = require('../../../../src/commands/cm/assets/publish'); | ||
|
||
config(); | ||
|
||
const environments = process.env.ENVIRONMENTS.split(','); | ||
const locales = process.env.LOCALES.split(','); | ||
|
||
describe('AssetsPublish', () => { | ||
it('Should run the command when all the flags are passed', async function () { | ||
it('Should run the command when all the flags are passed', async () => { | ||
const args = ['--environments', environments[0], '--locales', locales[0], '--alias', process.env.MANAGEMENT_ALIAS, '--yes']; | ||
const inquireStub = stub(cliux, 'inquire'); | ||
const assetPublishSpy = sinon.spy(AssetsPublish.prototype, 'run'); | ||
await AssetsPublish.run(args); | ||
expect(assetPublishSpy.calledOnce).to.be.true; | ||
assetPublishSpy.restore(); | ||
}); | ||
|
||
it('Should fail when alias and stack api key flags are not passed', async () => { | ||
const args = ['--environments', environments[0], '--locales', locales[0], '--yes']; | ||
const assetPublishSpy = sinon.spy(AssetsPublish.prototype, 'run'); | ||
const expectedError = 'Please use `--alias` or `--stack-api-key` to proceed.'; | ||
try { | ||
await AssetsPublish.run(args); | ||
} catch (error) { | ||
expect(error).to.be.an.instanceOf(Error); | ||
expect(error.message).to.equal(expectedError); | ||
expect(assetPublishSpy.calledOnce).to.be.true; | ||
} | ||
assetPublishSpy.restore(); | ||
}); | ||
|
||
it('Should run successfully when user is logged in and stack api key is passed', async () => { | ||
const args = ['--environments', environments[0], '--locales', locales[0], '--stack-api-key', process.env.STACK_API_KEY, '--yes']; | ||
const assetPublishSpy = sinon.spy(AssetsPublish.prototype, 'run'); | ||
await AssetsPublish.run(args); | ||
sinon.assert.notCalled(inquireStub); | ||
inquireStub.restore(); | ||
expect(assetPublishSpy.calledOnce).to.be.true; | ||
assetPublishSpy.restore(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.