-
-
Notifications
You must be signed in to change notification settings - Fork 967
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed loadSampleData.ts and added tests (#2807)
* fixed loadSampleData.ts and tests added * fix: formatted code to meet Prettier standards * Revert changes to tsconfig.json
- Loading branch information
1 parent
a3a085b
commit 938812c
Showing
2 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { describe, it, expect, beforeAll, afterAll } from "vitest"; | ||
import { connect, disconnect } from "../../src/db"; | ||
import { | ||
User, | ||
Organization, | ||
Post, | ||
Event, | ||
Venue, | ||
RecurrenceRule, | ||
AppUserProfile, | ||
ActionItemCategory, | ||
AgendaCategoryModel, | ||
} from "../../src/models"; | ||
import { execSync } from "child_process"; | ||
|
||
describe("Sample Data Import Tests", () => { | ||
beforeAll(async () => { | ||
await connect(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await disconnect(); | ||
}); | ||
|
||
it("should import sample data and verify document counts", async () => { | ||
try { | ||
execSync("npm run import:sample-data -- --format", { stdio: "pipe" }); | ||
console.log("Sample data imported successfully."); | ||
} catch (error) { | ||
console.error("Failed to import sample data:", error); | ||
throw error; | ||
} | ||
|
||
const userCount = await User.countDocuments(); | ||
const organizationCount = await Organization.countDocuments(); | ||
const postCount = await Post.countDocuments(); | ||
const eventCount = await Event.countDocuments(); | ||
const venueCount = await Venue.countDocuments(); | ||
const recurrenceRuleCount = await RecurrenceRule.countDocuments(); | ||
const appUserProfileCount = await AppUserProfile.countDocuments(); | ||
const actionItemCategoryCount = await ActionItemCategory.countDocuments(); | ||
const agendaCategoryCount = await AgendaCategoryModel.countDocuments(); | ||
|
||
expect(userCount).toBe(15); | ||
expect(organizationCount).toBe(4); | ||
expect(postCount).toBe(17); | ||
expect(eventCount).toBe(17280); | ||
expect(venueCount).toBe(4); | ||
expect(recurrenceRuleCount).toBe(100); | ||
expect(appUserProfileCount).toBe(14); | ||
expect(actionItemCategoryCount).toBe(4); | ||
expect(agendaCategoryCount).toBe(4); | ||
}); | ||
}); |