Skip to content

Commit

Permalink
Mocking and test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
robertherber committed Oct 16, 2023
1 parent 0eb9124 commit 070c553
Show file tree
Hide file tree
Showing 38 changed files with 217 additions and 50 deletions.
12 changes: 12 additions & 0 deletions apps/supplement-stack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# supplement-stack

## 0.0.7

### Patch Changes

- Updated dependencies
- [email protected]
- @zemble/core@0.0.7
- @zemble/graphql@0.0.11
- [email protected]
- [email protected]
- [email protected]

## 0.0.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/supplement-stack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "supplement-stack",
"version": "0.0.6",
"version": "0.0.7",
"description": "",
"main": "app.ts",
"private": true,
Expand Down
12 changes: 12 additions & 0 deletions apps/todo-app-with-auth-backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# todo-app-with-auth-backend

## 0.0.7

### Patch Changes

- Updated dependencies
- [email protected]
- @zemble/core@0.0.7
- @zemble/graphql@0.0.11
- [email protected]
- [email protected]
- [email protected]

## 0.0.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/todo-app-with-auth-backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "todo-app-with-auth-backend",
"version": "0.0.6",
"version": "0.0.7",
"description": "",
"private": true,
"main": "app.ts",
Expand Down
7 changes: 7 additions & 0 deletions packages/apple-app-site-association/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# zemble-plugin-apple-app-site-association

## 0.0.5

### Patch Changes

- Updated dependencies
- @zemble/core@0.0.7

## 0.0.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/apple-app-site-association/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zemble-plugin-apple-app-site-association",
"version": "0.0.4",
"version": "0.0.5",
"description": "",
"private": true,
"main": "plugin.ts",
Expand Down
9 changes: 9 additions & 0 deletions packages/auth-anonymous/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# zemble-plugin-auth-anonymous

## 0.0.7

### Patch Changes

- Updated dependencies
- @zemble/core@0.0.7
- @zemble/graphql@0.0.11
- [email protected]

## 0.0.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-anonymous/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zemble-plugin-auth-anonymous",
"version": "0.0.6",
"version": "0.0.7",
"description": "",
"main": "plugin.ts",
"scripts": {
Expand Down
9 changes: 9 additions & 0 deletions packages/auth-api-token/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# zemble-plugin-auth-api-token

## 0.0.9

### Patch Changes

- Updated dependencies
- @zemble/core@0.0.7
- @zemble/graphql@0.0.11
- [email protected]

## 0.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-api-token/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zemble-plugin-auth-api-token",
"version": "0.0.8",
"version": "0.0.9",
"description": "",
"main": "plugin.ts",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions packages/auth-otp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# zemble-plugin-auth-otp

## 0.0.9

### Patch Changes

- Updated dependencies
- @zemble/core@0.0.7
- @zemble/graphql@0.0.11
- [email protected]
- [email protected]

## 0.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-otp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zemble-plugin-auth-otp",
"version": "0.0.8",
"version": "0.0.9",
"description": "",
"main": "plugin.ts",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-otp/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const defaultConfig = {
minTimeBetweenTwoFactorCodeRequestsInSeconds: 60 * 1, // 1 minute
generateTokenContents,
handleAuthRequest: async (to, twoFactorCode, { sendEmail, logger }) => {
if (sendEmail) {
if (sendEmail && process.env.NODE_ENV !== 'test') {
void sendEmail({
from: plugin.config.from,
subject: plugin.config.emailSubject ? simpleTemplating(plugin.config.emailSubject, { email: to.email, name: to.name ?? to.email, twoFactorCode }) : 'Login',
Expand Down
8 changes: 8 additions & 0 deletions packages/auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# zemble-plugin-auth

## 0.0.9

### Patch Changes

- Updated dependencies
- @zemble/core@0.0.7
- @zemble/graphql@0.0.11

## 0.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zemble-plugin-auth",
"version": "0.0.8",
"version": "0.0.9",
"description": "",
"main": "plugin.ts",
"bin": {
Expand Down
10 changes: 10 additions & 0 deletions packages/bull/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# zemble-plugin-bull

## 0.0.9

### Patch Changes

- Mocking and test improvements
- Updated dependencies
- @zemble/core@0.0.7
- @zemble/graphql@0.0.11
- [email protected]

## 0.0.8

### Patch Changes
Expand Down
12 changes: 10 additions & 2 deletions packages/bull/ZembleQueue.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { ZembleQueueBull } from './ZembleQueueBull'
import ZembleQueueMock from './ZembleQueueMock'

export type { ZembleQueueConfig } from './ZembleQueueBull'

export const ZembleQueue = process.env.NODE_ENV === 'test' ? ZembleQueueMock : ZembleQueueBull
// eslint-disable-next-line import/no-mutable-exports
let ZembleQueue = ZembleQueueBull

if (process.env.NODE_ENV === 'test') {
// eslint-disable-next-line @typescript-eslint/no-var-requires
ZembleQueue = (require('./ZembleQueueMock').default)
}

// eslint-disable-next-line @typescript-eslint/no-var-requires
export { ZembleQueue }

export default ZembleQueue
2 changes: 1 addition & 1 deletion packages/bull/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zemble-plugin-bull",
"version": "0.0.8",
"version": "0.0.9",
"description": "",
"main": "plugin.ts",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/bull/utils/setupQueues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import '@zemble/graphql'
import createClient from '../clients/redis'
import { type BullPluginConfig } from '../plugin'
import ZembleQueueBull from '../ZembleQueueBull'
import ZembleQueueMock from '../ZembleQueueMock'

import type {
Queue,
Expand Down Expand Up @@ -72,7 +71,8 @@ const setupQueues = (pluginPath: string, pubSub: Zemble.PubSubType, config: Bull

// eslint-disable-next-line functional/immutable-data
queues.push(queue)
} else if (queueConfig instanceof ZembleQueueMock) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
} else if (process.env.NODE_ENV === 'test' && queueConfig instanceof require('./ZembleQueueMock').default) {
await queueConfig._initQueue(fileNameWithoutExtension)
} else {
throw new Error(`Failed to load queue ${filename}, make sure it exports a ZembleQueue`)
Expand Down
12 changes: 12 additions & 0 deletions packages/cms-users/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# zemble-plugin-cms-users

## 0.0.7

### Patch Changes

- Updated dependencies
- @zemble/core@0.0.7
- @zemble/graphql@0.0.11
- [email protected]
- [email protected]
- [email protected]
- [email protected]

## 0.0.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cms-users/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zemble-plugin-cms-users",
"version": "0.0.6",
"version": "0.0.7",
"description": "",
"main": "plugin.ts",
"private": true,
Expand Down
9 changes: 9 additions & 0 deletions packages/cms/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# zemble-plugin-cms

## 0.0.7

### Patch Changes

- Updated dependencies
- @zemble/core@0.0.7
- @zemble/graphql@0.0.11
- [email protected]

## 0.0.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zemble-plugin-cms",
"version": "0.0.6",
"version": "0.0.7",
"description": "",
"main": "plugin.ts",
"private": true,
Expand Down
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @zemble/core

## 0.0.7

### Patch Changes

- Mocking and test improvements

## 0.0.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zemble/core",
"version": "0.0.6",
"version": "0.0.7",
"description": "",
"main": "index.ts",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/utils/readPackageJson.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import fs from 'fs'
import { join } from 'node:path'

export const readPackageJson = (path = process.cwd()): { readonly name: string, readonly version: string } => {
export const readPackageJson = (path = process.cwd()) => {
try {
const packageJson = JSON.parse(fs.readFileSync(join(path, 'package.json'), 'utf8'))
const packageJson = JSON.parse(fs.readFileSync(join(path, 'package.json'), 'utf8')) as { readonly name: string, readonly version: string }

if (!packageJson.name) {
throw new Error(`[@zemble] Invalid package.json, missing "name", looked in: ${packageJson.name}`)
Expand Down
10 changes: 10 additions & 0 deletions packages/email-sendgrid/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# zemble-plugin-email-sendgrid

## 0.0.9

### Patch Changes

- Mocking and test improvements
- Updated dependencies
- @zemble/core@0.0.7
- @zemble/graphql@0.0.11
- [email protected]

## 0.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/email-sendgrid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zemble-plugin-email-sendgrid",
"version": "0.0.8",
"version": "0.0.9",
"description": "",
"main": "plugin.ts",
"scripts": {
Expand Down
Loading

0 comments on commit 070c553

Please sign in to comment.