insomnia/app/common/__tests__/import.test.js
Gregory Schier 5db095f90b Add private environment support (#84)
* Add private environment support

* Add appveyor
2017-02-15 12:32:15 -08:00

32 lines
1.3 KiB
JavaScript

import * as db from '../database';
import * as models from '../../models';
import * as importUtil from '../import';
import {getAppVersion} from '../constants';
describe('export()', () => {
beforeEach(async () => {
await db.init(models.types(), {inMemoryOnly: true}, true);
});
it('succeed with username and password', async () => {
const w = await models.workspace.create({name: 'Workspace'});
const r1 = await models.request.create({name: 'Request', parentId: w._id});
const eBase = await models.environment.create({name: 'Base', parentId: w._id});
const ePub = await models.environment.create({name: 'Public', parentId: eBase._id});
await models.environment.create({name: 'Private', isPrivate: true, parentId: eBase._id});
const json = await importUtil.exportJSON();
const data = JSON.parse(json);
expect(data._type).toBe('export');
expect(data.__export_format).toBe(3);
expect(data.__export_date).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/);
expect(data.__export_source).toBe(`insomnia.desktop.app:v${getAppVersion()}`);
expect(data.resources[0]._id).toBe(w._id);
expect(data.resources[1]._id).toBe(eBase._id);
expect(data.resources[2]._id).toBe(r1._id);
expect(data.resources[3]._id).toBe(ePub._id);
expect(data.resources.length).toBe(4);
});
});