From 6ae690c576a37d52f0a1d35f4d8f15ca4b233ae0 Mon Sep 17 00:00:00 2001 From: Bryan Clark Date: Fri, 6 Dec 2019 14:46:35 -0500 Subject: [PATCH] Add test for overwrite --- __tests__/auth.test.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/__tests__/auth.test.ts b/__tests__/auth.test.ts index 8e5efd4..ec54bce 100644 --- a/__tests__/auth.test.ts +++ b/__tests__/auth.test.ts @@ -42,7 +42,26 @@ describe('auth tests', () => { ); }, 100000); - it('does not create settings.xml without username and / or password', async () => { + it('overwrites existing settings.xml files', async () => { + const id = 'packages'; + const username = 'bluebottle'; + const password = 'SingleOrigin'; + + fs.mkdirSync(m2Dir, {recursive: true}); + fs.writeFileSync(settingsFile, "FAKE FILE"); + expect(fs.existsSync(m2Dir)).toBe(true); + expect(fs.existsSync(settingsFile)).toBe(true); + + await auth.configAuthentication(id, username, password); + + expect(fs.existsSync(m2Dir)).toBe(true); + expect(fs.existsSync(settingsFile)).toBe(true); + expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual( + auth.generate(id, username, password) + ); + }, 100000); + + it('does not create settings.xml without required parameters', async () => { await auth.configAuthentication('FOO', '', ''); expect(fs.existsSync(m2Dir)).toBe(false);