John Cowen 9a302f6f4a
ui: Clean up and document environment.js file (#8966)
* Move various environment getting utils out of the main file and test/doc

* Clean up and document the entire environment file

* Tweak the environment tests to reflect what they should be

* Explicitly enable namespaces instead of defaulting

* Allow env fallback functions to be called lazily

Otherwise the executables used for finding out things would be required
during build, this way if env vars are set the executable aren't needed

* Infer booleans from the fallback and cast them as such
2020-10-19 17:29:43 +01:00

29 lines
631 B
JavaScript

const test = require('tape');
const utils = require('../../config/utils.js');
test(
'utils.respositoryYear parses the year out correctly',
function(t) {
const expected = '2020';
const actual = utils.repositoryYear('2020-10-14 16:34:57 -0700')
t.equal(actual, expected, 'It parses the year correctly');
t.end();
}
);
test(
'utils.binaryVersion parses the version out correctly',
function(t) {
const expected = '1.9.0';
const actual = utils.binaryVersion()(`
Version = "1.9.0"
VersionPrerelease = "dev"
`)
t.equal(actual, expected, 'It parses the version correctly');
t.end();
}
);