Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Feb 22, 2022
1 parent be5dfaf commit 48d1c61
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions packages/oauth/src/stores/file-store.spec.js
Expand Up @@ -3,6 +3,7 @@ const { assert, expect } = require('chai');

const sinon = require('sinon');
const fs = require('fs');
const os = require('os');

const { InstallProvider } = require('../index');
const { FileInstallationStore } = require('./index');
Expand Down Expand Up @@ -90,10 +91,10 @@ describe('FileInstallationStore', async () => {
});

it('should store the latest installation', async () => {
const installationStore = new FileInstallationStore({ baseDir: './tmp' });
const installationStore = new FileInstallationStore({ baseDir: os.tmpdir() });
const installer = new InstallProvider({ clientId, clientSecret, stateSecret, installationStore });
const { enterprise, team, user } = storedInstallation;
const fakeInstallDir = `./tmp/${enterprise.id}-${team.id}`;
const fakeInstallDir = `${os.tmpdir()}/${enterprise.id}-${team.id}`;
const installationJSON = JSON.stringify(storedInstallation);

installer.installationStore.storeInstallation(storedInstallation);
Expand All @@ -102,10 +103,10 @@ describe('FileInstallationStore', async () => {
});

it('should store additional records for each installation with historicalDataEnabled', async () => {
const installationStore = new FileInstallationStore({ baseDir: './tmp', historicalDataEnabled: true });
const installationStore = new FileInstallationStore({ baseDir: os.tmpdir(), historicalDataEnabled: true });
const installer = new InstallProvider({ clientId, clientSecret, stateSecret, installationStore });
const { enterprise, team, user } = storedInstallation;
const fakeInstallDir = `./tmp/${enterprise.id}-${team.id}`;
const fakeInstallDir = `${os.tmpdir()}/${enterprise.id}-${team.id}`;
const installationJSON = JSON.stringify(storedInstallation);

installer.installationStore.storeInstallation(storedInstallation);
Expand All @@ -118,10 +119,10 @@ describe('FileInstallationStore', async () => {
});

it('should fetch a stored installation', async () => {
const installationStore = new FileInstallationStore({ baseDir: './tmp' });
const installationStore = new FileInstallationStore({ baseDir: os.tmpdir() });
const installer = new InstallProvider({ clientId, clientSecret, stateSecret, installationStore });
const { enterprise, team } = storedInstallation;
const fakeInstallDir = `/${enterprise.id}-${team.id}`;
const fakeInstallDir = `${os.tmpdir()}/${enterprise.id}-${team.id}`;
const query = { enterpriseId: enterprise.id, teamId: team.id };

installer.installationStore.storeInstallation(storedInstallation);
Expand All @@ -132,10 +133,10 @@ describe('FileInstallationStore', async () => {
});

it('should delete all records of installation if no userId is passed', async () => {
const installationStore = new FileInstallationStore({ baseDir: './tmp' });
const installationStore = new FileInstallationStore({ baseDir: os.tmpdir() });
const installer = new InstallProvider({ clientId, clientSecret, stateSecret, installationStore });
const { enterprise, team } = storedInstallation;
const fakeInstallDir = `./tmp/${enterprise.id}-${team.id}`;
const fakeInstallDir = `${os.tmpdir()}/${enterprise.id}-${team.id}`;
const query = { enterpriseId: enterprise.id, teamId: team.id };

await installer.installationStore.deleteInstallation(query);
Expand All @@ -149,10 +150,10 @@ describe('FileInstallationStore', async () => {
});

it('should delete only user records of installation if userId is passed', async () => {
const installationStore = new FileInstallationStore({ baseDir: './tmp' });
const installationStore = new FileInstallationStore({ baseDir: os.tmpdir() });
const installer = new InstallProvider({ clientId, clientSecret, stateSecret, installationStore });
const { enterprise, team, user } = storedInstallation;
const fakeInstallDir = `/${enterprise.id}-${team.id}`;
const fakeInstallDir = `${os.tmpdir()}/${enterprise.id}-${team.id}`;
const query = { enterpriseId: enterprise.id, teamId: team.id, userId: user.id };

await installer.installationStore.deleteInstallation(query);
Expand Down

0 comments on commit 48d1c61

Please sign in to comment.