-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: trim values when returning, closes #11
- Loading branch information
Showing
5 changed files
with
62 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,46 @@ | ||
const test = require('ava') | ||
const loadUserIni = require('../src/load-user-ini') | ||
const { getSettingsFrom } = require('../src/index') | ||
|
||
test('has ini sections', t => { | ||
test('has ini sections', (t) => { | ||
const ini = loadUserIni() | ||
t.true(ini.hasSection('demo'), 'has demo section') | ||
t.true(ini.hasSection('as-a'), 'has as-a section') | ||
t.false(ini.hasSection('does not exist'), 'does not have unknown section') | ||
}) | ||
|
||
test('has section under an alias', t => { | ||
test('has section under an alias', (t) => { | ||
const ini = loadUserIni() | ||
t.true(ini.hasSection('name-one'), 'has section name-one') | ||
t.true(ini.hasSection('name-two'), 'has section name-two') | ||
t.true(ini.hasSection('name-three'), 'has section name-three') | ||
t.false(ini.hasSection('name-one, name-two, name-three'), 'initial section was removed') | ||
t.false( | ||
ini.hasSection('name-one, name-two, name-three'), | ||
'initial section was removed', | ||
) | ||
}) | ||
|
||
test('ignores empty aliases', t => { | ||
test('ignores empty aliases', (t) => { | ||
const ini = loadUserIni() | ||
t.true(ini.hasSection('alias1'), 'has section alias1') | ||
t.true(ini.hasSection('alias2'), 'has section alias2') | ||
}) | ||
|
||
test('trims trailing spaces', (t) => { | ||
const ini = loadUserIni(true) | ||
t.true( | ||
ini.hasSection('section-with-trailing-spaces'), | ||
'has section with trailing spaces', | ||
) | ||
const settings = ini['section-with-trailing-spaces'] | ||
// the loaded ini has the trailing spaces | ||
t.deepEqual(settings, { | ||
MY_VAR_WITH_SPACES: 'Hello ', | ||
}) | ||
|
||
const section = getSettingsFrom('section-with-trailing-spaces', ini) | ||
// the setting should have its trailing spaces removed | ||
t.deepEqual(section, { | ||
MY_VAR_WITH_SPACES: 'Hello', | ||
}) | ||
}) |