Sha256: 6e57e8986150a948efb154ffe03a2881f778b84c3dd553df807cb2acee5f5c78

Contents?: true

Size: 1.98 KB

Versions: 72

Compression:

Stored size: 1.98 KB

Contents

'use strict';
/*jshint asi: true*/

var test                =  require('tap').test
  , path                =  require('path')
  , fs                  =  require('fs')
  , hideSemicolonsTheme =  require('../themes/hide-semicolons')
  , home                =  path.join(__dirname, 'fixtures', 'home')
  , rcpath              =  path.join(home, '.cardinalrc')
  , existsSync          =  fs.existsSync || path.existsSync
  , settingsResolve     =  require.resolve('../settings')
  , settings

function setup () {
  delete require.cache[settingsResolve]
  settings = require(settingsResolve)
}

function writerc(config) {
  fs.writeFileSync(rcpath, JSON.stringify(config), 'utf-8')
}

function removerc () {
  fs.unlinkSync(rcpath)
}

function resolveTheme (config) {
  writerc(config)
  var result = settings.resolveTheme(home)
  removerc()
  return result;
}

function getSettings (config) {
  writerc(config)
  var result = settings.getSettings(home)
  removerc()
  return result;
}

if (!existsSync(home)) fs.mkdirSync(home);

test('no .cardinalrc in home', function (t) {
  setup()
  var theme = settings.resolveTheme(home)
  t.equals(theme, undefined, 'resolves no theme') 
  t.end()
})

test('.cardinalrc with theme "hide-semicolons" in home', function (t) {
  setup()
  var theme = resolveTheme({ theme: "hide-semicolons" })
  t.deepEquals(theme, hideSemicolonsTheme, 'resolves hide-semicolons theme') 
  t.end()
})

test('.cardinalrc with full path to "hide-semicolons.js" in home', function (t) {
  setup()
  var theme = resolveTheme({ theme: path.join(__dirname, '..', 'themes', 'hide-semicolons.js') })
  t.deepEquals(theme, hideSemicolonsTheme, 'resolves hide-semicolons theme') 
  t.end()
})

test('.cardinalrc with linenos: true', function (t) {
  setup()
  var opts = { linenos: true }
  t.deepEquals(getSettings(opts), opts)
  t.end()
})

test('.cardinalrc with linenos: true and theme', function (t) {
  setup()
  var opts = { linenos: true, theme: 'some theme' }
  t.deepEquals(getSettings(opts), opts)
  t.end()
})

Version data entries

72 entries across 72 versions & 3 rubygems

Version Path
ilog-0.4.1 node_modules/cardinal/test/settings.js
ilog-0.4.0 node_modules/cardinal/test/settings.js
ilog-0.3.3 node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.18 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.17 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.16 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.15 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.14 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.13 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.12 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/cardinal/test/settings.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/cardinal/test/settings.js