mirror of
https://github.com/Kong/insomnia.git
synced 2026-10-25 08:09:06 -04:00
Fix tests
This commit is contained in:
1 parent
4c31c5575f
commit
a33fb6b9fa
3 files changed
+18
-9
No files matched your search
@@ -214,7 +214,7 @@ describe('export', () => {
|
||||
|
||||
expect(exportWorkspacesDataJson).toMatchObject({
|
||||
_type: 'export',
|
||||
__export_format: 3,
|
||||
__export_format: 4,
|
||||
__export_date: expect.stringMatching(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/),
|
||||
__export_source: `insomnia.desktop.app:v${getAppVersion()}`,
|
||||
resources: expect.arrayContaining([
|
||||
@@ -230,11 +230,14 @@ describe('export', () => {
|
||||
expect(exportWorkspacesDataJson.resources.length).toBe(7);
|
||||
|
||||
// Test export some requests only.
|
||||
const exportRequestsJson = await importUtil.exportRequestsJSON([r1]);
|
||||
const exportRequestsData = JSON.parse(exportRequestsJson);
|
||||
expect(exportRequestsData).toMatchObject({
|
||||
const exportRequestsJson = await importUtil.exportRequestsData([r1], false, 'json');
|
||||
const exportRequestsYaml = await importUtil.exportRequestsData([r1], false, 'yaml');
|
||||
const exportRequestsDataJSON = JSON.parse(exportRequestsJson);
|
||||
const exportRequestsDataYAML = YAML.parse(exportRequestsYaml);
|
||||
|
||||
expect(exportRequestsDataJSON).toMatchObject({
|
||||
_type: 'export',
|
||||
__export_format: 3,
|
||||
__export_format: 4,
|
||||
__export_date: expect.stringMatching(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/),
|
||||
__export_source: `insomnia.desktop.app:v${getAppVersion()}`,
|
||||
resources: expect.arrayContaining([
|
||||
@@ -245,6 +248,11 @@ describe('export', () => {
|
||||
expect.objectContaining({ _id: ePub._id }),
|
||||
]),
|
||||
});
|
||||
expect(exportRequestsData.resources.length).toBe(5);
|
||||
|
||||
expect(exportRequestsDataJSON.resources.length).toBe(5);
|
||||
expect(exportRequestsDataYAML.resources.length).toBe(5);
|
||||
|
||||
// Ensure JSON and YAML are the same
|
||||
expect(exportRequestsDataJSON.resources).toEqual(exportRequestsDataYAML.resources);
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
// @flow
|
||||
import { convert } from 'insomnia-importers';
|
||||
import clone from 'clone';
|
||||
import * as db from './database';
|
||||
import * as har from './har';
|
||||
import type { BaseModel } from '../models/index';
|
||||
@@ -276,7 +277,7 @@ export async function exportRequestsData(
|
||||
const workspaces: Array<BaseModel> = [];
|
||||
const mapTypeAndIdToDoc: Object = {};
|
||||
for (const req of requests) {
|
||||
const ancestors: Array<BaseModel> = await db.withAncestors(req);
|
||||
const ancestors: Array<BaseModel> = clone(await db.withAncestors(req));
|
||||
for (const ancestor of ancestors) {
|
||||
const key = ancestor.type + '___' + ancestor._id;
|
||||
if (mapTypeAndIdToDoc.hasOwnProperty(key)) {
|
||||
|
||||
@@ -21,10 +21,10 @@ export function init(): { import: Object, export: Object } {
|
||||
options: { includePrivate?: boolean, format?: 'json' | 'yaml' } = {},
|
||||
): Promise<string> {
|
||||
options = options || {};
|
||||
return exportWorkspacesData(null, options.includePrivate, options.format || 'json');
|
||||
return exportWorkspacesData(null, !!options.includePrivate, options.format || 'json');
|
||||
},
|
||||
async har(options: { includePrivate?: boolean } = {}): Promise<string> {
|
||||
return exportWorkspacesHAR(null, options.includePrivate);
|
||||
return exportWorkspacesHAR(null, !!options.includePrivate);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user