Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('numeric suffix', async () => {
const configA = GitConfig.from(`[core]
bigFileThreshold = 2k`)
const configB = GitConfig.from(`[core]
bigFileThreshold = 2m`)
const configC = GitConfig.from(`[core]
bigFileThreshold = 2g`)
const a = await configA.get('core.bigFileThreshold')
const b = await configB.get('core.bigFileThreshold')
const c = await configC.get('core.bigFileThreshold')
expect(a).toEqual(2048)
expect(b).toEqual(2097152)
expect(c).toEqual(2147483648)
})
})
it('numeric suffix', async () => {
const configA = GitConfig.from(`[core]
bigFileThreshold = 2k`)
const configB = GitConfig.from(`[core]
bigFileThreshold = 2m`)
const configC = GitConfig.from(`[core]
bigFileThreshold = 2g`)
const a = await configA.get('core.bigFileThreshold')
const b = await configB.get('core.bigFileThreshold')
const c = await configC.get('core.bigFileThreshold')
expect(a).toEqual(2048)
expect(b).toEqual(2097152)
expect(c).toEqual(2147483648)
})
})
it('subsection', async () => {
const config = GitConfig.from(`[one]
keyaaa = valaaa
[remote "foo"]
url = https://foo.com/project.git
; this is a comment
[remote "bar"]
url = https://bar.com/project.git`)
await config.deleteSection('remote', 'foo')
expect(config.toString()).toEqual(`[one]
keyaaa = valaaa
[remote "bar"]
url = https://bar.com/project.git`)
})
})
it('multiple', async () => {
const config = GitConfig.from(`[foo]
keyaaa = valaaa
keybbb = valbbb
keybbb = valBBB`)
const a = await config.getall('foo.keybbb')
expect(a).toEqual(['valbbb', 'valBBB'])
})
it('subsection', async () => {
const config = GitConfig.from(`[remote "foo"]
url = https://foo.com/project.git
[remote "bar"]
url = https://bar.com/project.git`)
await config.append('remote.baz.url', 'https://baz.com/project.git')
expect(config.toString()).toEqual(`[remote "foo"]
url = https://foo.com/project.git
[remote "bar"]
url = https://bar.com/project.git
[remote "baz"]
\turl = https://baz.com/project.git`)
})
})
it('simple', async () => {
const config = GitConfig.from(`[one]
keyaaa = valaaa
[remote "foo"]
url = https://foo.com/project.git
[remote "bar"]
url = https://bar.com/project.git
[two]
keyaaa = valaaa`)
const subsections = await config.getSubsections('remote')
expect(subsections).toEqual(['foo', 'bar'])
})
})
it('new section', async () => {
const config = GitConfig.from(`[foo]
keyaaa = valaaa`)
await config.set('bar.keyaaa', 'valaaa')
expect(config.toString()).toEqual(`[foo]
keyaaa = valaaa
[bar]
\tkeyaaa = valaaa`)
})
it('special boolean', async () => {
const config = GitConfig.from(`[core]
filemode = off
bare = on
logallrefupdates = no
symlinks = true`)
const a = await config.get('core.filemode')
const b = await config.get('core.bare')
const c = await config.get('core.logallrefupdates')
const d = await config.get('core.symlinks')
expect(a).toEqual(false)
expect(b).toEqual(true)
expect(c).toEqual(false)
expect(d).toEqual(true)
})
it('numeric suffix', async () => {
const configA = GitConfig.from(`[core]
bigFileThreshold = 2k`)
const configB = GitConfig.from(`[core]
bigFileThreshold = 2m`)
const configC = GitConfig.from(`[core]
bigFileThreshold = 2g`)
const a = await configA.get('core.bigFileThreshold')
const b = await configB.get('core.bigFileThreshold')
const c = await configC.get('core.bigFileThreshold')
expect(a).toEqual(2048)
expect(b).toEqual(2097152)
expect(c).toEqual(2147483648)
})
})