2010-03-09 00:06:29 +01:00
|
|
|
require("../common");
|
2010-03-08 19:02:19 +01:00
|
|
|
var path = require('path');
|
|
|
|
var fs = require("fs");
|
2010-03-06 01:12:31 +01:00
|
|
|
parse = require("ini").parse;
|
|
|
|
|
|
|
|
debug("load fixtures/fixture.ini");
|
|
|
|
|
|
|
|
p = path.join(fixturesDir, "fixture.ini");
|
|
|
|
|
|
|
|
fs.readFile(p,function(err, data) {
|
|
|
|
if (err) throw err;
|
|
|
|
|
|
|
|
assert.equal(typeof parse, 'function');
|
|
|
|
|
|
|
|
var iniContents = parse(data);
|
|
|
|
assert.equal(typeof iniContents, 'object');
|
2010-03-10 09:17:15 +01:00
|
|
|
|
|
|
|
var expect =
|
|
|
|
{ "-" :
|
|
|
|
{ "root" : "something"
|
|
|
|
, "url" : "http://example.com/?foo=bar"
|
|
|
|
}
|
|
|
|
, "the section with whitespace" :
|
|
|
|
{ "this has whitespace" : "yep"
|
|
|
|
, "just a flag, no value." : true
|
|
|
|
}
|
|
|
|
, "section" :
|
|
|
|
{ "one" : "two"
|
|
|
|
, "Foo" : "Bar"
|
|
|
|
, "this" : "Your Mother!"
|
|
|
|
, "blank" : ""
|
|
|
|
}
|
|
|
|
, "Section Two" :
|
|
|
|
{ "something else" : "blah"
|
|
|
|
, "remove" : "whitespace"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
assert.deepEqual(iniContents, expect,
|
|
|
|
"actual: \n"+inspect(iniContents) +"\n≠\nexpected:\n"+inspect(expect))
|
2010-03-06 01:12:31 +01:00
|
|
|
|
|
|
|
assert.equal(iniContents['-']['root'],'something');
|
|
|
|
assert.equal(iniContents['section']['blank'],'');
|
|
|
|
assert.equal(iniContents['Section Two']['remove'],'whitespace');
|
|
|
|
|
|
|
|
});
|