Skip to content

Commit bed9e72

Browse files
committed
refactor: improve test coverage
1 parent 6e9f4f0 commit bed9e72

File tree

7 files changed

+11
-45
lines changed

7 files changed

+11
-45
lines changed

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = {
1717
coverageReporters: ['json', 'lcov', 'text-summary', 'clover'],
1818
collectCoverageFrom: [
1919
'src/**/*.ts',
20+
'!src/index.ts',
2021
'!src/index.cjs.ts'
2122
]
2223
}

src/connection/Connection.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ export class Connection {
5252
return this.get()[id] ?? null
5353
}
5454

55-
/**
56-
* Find multiple models by their index ids.
57-
*/
58-
findIn(ids: string[]): Element[] {
59-
const data = this.get()
60-
61-
return ids.map((id) => data[id])
62-
}
63-
6455
/**
6556
* Commit `insert` mutation to the store.
6657
*/

src/model/attributes/relations/BelongsTo.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,4 @@ export class BelongsTo extends Relation {
9797
: model.$setRelation(relation, null)
9898
})
9999
}
100-
101-
/**
102-
* Make the value for the attribute.
103-
*/
104-
make(_value: any): null {
105-
return null
106-
}
107100
}

src/model/attributes/relations/HasMany.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,4 @@ export class HasMany extends Relation {
8181
return [result[this.foreignKey], result]
8282
})
8383
}
84-
85-
/**
86-
* Make the value for the attribute.
87-
*/
88-
make(_value: any): null {
89-
return null
90-
}
9184
}

src/model/attributes/relations/HasOne.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,4 @@ export class HasOne extends Relation {
8181
return [result[this.foreignKey], result]
8282
})
8383
}
84-
85-
/**
86-
* Make the value for the attribute.
87-
*/
88-
make(_value: any): null {
89-
return null
90-
}
9184
}

src/model/attributes/relations/Relation.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,12 @@ export abstract class Relation extends Attribute {
9898
return dictionary
9999
}, {})
100100
}
101+
102+
/**
103+
* Make the value for the attribute.
104+
*/
105+
/* istanbul ignore next */
106+
make(_value: any): null {
107+
return null
108+
}
101109
}

src/query/Query.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -238,25 +238,12 @@ export class Query<M extends Model = Model> {
238238
/**
239239
* Get models by given index ids.
240240
*/
241-
protected pick(id: string): Item<M>
242-
protected pick(ids: string[]): Collection<M>
243-
protected pick(ids: any): any {
244-
if (isArray(ids)) {
245-
return this.pickIn(ids)
246-
}
247-
248-
const record = this.connection.find(ids)
241+
protected pick(id: string): Item<M> {
242+
const record = this.connection.find(id)
249243

250244
return record ? this.hydrate(record) : null
251245
}
252246

253-
/**
254-
* Get models by given index ids.
255-
*/
256-
protected pickIn(ids: string[]): Collection<M> {
257-
return this.hydrate(this.connection.findIn(ids))
258-
}
259-
260247
/**
261248
* Retrieve models by processing all filters set to the query chain.
262249
*/

0 commit comments

Comments
 (0)