e0ed609d0973f3f0d99d4f3d03ed38e84d307709.svn-base
2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
diff --git a/test/settings.js b/test/settings.js
index 7b28d66..642688f 100644
--- a/test/settings.js
+++ b/test/settings.js
@@ -1,14 +1,20 @@
'use strict';
/*jshint asi: true*/
-var test = require('tap').test
- , path = require('path')
- , fs = require('fs')
- , settings = require('../settings')
- , existsSync = fs.existsSync || path.existsSync
+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')
@@ -25,22 +31,47 @@ function resolveTheme (config) {
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()
+})
+