-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
label.set/description.set: allow to remove a term by passing an empty…
… string as value
- Loading branch information
Showing
4 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,40 @@ | ||
require('should') | ||
const should = require('should') | ||
const config = require('config') | ||
const wbEdit = require('root')(config) | ||
const { randomString } = require('tests/unit/utils') | ||
const { getSandboxItemId } = require('tests/integration/utils/sandbox_entities') | ||
const { getSandboxItemId, getRefreshedEntity } = require('tests/integration/utils/sandbox_entities') | ||
const language = 'fr' | ||
|
||
describe('description set', function () { | ||
this.timeout(20 * 1000) | ||
before('wait for instance', require('tests/integration/utils/wait_for_instance')) | ||
|
||
it('should set a label', async () => { | ||
it('should set a description', async () => { | ||
const id = await getSandboxItemId() | ||
const value = `Bac à Sable (${randomString()})` | ||
const res = await wbEdit.description.set({ id, language, value }) | ||
res.success.should.equal(1) | ||
const item = await getRefreshedEntity(id) | ||
item.descriptions[language].value.should.equal(value) | ||
}) | ||
|
||
it('should remove a description when passed value=null', async () => { | ||
const id = await getSandboxItemId() | ||
const value = `Bac à Sable (${randomString()})` | ||
await wbEdit.description.set({ id, language, value }) | ||
const res = await wbEdit.description.set({ id, language, value: null }) | ||
res.success.should.equal(1) | ||
const item = await getRefreshedEntity(id) | ||
should(item.descriptions[language]).not.be.ok() | ||
}) | ||
|
||
it('should remove a description when passed value=""', async () => { | ||
const id = await getSandboxItemId() | ||
const value = `Bac à Sable (${randomString()})` | ||
await wbEdit.description.set({ id, language, value }) | ||
const res = await wbEdit.description.set({ id, language, value: '' }) | ||
res.success.should.equal(1) | ||
const item = await getRefreshedEntity(id) | ||
should(item.descriptions[language]).not.be.ok() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters