@strav/testing 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,14 +1,14 @@
1
- # @stravigor/testing
1
+ # @strav/testing
2
2
 
3
- Testing utilities for the [Strav](https://www.npmjs.com/package/@stravigor/core) framework. Provides HTTP testing helpers, authentication simulation, transaction-based test isolation, and model factories.
3
+ Testing utilities for the [Strav](https://www.npmjs.com/package/@strav/core) framework. Provides HTTP testing helpers, authentication simulation, transaction-based test isolation, and model factories.
4
4
 
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- bun add -d @stravigor/testing
8
+ bun add -d @strav/testing
9
9
  ```
10
10
 
11
- Requires `@stravigor/core` as a peer dependency.
11
+ Requires `@strav/core` as a peer dependency.
12
12
 
13
13
  ## TestCase
14
14
 
@@ -16,7 +16,7 @@ Boots the app, provides HTTP helpers, and wraps each test in a rolled-back trans
16
16
 
17
17
  ```ts
18
18
  import { describe, test, expect } from 'bun:test'
19
- import { TestCase } from '@stravigor/testing'
19
+ import { TestCase } from '@strav/testing'
20
20
 
21
21
  const t = await TestCase.boot({
22
22
  auth: true,
@@ -62,7 +62,7 @@ t.withoutAuth() // clear auth token
62
62
  Lightweight model factory for test data seeding.
63
63
 
64
64
  ```ts
65
- import { Factory } from '@stravigor/testing'
65
+ import { Factory } from '@strav/testing'
66
66
 
67
67
  const UserFactory = Factory.define(User, (seq) => ({
68
68
  pid: crypto.randomUUID(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strav/testing",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "Testing utilities for the Strav framework",
6
6
  "license": "MIT",
package/src/factory.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BaseModel } from '@stravigor/database'
1
+ import type { BaseModel } from '@strav/database'
2
2
 
3
3
  type ModelClass = typeof BaseModel & { create(attrs: Record<string, unknown>): Promise<any> }
4
4
  type DefinitionFn = (seq: number) => Record<string, unknown>
package/src/test_case.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { SQL, ReservedSQL } from 'bun'
2
- import { app, Configuration, ExceptionHandler } from '@stravigor/kernel'
3
- import { Database, BaseModel } from '@stravigor/database'
4
- import { Router } from '@stravigor/http'
2
+ import { app, Configuration, ExceptionHandler } from '@strav/kernel'
3
+ import { Database, BaseModel } from '@strav/database'
4
+ import { Router } from '@strav/http'
5
5
  import { Factory } from './factory.ts'
6
6
 
7
7
  export interface TestCaseOptions {
@@ -22,7 +22,7 @@ export interface TestCaseOptions {
22
22
  * transaction for full isolation.
23
23
  *
24
24
  * @example
25
- * import { TestCase, Factory } from '@stravigor/testing'
25
+ * import { TestCase, Factory } from '@strav/testing'
26
26
  *
27
27
  * const t = await TestCase.boot({
28
28
  * auth: true,
@@ -70,8 +70,8 @@ export class TestCase {
70
70
 
71
71
  // Auth + Session
72
72
  if (this.options.auth) {
73
- const { SessionManager } = await import('@stravigor/http')
74
- const { Auth } = await import('@stravigor/http')
73
+ const { SessionManager } = await import('@strav/http')
74
+ const { Auth } = await import('@strav/http')
75
75
 
76
76
  if (!app.has(SessionManager)) app.singleton(SessionManager)
77
77
  if (!app.has(Auth)) app.singleton(Auth)
@@ -89,8 +89,8 @@ export class TestCase {
89
89
 
90
90
  // View engine
91
91
  if (this.options.views) {
92
- const { ViewEngine } = await import('@stravigor/view')
93
- const { Context } = await import('@stravigor/http')
92
+ const { ViewEngine } = await import('@strav/view')
93
+ const { Context } = await import('@strav/http')
94
94
 
95
95
  if (!app.has(ViewEngine)) app.singleton(ViewEngine)
96
96
  const viewEngine = app.resolve(ViewEngine)
@@ -193,7 +193,7 @@ export class TestCase {
193
193
  * Creates a real AccessToken in the database.
194
194
  */
195
195
  async actingAs(user: unknown, tokenName = 'test-token'): Promise<this> {
196
- const { AccessToken } = await import('@stravigor/http')
196
+ const { AccessToken } = await import('@strav/http')
197
197
  const { token } = await AccessToken.create(user, tokenName)
198
198
  this._token = token
199
199
  return this