Skip to content

Commit

Permalink
Add test for overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Clark committed Dec 6, 2019
1 parent b7e7041 commit 6ae690c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion __tests__/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6ae690c

Please sign in to comment.