UNPKG

wikibase-edit

Version:

Edit Wikibase from NodeJS

35 lines 1.58 kB
import 'should'; import { removeAlias } from '../../../src/lib/alias/remove.js'; import { assert, randomString, someEntityId } from '../utils.js'; const language = 'it'; describe('alias remove', () => { it('should reject if not passed an entity id', () => { // @ts-expect-error removeAlias.bind(null, {}).should.throw('invalid entity id'); }); it('should reject if not passed a language', () => { // @ts-expect-error removeAlias.bind(null, { id: someEntityId }).should.throw('invalid language'); }); it('should reject if not passed an alias', () => { // @ts-expect-error removeAlias.bind(null, { id: someEntityId, language }).should.throw('empty alias array'); }); it('should accept a single alias string', () => { // It's not necessary that the removed alias actually exist // so we can just pass a random string and expect Wikibase to deal with it const value = randomString(); const { action, data } = removeAlias({ id: someEntityId, language, value }); action.should.equal('wbsetaliases'); assert('remove' in data); data.remove.should.equal(value); }); it('should accept multiple aliases as an array of strings', () => { const value = [randomString(), randomString()]; const { action, data } = removeAlias({ id: someEntityId, language, value }); action.should.equal('wbsetaliases'); assert('remove' in data); data.remove.should.equal(value.join('|')); }); }); //# sourceMappingURL=remove.js.map