{"size": 1217, "ext": "js", "max_stars_repo_path": "test/index.test.js", "max_stars_repo_name": "whtsky/nuxt.js", "max_stars_repo_stars_event_min_datetime": "2021-05-25T02:02:20.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-25T02:02:20.000Z", "max_issues_repo_path": "test/index.test.js", "max_issues_repo_name": "whtsky/nuxt.js", "max_issues_repo_issues_event_min_datetime": "2019-01-23T08:13:44.000Z", "max_issues_repo_issues_event_max_datetime": "2019-01-23T08:13:44.000Z", "max_forks_repo_path": "test/index.test.js", "max_forks_repo_name": "whtsky/nuxt.js", "max_forks_repo_forks_event_min_datetime": "2019-03-19T09:49:38.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-19T09:49:38.000Z"}
{"max_stars_count": 1, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 28.3023255814, "max_line_length": 85, "alphanum_fraction": 0.6343467543}
import test from 'ava'
import { resolve } from 'path'
import { Nuxt, Builder } from '../index.js'

test('Nuxt.js Class', t => {
  t.is(typeof Nuxt, 'function')
})

test.serial('Nuxt.js Instance', async t => {
  const nuxt = new Nuxt({
    rootDir: resolve(__dirname, 'fixtures', 'empty')
  })
  t.is(typeof nuxt, 'object')
  t.is(nuxt.options.dev, true)
  t.is(typeof nuxt._ready.then, 'function')
  await nuxt.ready()
  t.is(nuxt.initialized, true)
})

test.serial('Fail to build when no pages/ directory but is in the parent', t => {
  const nuxt = new Nuxt({
    dev: false,
    rootDir: resolve(__dirname, 'fixtures', 'empty', 'pages')
  })
  return new Builder(nuxt).build().catch(err => {
    let s = String(err)
    t.true(s.includes('No `pages` directory found'))
    t.true(s.includes('Did you mean to run `nuxt` in the parent (`../`) directory?'))
  })
})

test.serial('Fail to build when no pages/ directory', t => {
  const nuxt = new Nuxt({
    dev: false,
    rootDir: resolve(__dirname)
  })
  return new Builder(nuxt).build().catch(err => {
    let s = String(err)
    t.true(s.includes('Couldn\'t find a `pages` directory'))
    t.true(s.includes('Please create one under the project root'))
  })
})
