diff --git a/src/commands/status/index.js b/src/commands/status/index.js index 47a0bd434d1..641f02eec13 100644 --- a/src/commands/status/index.js +++ b/src/commands/status/index.js @@ -44,7 +44,7 @@ class StatusCommand extends Command { const accountData = { Name: user.full_name, Email: user.email, - Github: ghuser, + GitHub: ghuser, } const teamsData = {} diff --git a/tests/command.status.test.js b/tests/command.status.test.js new file mode 100644 index 00000000000..2c90af6e1f5 --- /dev/null +++ b/tests/command.status.test.js @@ -0,0 +1,38 @@ +const test = require('ava') + +const callCli = require('./utils/call-cli') +const { withMockApi, getCLIOptions } = require('./utils/mock-api') +const { withSiteBuilder } = require('./utils/site-builder') +const { normalize } = require('./utils/snapshots') + +const siteInfo = { + account_slug: 'test-account', + id: 'site_id', + name: 'site-name', + admin_url: 'https://app.netlify.com/sites/test-site/overview', + url: 'https://test-site.netlify.app/', +} + +const user = { full_name: 'Test User', email: 'test@netlify.com' } + +const accounts = [{ slug: siteInfo.account_slug, name: user.full_name, roles_allowed: [] }] + +const routes = [ + { path: 'sites/site_id', response: siteInfo }, + { + path: 'accounts', + response: accounts, + }, + { path: 'user', response: user }, +] + +test('should print status for a linked site', async (t) => { + await withSiteBuilder('linked-site', async (builder) => { + await builder.buildAsync() + + await withMockApi(routes, async ({ apiUrl }) => { + const output = await callCli(['status'], getCLIOptions({ builder, apiUrl })) + t.snapshot(normalize(output)) + }) + }) +}) diff --git a/tests/snapshots/command.status.test.js.md b/tests/snapshots/command.status.test.js.md new file mode 100644 index 00000000000..a4069f4edfa --- /dev/null +++ b/tests/snapshots/command.status.test.js.md @@ -0,0 +1,23 @@ +# Snapshot report for `tests/command.status.test.js` + +The actual snapshot is saved in `command.status.test.js.snap`. + +Generated by [AVA](https://avajs.dev). + +## should print status for a linked site + +> Snapshot 1 + + `──────────────────────┐␊ + Current Netlify User │␊ + ──────────────────────┘␊ + Name:  Test User␊ + Email:  test@netlify.com␊ + ────────────────────┐␊ + Netlify Site Info │␊ + ────────────────────┘␊ + Current site: site-name␊ + Admin URL:  https://app.netlify.com/sites/test-site/overview␊ + Site URL:  https://test-site.netlify.app/␊ + Site Id:  site_id␊ + ` diff --git a/tests/snapshots/command.status.test.js.snap b/tests/snapshots/command.status.test.js.snap new file mode 100644 index 00000000000..a7d87f29d80 Binary files /dev/null and b/tests/snapshots/command.status.test.js.snap differ diff --git a/tests/utils/snapshots.js b/tests/utils/snapshots.js index dd85ff6c9e5..5243035dbaf 100644 --- a/tests/utils/snapshots.js +++ b/tests/utils/snapshots.js @@ -11,6 +11,8 @@ const normalizers = [ // this is specific to npm v6 { pattern: /@ start.+\/.+netlify-cli-tests-v10.+/, value: 'start' }, { pattern: /It should be one of.+/gm, value: 'It should be one of: *' }, + // ntl status adds the GitHub user if exists - we remove it to be consistent + { pattern: /\n.+GitHub:.+/, value: '' }, ] const normalize = (inputString) =>