Skip to content

Commit

Permalink
chore: Add test collections script
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Nov 3, 2021
1 parent 8189c1b commit e196dc3
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/dev-server/scripts/generate-deep-collections.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { CollectionDefinition, InitialData } from '@vendure/core';
import fs from 'fs';
import path from 'path';

/**
* This script generates lots of Collections, nested 3 levels deep. It is useful for testing
* scenarios where we need to work with a large amount of Collections.
*/
const collections: CollectionDefinition[] = [];

for (let i = 1; i <= 20; i++) {
const IName = `Collection ${i}`;
collections.push({
name: IName,
filters: [],
});
for (let j = 1; j <= 5; j++) {
const JName = `Collection ${i}-${j}`;
collections.push({
name: JName,
filters: [],
parentName: IName,
});
for (let k = 1; k <= 3; k++) {
const KName = `Collection ${i}-${j}-${k}`;
collections.push({
name: KName,
filters: [],
parentName: JName,
});
}
}
}

fs.writeFileSync(path.join(__dirname, 'collections.json'), JSON.stringify(collections, null, 2), 'utf-8');

0 comments on commit e196dc3

Please sign in to comment.