-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable to add an element with ordinal
with a safer way to assign ordinal, not relying on loop (which is based on array length) but on existing ordinal, to better handle legacy element without ordinal
- Loading branch information
Showing
2 changed files
with
15 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,9 @@ | ||
import { createEdition } from '../fixtures/entities.js' | ||
import { createListing } from '../fixtures/listings.js' | ||
import { authReq } from '../utils/utils.js' | ||
|
||
const endpoint = '/api/lists?action=' | ||
const byIds = `${endpoint}by-ids&with-elements=true` | ||
import { createListingWithElements } from '../fixtures/listings.js' | ||
|
||
describe('element:listing-ordinal', () => { | ||
it('should add elements with ordinals', async () => { | ||
const { listing } = await createListing() | ||
const { uri } = await createEdition() | ||
await authReq('post', `${endpoint}add-elements`, { | ||
id: listing._id, | ||
uris: [ uri ], | ||
}) | ||
const res = await authReq('get', `${byIds}&ids=${listing._id}`) | ||
const firstListing = res.lists[listing._id] | ||
firstListing.elements[0].ordinal.should.equal(0) | ||
it('should create elements with a listingId', async () => { | ||
const { listing } = await createListingWithElements() | ||
listing.elements[0].ordinal.should.equal(0) | ||
listing.elements[1].ordinal.should.equal(1) | ||
}) | ||
}) |