-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement model registry declarations
- Loading branch information
1 parent
c39e106
commit ce96ff9
Showing
2 changed files
with
44 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { tt } from '@noeldemartin/utils'; | ||
import type { Equals, Expect } from '@noeldemartin/utils'; | ||
|
||
import User from '@/testing/stubs/User'; | ||
import Post from '@/testing/stubs/Post'; | ||
import City from '@/testing/stubs/City'; | ||
import type { ModelConstructor } from '@/models/inference'; | ||
|
||
import { bootModels, requireBootedModel } from './index'; | ||
|
||
declare module './index' { | ||
interface ModelsRegistry { | ||
User: typeof User; | ||
} | ||
} | ||
|
||
describe('Models helpers', () => { | ||
|
||
it('registers booted models', () => { | ||
bootModels({ User, Post, City }); | ||
|
||
const user = requireBootedModel('User'); | ||
const post = requireBootedModel('Post'); | ||
const city = requireBootedModel<typeof City>('City'); | ||
|
||
expect(user).toBe(User); | ||
expect(post).toBe(Post); | ||
expect(city).toBe(City); | ||
|
||
tt< | ||
Expect<Equals<typeof user, typeof User>> | | ||
Expect<Equals<typeof post, ModelConstructor>> | | ||
Expect<Equals<typeof city, typeof City>> | | ||
true | ||
>(); | ||
}); | ||
|
||
}); |
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