File: set.js

package info (click to toggle)
node-wikibase-edit 5.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 1,276 kB
  • sloc: javascript: 7,904; sh: 7; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 953 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// require('module-alias/register')
require('should')
const language = 'fr'
const setLabel = require('../../../lib/label/set')
const { randomString, someEntityId } = require('../utils')

describe('label', () => {
  it('should throw if not passed an entity', () => {
    setLabel.bind(null, {}).should.throw('invalid entity')
  })

  it('should throw if not passed a language', () => {
    setLabel.bind(null, { id: someEntityId }).should.throw('invalid language')
  })

  it('should throw if not passed a label', () => {
    setLabel.bind(null, { id: someEntityId, language }).should.throw('missing label')
  })

  it('should return an action and data', () => {
    const value = `Bac à Sable (${randomString()})`
    const { action, data } = setLabel({ id: someEntityId, language, value })
    action.should.equal('wbsetlabel')
    data.id.should.equal(someEntityId)
    data.language.should.equal(language)
    data.value.should.equal(value)
  })
})