UNPKG

mongodb-stitch

Version:

[![Join the chat at https://gitter.im/mongodb/stitch](https://badges.gitter.im/mongodb/stitch.svg)](https://gitter.im/mongodb/stitch?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

51 lines (43 loc) 1.79 kB
const StitchMongoFixture = require('../fixtures/stitch_mongo_fixture'); import { buildAdminTestHarness, extractTestFixtureDataPoints } from '../testutil'; describe('Secrets', () => { let test = new StitchMongoFixture(); let th; let appSecrets; beforeAll(() => test.setup()); afterAll(() => test.teardown()); beforeEach(async() => { const { apiKey, groupId, serverUrl } = extractTestFixtureDataPoints(test); th = await buildAdminTestHarness(true, apiKey, groupId, serverUrl); appSecrets = th.app().secrets(); }); afterEach(async() => th.cleanup()); const testSecretName = 'testvaluename'; it('returns an empty list when no secrets exist for the app', async() => { let secrets = await appSecrets.list(); expect(secrets).toEqual([]); }); it('returns a list containing the new secret after one has been created', async() => { let secret = await appSecrets.create({name: testSecretName}); expect(secret.name).toEqual(testSecretName); let secrets = await appSecrets.list(); expect(secrets).toHaveLength(1); expect(secrets[0]).toEqual(secret); }); it('can update a secret name', async() => { let secret = await appSecrets.create({name: testSecretName}); secret.name = 'anotherName'; await appSecrets.secret(secret._id).update(secret); let secrets = await appSecrets.list(); expect(secrets[0].name).toEqual('anotherName'); }); it('can delete a secret', async() => { let secret = await appSecrets.create({name: testSecretName}); expect(secret.name).toEqual(testSecretName); let secrets = await appSecrets.list(); expect(secrets).toHaveLength(1); await appSecrets.secret(secret._id).remove(); secrets = await appSecrets.list(); expect(secrets).toHaveLength(0); }); });