adapt-authoring-tags 1.3.1 → 1.3.3

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.
@@ -1,4 +1,4 @@
1
- name: Standard.js formatting check
1
+ name: Lint
2
2
  on: push
3
3
  jobs:
4
4
  default:
@@ -9,4 +9,4 @@ jobs:
9
9
  with:
10
10
  node-version: 'lts/*'
11
11
  - run: npm install
12
- - run: npx standard
12
+ - run: npx standard
package/lib/TagsModule.js CHANGED
@@ -102,11 +102,11 @@ class TagsModule extends AbstractApiModule {
102
102
  }
103
103
 
104
104
  /** @override */
105
- async insert (...args) {
105
+ async insert (data, options = {}, mongoOptions = {}) {
106
106
  // allow attempts to create tags that already exist
107
- const [tag] = await this.find(...args)
107
+ const tag = await this.findOne(data, { ...options, strict: false }, mongoOptions)
108
108
  if (tag) return tag
109
- return super.insert(...args)
109
+ return super.insert(data, options, mongoOptions)
110
110
  }
111
111
 
112
112
  /** @override */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-tags",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Module for managing tags",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-tags",
6
6
  "license": "GPL-3.0",
@@ -478,16 +478,16 @@ describe('TagsModule', () => {
478
478
  assert.equal(parentInsert.mock.calls.length, 1)
479
479
  })
480
480
 
481
- it('should pass through all arguments to find', async () => {
481
+ it('should pass through all arguments to findOne', async () => {
482
482
  const { instance } = createInstance()
483
- instance.find = mock.fn(async () => [{ _id: 'tag1', title: 'test' }])
483
+ instance.findOne = mock.fn(async () => ({ _id: 'tag1', title: 'test' }))
484
484
  const data = { title: 'test' }
485
485
  const options = { validate: false }
486
486
  const mongoOpts = { limit: 1 }
487
487
  await instance.insert(data, options, mongoOpts)
488
- const findArgs = instance.find.mock.calls[0].arguments
488
+ const findArgs = instance.findOne.mock.calls[0].arguments
489
489
  assert.equal(findArgs[0], data)
490
- assert.equal(findArgs[1], options)
490
+ assert.deepEqual(findArgs[1], { validate: false, strict: false })
491
491
  assert.equal(findArgs[2], mongoOpts)
492
492
  })
493
493
  })