-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: return json in import, update and publish
- Loading branch information
1 parent
346f64a
commit cd49d29
Showing
8 changed files
with
63 additions
and
47 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default { | ||
ZENDESK_SUBDOMAIN: 'z3ntest', | ||
ZENDESK_EMAIL: '[email protected]', | ||
ZENDESK_PASSWORD: '123456' // the universal password | ||
} |
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ import { expect, test } from '@oclif/test' | |
import * as path from 'path' | ||
import * as nock from 'nock' | ||
import ImportCommand from '../../src/commands/themes/import' | ||
import env from './env' | ||
|
||
describe('themes:import', function () { | ||
const baseThemePath = path.join(__dirname, 'mocks/base_theme') | ||
|
@@ -19,12 +20,8 @@ describe('themes:import', function () { | |
} | ||
|
||
describe('successful import', () => { | ||
test | ||
.env({ | ||
ZENDESK_SUBDOMAIN: 'z3ntest', | ||
ZENDESK_EMAIL: '[email protected]', | ||
ZENDESK_PASSWORD: '123456' // the universal password | ||
}) | ||
const success = test | ||
.env(env) | ||
.nock('https://z3ntest.zendesk.com', api => { | ||
api | ||
.post('/api/v2/guide/theming/jobs/themes/imports') | ||
|
@@ -39,21 +36,26 @@ describe('themes:import', function () { | |
.post('/upload/path') | ||
.reply(200) | ||
}) | ||
|
||
success | ||
.stdout() | ||
.it('should display success message when the theme is imported successfully', async ctx => { | ||
await ImportCommand.run([baseThemePath, '--brandId', '1111']) | ||
expect(ctx.stdout).to.contain('Theme imported successfully theme ID: 1234') | ||
}) | ||
|
||
success | ||
.stdout() | ||
.it('should return an object containing the theme ID when ran with --json', async ctx => { | ||
await ImportCommand.run([baseThemePath, '--brandId', '1111', '--json']) | ||
expect(ctx.stdout).to.equal(JSON.stringify({ themeId: '1234' }, null, 2) + '\n') | ||
}) | ||
}) | ||
|
||
describe('import failure', () => { | ||
test | ||
.stderr() | ||
.env({ | ||
ZENDESK_SUBDOMAIN: 'z3ntest', | ||
ZENDESK_EMAIL: '[email protected]', | ||
ZENDESK_PASSWORD: '123456' // the universal password | ||
}) | ||
.env(env) | ||
.nock('https://z3ntest.zendesk.com', api => { | ||
api | ||
.post('/api/v2/guide/theming/jobs/themes/imports') | ||
|
@@ -77,11 +79,7 @@ describe('themes:import', function () { | |
}) | ||
|
||
test | ||
.env({ | ||
ZENDESK_SUBDOMAIN: 'z3ntest', | ||
ZENDESK_EMAIL: '[email protected]', | ||
ZENDESK_PASSWORD: '123456' // the universal password | ||
}) | ||
.env(env) | ||
.nock('https://z3ntest.zendesk.com', api => { | ||
api | ||
.post('/api/v2/guide/theming/jobs/themes/imports') | ||
|
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,31 +1,33 @@ | ||
import { expect, test } from '@oclif/test' | ||
import PublishCommand from '../../src/commands/themes/publish' | ||
import env from './env' | ||
|
||
describe('themes:publish', function () { | ||
describe('successful publish', () => { | ||
test | ||
.env({ | ||
ZENDESK_SUBDOMAIN: 'z3ntest', | ||
ZENDESK_EMAIL: '[email protected]', | ||
ZENDESK_PASSWORD: '123456' // the universal password | ||
}) | ||
const success = test | ||
.env(env) | ||
.nock('https://z3ntest.zendesk.com', api => api | ||
.post('/api/v2/guide/theming/themes/1234/publish') | ||
.reply(200)) | ||
|
||
success | ||
.stdout() | ||
.it('should display success message when the theme is published successfully', async ctx => { | ||
await PublishCommand.run(['--themeId', '1234']) | ||
expect(ctx.stdout).to.contain('Theme published successfully theme ID: 1234') | ||
}) | ||
|
||
success | ||
.stdout() | ||
.it('should return an object containing the theme ID when ran with --json', async ctx => { | ||
await PublishCommand.run(['--themeId', '1234', '--json']) | ||
expect(ctx.stdout).to.equal(JSON.stringify({ themeId: '1234' }, null, 2) + '\n') | ||
}) | ||
}) | ||
|
||
describe('publish failure', () => { | ||
test | ||
.env({ | ||
ZENDESK_SUBDOMAIN: 'z3ntest', | ||
ZENDESK_EMAIL: '[email protected]', | ||
ZENDESK_PASSWORD: '123456' // the universal password | ||
}) | ||
.env(env) | ||
.nock('https://z3ntest.zendesk.com', api => api | ||
.post('/api/v2/guide/theming/themes/1234/publish') | ||
.reply(400, { | ||
|
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ import { expect, test } from '@oclif/test' | |
import * as path from 'path' | ||
import * as nock from 'nock' | ||
import UpdateCommand from '../../src/commands/themes/update' | ||
import env from './env' | ||
|
||
describe('themes:update', function () { | ||
const baseThemePath = path.join(__dirname, 'mocks/base_theme') | ||
|
@@ -19,12 +20,8 @@ describe('themes:update', function () { | |
} | ||
|
||
describe('successful update', () => { | ||
test | ||
.env({ | ||
ZENDESK_SUBDOMAIN: 'z3ntest', | ||
ZENDESK_EMAIL: '[email protected]', | ||
ZENDESK_PASSWORD: '123456' // the universal password | ||
}) | ||
const success = test | ||
.env(env) | ||
.nock('https://z3ntest.zendesk.com', api => { | ||
api | ||
.post('/api/v2/guide/theming/jobs/themes/updates') | ||
|
@@ -39,21 +36,26 @@ describe('themes:update', function () { | |
.post('/upload/path') | ||
.reply(200) | ||
}) | ||
|
||
success | ||
.stdout() | ||
.it('should display success message when the theme is updated successfully', async ctx => { | ||
await UpdateCommand.run([baseThemePath, '--themeId', '1234']) | ||
expect(ctx.stdout).to.contain('Theme updated successfully') | ||
}) | ||
|
||
success | ||
.stdout() | ||
.it('should return an object containing the theme ID when ran with --json', async ctx => { | ||
await UpdateCommand.run([baseThemePath, '--themeId', '1234', '--json']) | ||
expect(ctx.stdout).to.equal(JSON.stringify({ themeId: '1234' }, null, 2) + '\n') | ||
}) | ||
}) | ||
|
||
describe('update failure', () => { | ||
test | ||
.stderr() | ||
.env({ | ||
ZENDESK_SUBDOMAIN: 'z3ntest', | ||
ZENDESK_EMAIL: '[email protected]', | ||
ZENDESK_PASSWORD: '123456' // the universal password | ||
}) | ||
.env(env) | ||
.nock('https://z3ntest.zendesk.com', api => { | ||
api | ||
.post('/api/v2/guide/theming/jobs/themes/updates') | ||
|
@@ -77,11 +79,7 @@ describe('themes:update', function () { | |
}) | ||
|
||
test | ||
.env({ | ||
ZENDESK_SUBDOMAIN: 'z3ntest', | ||
ZENDESK_EMAIL: '[email protected]', | ||
ZENDESK_PASSWORD: '123456' // the universal password | ||
}) | ||
.env(env) | ||
.nock('https://z3ntest.zendesk.com', api => { | ||
api | ||
.post('/api/v2/guide/theming/jobs/themes/updates') | ||
|