adapt-authoring-spoortracking 1.1.0 → 1.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.
@@ -34,7 +34,7 @@ class SpoorTrackingModule extends AbstractModule {
34
34
  return
35
35
  }
36
36
  const content = await this.app.waitForModule('content')
37
- const [{ _trackingId }] = await content.find({ _courseId: data._courseId }, {}, { limit: 1, sort: [['_trackingId', -1]] })
37
+ const [{ _trackingId } = {}] = await content.find({ _courseId: data._courseId }, {}, { limit: 1, sort: [['_trackingId', -1]] })
38
38
  data._trackingId = (_trackingId ?? 0) + 1
39
39
  }
40
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-spoortracking",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Module for making course content compatible with spoor",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-spoortracking",
6
6
  "license": "GPL-3.0",
@@ -127,17 +127,11 @@ describe('SpoorTrackingModule', () => {
127
127
  assert.equal(data._trackingId, 1)
128
128
  })
129
129
 
130
- // TODO: BUG - insertTrackingId crashes when content.find returns an empty array
131
- // Destructuring `[{ _trackingId }]` from an empty array gives `undefined`,
132
- // causing a TypeError. This happens when a block is the first content item
133
- // inserted for a course.
134
130
  it('should handle empty find result gracefully', async () => {
135
131
  instance._contentMock.find.mock.mockImplementation(async () => [])
136
132
  const data = { _type: 'block', _courseId: 'emptyCourse' }
137
- await assert.rejects(
138
- () => instance.insertTrackingId(data),
139
- TypeError
140
- )
133
+ await instance.insertTrackingId(data)
134
+ assert.equal(data._trackingId, 1)
141
135
  })
142
136
  })
143
137