])
})
+ it('selection model should sort items by state and document counts = 0, if set', () => {
+ const tagA = { id: 4, name: 'Tag A' }
+ component.items = items.concat([tagA])
+ component.selectionModel = selectionModel
+ component.documentCounts = [
+ { id: 1, document_count: 0 }, // Tag1
+ { id: 2, document_count: 1 }, // Tag2
+ { id: 4, document_count: 2 }, // Tag A
+ ]
+ component.selectionModel.apply()
+ expect(selectionModel.items).toEqual([
+ nullItem,
+ tagA,
+ items[1], // Tag2
+ items[0], // Tag1
+ ])
+
+ selectionModel.toggle(items[1].id)
+ component.documentCounts = [
+ { id: 1, document_count: 0 },
+ { id: 2, document_count: 1 },
+ { id: 4, document_count: 0 },
+ ]
+ selectionModel.apply()
+ expect(selectionModel.items).toEqual([
+ nullItem,
+ items[1], // Tag2
+ tagA,
+ items[0], // Tag1
+ ])
+ })
+
it('should set support create, keep open model and call createRef method', fakeAsync(() => {
component.items = items
component.icon = 'tag-fill'
this.getNonTemporary(b.id) == ToggleableItemState.NotSelected
) {
return -1
+ } else if (
+ this._documentCounts.length &&
+ this.getDocumentCount(b.id) === 0 &&
+ this.getDocumentCount(a.id) > this.getDocumentCount(b.id)
+ ) {
+ return -1
+ } else if (
+ this._documentCounts.length &&
+ this.getDocumentCount(a.id) === 0 &&
+ this.getDocumentCount(a.id) < this.getDocumentCount(b.id)
+ ) {
+ return 1
} else {
return a.name.localeCompare(b.name)
}