Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: add a test case for create-nuxt-content
  • Loading branch information
nozomuikuta committed Sep 14, 2020
commit 6008b67a93ac663da6e893e225136f7a1bf5106d
51 changes: 36 additions & 15 deletions packages/create-nuxt-content-docs/test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,42 @@ const sao = require('sao')

const generator = path.join(__dirname, '../src')

test('should write files with good answers', async () => {
const answers = {
name: 'nuxt-content-docs',
title: 'Nuxt Content',
url: 'https://content.nuxtjs.org',
github: 'nuxt/content',
twitter: 'nuxt_js'
}
const stream = await sao.mock({ generator }, answers)
describe('create-nuxt-content', () => {
test('should write files with good answers (GitHub)', async () => {
const answers = {
name: 'nuxt-content-docs',
title: 'Nuxt Content',
url: 'https://content.nuxtjs.org',
github: 'nuxt/content',
twitter: 'nuxt_js'
}
const stream = await sao.mock({ generator }, answers)

const pkg = await stream.readFile('package.json')
const pkg = await stream.readFile('package.json')

expect(JSON.parse(pkg)).toEqual(expect.objectContaining({
name: 'nuxt-content-docs',
version: '1.0.0',
private: true
}))
expect(JSON.parse(pkg)).toEqual(expect.objectContaining({
name: 'nuxt-content-docs',
version: '1.0.0',
private: true
}))
})

test('should write files with good answers (GitHub Enterprise)', async () => {
const answers = {
name: 'nuxt-content-docs',
title: 'Nuxt Content',
url: 'https://content.nuxtjs.org',
github: 'https://api.ghe.com/repos/me/project',
twitter: 'nuxt_js'
}
const stream = await sao.mock({ generator }, answers)

const pkg = await stream.readFile('package.json')

expect(JSON.parse(pkg)).toEqual(expect.objectContaining({
name: 'nuxt-content-docs',
version: '1.0.0',
private: true
}))
})
})