• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ecamp / hal-json-vuex / 13321877237

13 Feb 2025 10:43PM UTC coverage: 84.708%. Remained the same
13321877237

push

github

web-flow
Update babel monorepo to v7.26.8

159 of 206 branches covered (77.18%)

Branch coverage included in aggregate %.

262 of 291 relevant lines covered (90.03%)

740.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/src/EmbeddedCollection.js
1
import CanHaveItems from './CanHaveItems.js'
2
import LoadingStoreCollection from './LoadingStoreCollection'
3

4
/**
5
 * Imitates a full standalone collection with an items property, even if there is no separate URI (as it
6
 * is the case with embedded collections).
7
 * Reloading an embedded collection requires special information. Since the embedded collection has no own
8
 * URI, we need to reload the whole entity containing the embedded collection. Some extra info about the
9
 * containing entity must therefore be passed to this function.
10
 * @param items          array of items, which can be mixed primitive values and entity references
11
 * @param reloadUri      URI of the entity containing the embedded collection (for reloading)
12
 * @param reloadProperty property in the containing entity under which the embedded collection is saved
13
 * @param loadPromise    a promise that will resolve when the parent entity has finished (re-)loading
14
 */
15
class EmbeddedCollection extends CanHaveItems {
16
  constructor (items, reloadUri, reloadProperty, { get, reload, isUnknown }, config, loadPromise = null) {
66✔
17
    super({ get, reload, isUnknown }, config)
132✔
18
    this._meta = {
132✔
19
      load: loadPromise
132✔
20
        ? loadPromise.then(loadedParent => new EmbeddedCollection(loadedParent[reloadProperty], reloadUri, reloadProperty, { get, reload, isUnknown }, config))
66✔
21
        : Promise.resolve(this),
22
      reload: { uri: reloadUri, property: reloadProperty }
23
    }
24
    this.addItemsGetter(items, reloadUri, reloadProperty)
132✔
25
  }
26

27
  $loadItems () {
28
    return new Promise((resolve) => {
6✔
29
      const items = this.items
6✔
30
      if (items instanceof LoadingStoreCollection) items._meta.load.then(result => resolve(result))
6!
31
      else resolve(items)
6✔
32
    })
33
  }
34
}
35

36
export default EmbeddedCollection
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc