Skip to content

Commit d364692

Browse files
committed
chore: lint test files
1 parent 38ffa23 commit d364692

15 files changed

+42
-144
lines changed

test/feature/model/Delete.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,7 @@ describe('Feature - Model - Delete', () => {
283283

284284
await User.insert({ data: { id: 1, posts: [{ id: 2 }, { id: 3 }] } })
285285

286-
const user = User.query()
287-
.with('posts')
288-
.find(1) as User
286+
const user = User.query().with('posts').find(1) as User
289287

290288
expect(user.$isDeleted).toBe(false)
291289
expect(user.deleted_at).toBe(null)
@@ -337,9 +335,7 @@ describe('Feature - Model - Delete', () => {
337335
data: { id: 1, name: 'John Doe', post: [{ id: 2 }, { id: 3 }] }
338336
})
339337

340-
const user = User.query()
341-
.with('post')
342-
.find(1) as User
338+
const user = User.query().with('post').find(1) as User
343339

344340
expect(user.name).toBe('John Doe')
345341
expect(user.post).toBeInstanceOf(Post)

test/feature/model/Deprecated.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ describe('Feature - Model - Deprecated', () => {
8989

9090
await User.softDelete(1)
9191

92-
const users = User.query()
93-
.trashed()
94-
.get()
92+
const users = User.query().trashed().get()
9593

9694
expect(spyOnWarn).toHaveBeenCalled()
9795
expect(users.length).toBe(1)

test/feature/model/Restore.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ describe('Feature - Model - Restore', () => {
111111
}
112112
})
113113

114-
const user = User.query()
115-
.with('post')
116-
.find(1) as User
114+
const user = User.query().with('post').find(1) as User
117115

118116
expect(user.$isDeleted).toBe(true)
119117
expect(user.deleted_at).toBe(mockDate)
@@ -171,9 +169,7 @@ describe('Feature - Model - Restore', () => {
171169
}
172170
})
173171

174-
const user = User.query()
175-
.with('post')
176-
.find(1) as User
172+
const user = User.query().with('post').find(1) as User
177173

178174
expect(user.$isDeleted).toBe(true)
179175
expect(user.deleted_at).toBe(mockDate)

test/feature/model/Retrieve.spec.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ describe('Feature - Model - Retrieve', () => {
3737

3838
await User.softDelete(1)
3939

40-
const users = User.query()
41-
.withTrashed()
42-
.get()
40+
const users = User.query().withTrashed().get()
4341

4442
expect(users.length).toBe(3)
4543
expect(users[0].$isDeleted).toBe(true)
@@ -52,9 +50,7 @@ describe('Feature - Model - Retrieve', () => {
5250

5351
await User.softDelete(1)
5452

55-
const users = User.query()
56-
.onlyTrashed()
57-
.get()
53+
const users = User.query().onlyTrashed().get()
5854

5955
expect(users.length).toBe(1)
6056
expect(users[0].id).toBe(1)
@@ -92,15 +88,11 @@ describe('Feature - Model - Retrieve', () => {
9288

9389
await User.softDelete(1)
9490

95-
const user = User.query()
96-
.whereId(1)
97-
.first()
91+
const user = User.query().whereId(1).first()
9892

9993
expect(user).toBe(null)
10094

101-
const users = User.query()
102-
.whereIdIn([1, 2])
103-
.get()
95+
const users = User.query().whereIdIn([1, 2]).get()
10496

10597
expect(users.length).toBe(1)
10698
expect(users[0].$isDeleted).toBe(false)
@@ -111,9 +103,7 @@ describe('Feature - Model - Retrieve', () => {
111103

112104
await User.softDelete(1)
113105

114-
const users = User.query()
115-
.withTrashed()
116-
.get()
106+
const users = User.query().withTrashed().get()
117107

118108
expect(users.length).toBe(2)
119109
expect(users[0].$trashed()).toBe(true)

test/feature/relations/BelongsTo.spec.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,15 @@ describe('Feature - Relations - Belongs To', () => {
4040
it('can resolve queries without deleted relations (default)', async () => {
4141
await User.softDelete(1)
4242

43-
const post = Post.query()
44-
.with('user')
45-
.find(1) as Post
43+
const post = Post.query().with('user').find(1) as Post
4644

4745
expect(post.user).toBeNull()
4846
})
4947

5048
it('can include deleted relations using `withTrashed` clause', async () => {
5149
await User.softDelete(1)
5250

53-
const post = Post.query()
54-
.withTrashed()
55-
.with('user')
56-
.find(1) as Post
51+
const post = Post.query().withTrashed().with('user').find(1) as Post
5752

5853
expect(post.user).toBeInstanceOf(User)
5954
expect(post.user.$trashed()).toBe(true)
@@ -62,10 +57,7 @@ describe('Feature - Relations - Belongs To', () => {
6257
it('can resolve only deleted relations using `onlyTrashed` clause', async () => {
6358
await User.softDelete(1)
6459

65-
const post = Post.query()
66-
.onlyTrashed()
67-
.with('user')
68-
.find(1) as Post
60+
const post = Post.query().onlyTrashed().with('user').find(1) as Post
6961

7062
expect(post.user).toBeInstanceOf(User)
7163
expect(post.user.$trashed()).toBe(true)

test/feature/relations/BelongsToMany.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ describe('Feature - Relations - Belongs To Many', () => {
5252
it('can resolve queries without deleted relation (default)', async () => {
5353
await Role.softDelete(3)
5454

55-
const users = User.query()
56-
.with('roles')
57-
.findIn([1, 2]) as User[]
55+
const users = User.query().with('roles').findIn([1, 2]) as User[]
5856

5957
expect(users[0].roles.length).toBe(1)
6058
expect(users[0].roles[0].$trashed()).toBe(false)

test/feature/relations/HasMany.spec.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ describe('Feature - Relations - Has Many', () => {
4040
it('can resolve queries without deleted relations (default)', async () => {
4141
await Post.softDelete(1)
4242

43-
const user = User.query()
44-
.with('posts')
45-
.find(1) as User
43+
const user = User.query().with('posts').find(1) as User
4644

4745
expect(user.posts.length).toBe(1)
4846
expect(user.posts[0].$trashed()).toBe(false)
@@ -51,10 +49,7 @@ describe('Feature - Relations - Has Many', () => {
5149
it('can include deleted relations using `withTrashed` clause', async () => {
5250
await Post.softDelete(1)
5351

54-
const user = User.query()
55-
.withTrashed()
56-
.with('posts')
57-
.find(1) as User
52+
const user = User.query().withTrashed().with('posts').find(1) as User
5853

5954
expect(user.posts.length).toBe(2)
6055
expect(user.posts[0].$trashed()).toBe(true)
@@ -64,10 +59,7 @@ describe('Feature - Relations - Has Many', () => {
6459
it('can resolve only deleted relations using `onlyTrashed` clause', async () => {
6560
await Post.softDelete(1)
6661

67-
const user = User.query()
68-
.onlyTrashed()
69-
.with('posts')
70-
.find(1) as User
62+
const user = User.query().onlyTrashed().with('posts').find(1) as User
7163

7264
expect(user.posts.length).toBe(1)
7365
expect(user.posts[0].$trashed()).toBe(true)

test/feature/relations/HasManyBy.spec.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ describe('Feature - Relations - Has Many By', () => {
4040
it('can resolve queries without deleted relations (default)', async () => {
4141
await Post.softDelete(2)
4242

43-
const user = User.query()
44-
.with('posts')
45-
.find(1) as User
43+
const user = User.query().with('posts').find(1) as User
4644

4745
expect(user.posts.length).toBe(1)
4846
expect(user.posts[0].$trashed()).toBe(false)
@@ -51,10 +49,7 @@ describe('Feature - Relations - Has Many By', () => {
5149
it('can include deleted relations using `withTrashed` clause', async () => {
5250
await Post.softDelete(2)
5351

54-
const user = User.query()
55-
.withTrashed()
56-
.with('posts')
57-
.find(1) as User
52+
const user = User.query().withTrashed().with('posts').find(1) as User
5853

5954
expect(user.posts.length).toBe(2)
6055
expect(user.posts[0].$trashed()).toBe(true)
@@ -64,10 +59,7 @@ describe('Feature - Relations - Has Many By', () => {
6459
it('can resolve only deleted relations using `onlyTrashed` clause', async () => {
6560
await Post.softDelete(2)
6661

67-
const user = User.query()
68-
.onlyTrashed()
69-
.with('posts')
70-
.find(1) as User
62+
const user = User.query().onlyTrashed().with('posts').find(1) as User
7163

7264
expect(user.posts.length).toBe(1)
7365
expect(user.posts[0].$trashed()).toBe(true)

test/feature/relations/HasManyThrough.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ describe('Feature - Relations - Has Many Through', () => {
6262
it('can resolve queries without deleted relations (default)', async () => {
6363
await Post.softDelete(1)
6464

65-
const country = Country.query()
66-
.with('posts')
67-
.find(1) as Country
65+
const country = Country.query().with('posts').find(1) as Country
6866

6967
expect(country.posts.length).toBe(1)
7068
expect(country.posts[0].$trashed()).toBe(false)

test/feature/relations/HasOne.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ describe('Feature - Relations - Has One', () => {
4040
it('can resolve queries without deleted relations (default)', async () => {
4141
await Post.softDelete(3)
4242

43-
const users = User.query()
44-
.with('post')
45-
.findIn([1, 2]) as User[]
43+
const users = User.query().with('post').findIn([1, 2]) as User[]
4644

4745
expect(users[0].post).toBeNull()
4846
expect(users[1].post).toBeInstanceOf(Post)

test/feature/relations/MorphMany.spec.ts

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,36 +61,26 @@ describe('Feature - Relations - Morph Many', () => {
6161
it('can resolve queries without deleted relations (default)', async () => {
6262
await Tag.softDelete([1, 3])
6363

64-
const post = Post.query()
65-
.with('tags')
66-
.find(1) as Post
64+
const post = Post.query().with('tags').find(1) as Post
6765

6866
expect(post.tags.length).toBe(1)
6967
expect(post.tags[0].$trashed()).toBe(false)
7068

71-
const video = Video.query()
72-
.with('tags')
73-
.find(1) as Video
69+
const video = Video.query().with('tags').find(1) as Video
7470

7571
expect(video.tags.length).toBe(0)
7672
})
7773

7874
it('can include deleted relations using `withTrashed` clause', async () => {
7975
await Tag.softDelete([1, 3])
8076

81-
const post = Post.query()
82-
.withTrashed()
83-
.with('tags')
84-
.find(1) as Post
77+
const post = Post.query().withTrashed().with('tags').find(1) as Post
8578

8679
expect(post.tags.length).toBe(2)
8780
expect(post.tags[0].$trashed()).toBe(true)
8881
expect(post.tags[1].$trashed()).toBe(false)
8982

90-
const video = Video.query()
91-
.withTrashed()
92-
.with('tags')
93-
.find(1) as Video
83+
const video = Video.query().withTrashed().with('tags').find(1) as Video
9484

9585
expect(video.tags.length).toBe(1)
9686
expect(video.tags[0].$trashed()).toBe(true)
@@ -99,18 +89,12 @@ describe('Feature - Relations - Morph Many', () => {
9989
it('can resolve only deleted relations using `onlyTrashed` clause', async () => {
10090
await Tag.softDelete(1)
10191

102-
const post = Post.query()
103-
.onlyTrashed()
104-
.with('tags')
105-
.find(1) as Post
92+
const post = Post.query().onlyTrashed().with('tags').find(1) as Post
10693

10794
expect(post.tags.length).toBe(1)
10895
expect(post.tags[0].$trashed()).toBe(true)
10996

110-
const video = Video.query()
111-
.onlyTrashed()
112-
.with('tags')
113-
.find(1) as Video
97+
const video = Video.query().onlyTrashed().with('tags').find(1) as Video
11498

11599
expect(video.tags.length).toBe(0)
116100
})

test/feature/relations/MorphOne.spec.ts

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,11 @@ describe('Feature - Relations - Morph One', () => {
6161
it('can resolve queries without deleted relations (default)', async () => {
6262
await Tag.softDelete(1)
6363

64-
const post = Post.query()
65-
.with('tag')
66-
.find(1) as Post
64+
const post = Post.query().with('tag').find(1) as Post
6765

6866
expect(post.tag).toBeNull()
6967

70-
const video = Video.query()
71-
.with('tag')
72-
.find(1) as Video
68+
const video = Video.query().with('tag').find(1) as Video
7369

7470
expect(video.tag).toBeInstanceOf(Tag)
7571
expect(video.tag.$trashed()).toBe(false)
@@ -78,18 +74,12 @@ describe('Feature - Relations - Morph One', () => {
7874
it('can include deleted relations using `withTrashed` clause', async () => {
7975
await Tag.softDelete(1)
8076

81-
const post = Post.query()
82-
.withTrashed()
83-
.with('tag')
84-
.find(1) as Post
77+
const post = Post.query().withTrashed().with('tag').find(1) as Post
8578

8679
expect(post.tag).toBeInstanceOf(Tag)
8780
expect(post.tag.$trashed()).toBe(true)
8881

89-
const video = Video.query()
90-
.withTrashed()
91-
.with('tag')
92-
.find(1) as Video
82+
const video = Video.query().withTrashed().with('tag').find(1) as Video
9383

9484
expect(video.tag).toBeInstanceOf(Tag)
9585
expect(video.tag.$trashed()).toBe(false)
@@ -98,18 +88,12 @@ describe('Feature - Relations - Morph One', () => {
9888
it('can resolve only deleted relations using `onlyTrashed` clause', async () => {
9989
await Tag.softDelete(1)
10090

101-
const post = Post.query()
102-
.onlyTrashed()
103-
.with('tag')
104-
.find(1) as Post
91+
const post = Post.query().onlyTrashed().with('tag').find(1) as Post
10592

10693
expect(post.tag).toBeInstanceOf(Tag)
10794
expect(post.tag.$trashed()).toBe(true)
10895

109-
const video = Video.query()
110-
.onlyTrashed()
111-
.with('tag')
112-
.find(1) as Video
96+
const video = Video.query().onlyTrashed().with('tag').find(1) as Video
11397

11498
expect(video.tag).toBeNull()
11599
})

test/feature/relations/MorphTo.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ describe('Feature - Relations - Morph To', () => {
6262
it('can resolve queries without deleted relations (default)', async () => {
6363
await Post.softDelete(1)
6464

65-
const tags = Tag.query()
66-
.with('taggable')
67-
.findIn([1, 2]) as Tag[]
65+
const tags = Tag.query().with('taggable').findIn([1, 2]) as Tag[]
6866

6967
expect(tags[0].taggable_type).toBe('posts')
7068
expect(tags[0].taggable).toBeNull()

0 commit comments

Comments
 (0)