tests: fix memory leaks (#2389)
This commit is contained in:
@@ -1,30 +1,36 @@
|
||||
/* eslint-disable no-undef */
|
||||
chai.use(chaiAsPromised)
|
||||
const expect = chai.expect
|
||||
|
||||
describe('note display criteria', function () {
|
||||
let payloadManager
|
||||
let itemManager
|
||||
let mutator
|
||||
|
||||
let createNote
|
||||
let createTag
|
||||
|
||||
beforeEach(async function () {
|
||||
const logger = new Logger('test')
|
||||
|
||||
this.payloadManager = new PayloadManager(logger)
|
||||
this.itemManager = new ItemManager(this.payloadManager)
|
||||
this.mutator = new MutatorService(this.itemManager, this.payloadManager)
|
||||
payloadManager = new PayloadManager(logger)
|
||||
itemManager = new ItemManager(payloadManager)
|
||||
mutator = new MutatorService(itemManager, payloadManager)
|
||||
|
||||
this.createNote = async (title = 'hello', text = 'world') => {
|
||||
return this.mutator.createItem(ContentType.TYPES.Note, {
|
||||
createNote = async (title = 'hello', text = 'world') => {
|
||||
return mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: title,
|
||||
text: text,
|
||||
})
|
||||
}
|
||||
|
||||
this.createTag = async (notes = [], title = 'thoughts') => {
|
||||
createTag = async (notes = [], title = 'thoughts') => {
|
||||
const references = notes.map((note) => {
|
||||
return {
|
||||
uuid: note.uuid,
|
||||
content_type: note.content_type,
|
||||
}
|
||||
})
|
||||
return this.mutator.createItem(ContentType.TYPES.Tag, {
|
||||
return mutator.createItem(ContentType.TYPES.Tag, {
|
||||
title: title,
|
||||
references: references,
|
||||
})
|
||||
@@ -32,177 +38,147 @@ describe('note display criteria', function () {
|
||||
})
|
||||
|
||||
it('includePinned off', async function () {
|
||||
await this.createNote()
|
||||
const pendingPin = await this.createNote()
|
||||
await this.mutator.changeItem(pendingPin, (mutator) => {
|
||||
await createNote()
|
||||
const pendingPin = await createNote()
|
||||
await mutator.changeItem(pendingPin, (mutator) => {
|
||||
mutator.pinned = true
|
||||
})
|
||||
const criteria = {
|
||||
includePinned: false,
|
||||
}
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
notesAndFilesMatchingOptions(criteria, itemManager.collection.all(ContentType.TYPES.Note), itemManager.collection)
|
||||
.length,
|
||||
).to.equal(1)
|
||||
})
|
||||
|
||||
it('includePinned on', async function () {
|
||||
await this.createNote()
|
||||
const pendingPin = await this.createNote()
|
||||
await this.mutator.changeItem(pendingPin, (mutator) => {
|
||||
await createNote()
|
||||
const pendingPin = await createNote()
|
||||
await mutator.changeItem(pendingPin, (mutator) => {
|
||||
mutator.pinned = true
|
||||
})
|
||||
const criteria = { includePinned: true }
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
notesAndFilesMatchingOptions(criteria, itemManager.collection.all(ContentType.TYPES.Note), itemManager.collection)
|
||||
.length,
|
||||
).to.equal(2)
|
||||
})
|
||||
|
||||
it('includeTrashed off', async function () {
|
||||
await this.createNote()
|
||||
const pendingTrash = await this.createNote()
|
||||
await this.mutator.changeItem(pendingTrash, (mutator) => {
|
||||
await createNote()
|
||||
const pendingTrash = await createNote()
|
||||
await mutator.changeItem(pendingTrash, (mutator) => {
|
||||
mutator.trashed = true
|
||||
})
|
||||
const criteria = { includeTrashed: false }
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
notesAndFilesMatchingOptions(criteria, itemManager.collection.all(ContentType.TYPES.Note), itemManager.collection)
|
||||
.length,
|
||||
).to.equal(1)
|
||||
})
|
||||
|
||||
it('includeTrashed on', async function () {
|
||||
await this.createNote()
|
||||
const pendingTrash = await this.createNote()
|
||||
await this.mutator.changeItem(pendingTrash, (mutator) => {
|
||||
await createNote()
|
||||
const pendingTrash = await createNote()
|
||||
await mutator.changeItem(pendingTrash, (mutator) => {
|
||||
mutator.trashed = true
|
||||
})
|
||||
const criteria = { includeTrashed: true }
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
notesAndFilesMatchingOptions(criteria, itemManager.collection.all(ContentType.TYPES.Note), itemManager.collection)
|
||||
.length,
|
||||
).to.equal(2)
|
||||
})
|
||||
|
||||
it('includeArchived off', async function () {
|
||||
await this.createNote()
|
||||
const pendingArchive = await this.createNote()
|
||||
await this.mutator.changeItem(pendingArchive, (mutator) => {
|
||||
await createNote()
|
||||
const pendingArchive = await createNote()
|
||||
await mutator.changeItem(pendingArchive, (mutator) => {
|
||||
mutator.archived = true
|
||||
})
|
||||
const criteria = { includeArchived: false }
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
notesAndFilesMatchingOptions(criteria, itemManager.collection.all(ContentType.TYPES.Note), itemManager.collection)
|
||||
.length,
|
||||
).to.equal(1)
|
||||
})
|
||||
|
||||
it('includeArchived on', async function () {
|
||||
await this.createNote()
|
||||
const pendingArchive = await this.createNote()
|
||||
await this.mutator.changeItem(pendingArchive, (mutator) => {
|
||||
await createNote()
|
||||
const pendingArchive = await createNote()
|
||||
await mutator.changeItem(pendingArchive, (mutator) => {
|
||||
mutator.archived = true
|
||||
})
|
||||
const criteria = {
|
||||
includeArchived: true,
|
||||
}
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
notesAndFilesMatchingOptions(criteria, itemManager.collection.all(ContentType.TYPES.Note), itemManager.collection)
|
||||
.length,
|
||||
).to.equal(2)
|
||||
})
|
||||
|
||||
it('includeProtected off', async function () {
|
||||
await this.createNote()
|
||||
const pendingProtected = await this.createNote()
|
||||
await this.mutator.changeItem(pendingProtected, (mutator) => {
|
||||
await createNote()
|
||||
const pendingProtected = await createNote()
|
||||
await mutator.changeItem(pendingProtected, (mutator) => {
|
||||
mutator.protected = true
|
||||
})
|
||||
const criteria = { includeProtected: false }
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
notesAndFilesMatchingOptions(criteria, itemManager.collection.all(ContentType.TYPES.Note), itemManager.collection)
|
||||
.length,
|
||||
).to.equal(1)
|
||||
})
|
||||
|
||||
it('includeProtected on', async function () {
|
||||
await this.createNote()
|
||||
const pendingProtected = await this.createNote()
|
||||
await this.mutator.changeItem(pendingProtected, (mutator) => {
|
||||
await createNote()
|
||||
const pendingProtected = await createNote()
|
||||
await mutator.changeItem(pendingProtected, (mutator) => {
|
||||
mutator.protected = true
|
||||
})
|
||||
const criteria = {
|
||||
includeProtected: true,
|
||||
}
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
notesAndFilesMatchingOptions(criteria, itemManager.collection.all(ContentType.TYPES.Note), itemManager.collection)
|
||||
.length,
|
||||
).to.equal(2)
|
||||
})
|
||||
|
||||
it('protectedSearchEnabled false', async function () {
|
||||
const normal = await this.createNote('hello', 'world')
|
||||
await this.mutator.changeItem(normal, (mutator) => {
|
||||
const normal = await createNote('hello', 'world')
|
||||
await mutator.changeItem(normal, (mutator) => {
|
||||
mutator.protected = true
|
||||
})
|
||||
const criteria = {
|
||||
searchQuery: { query: 'world', includeProtectedNoteText: false },
|
||||
}
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
notesAndFilesMatchingOptions(criteria, itemManager.collection.all(ContentType.TYPES.Note), itemManager.collection)
|
||||
.length,
|
||||
).to.equal(0)
|
||||
})
|
||||
|
||||
it('protectedSearchEnabled true', async function () {
|
||||
const normal = await this.createNote()
|
||||
await this.mutator.changeItem(normal, (mutator) => {
|
||||
const normal = await createNote()
|
||||
await mutator.changeItem(normal, (mutator) => {
|
||||
mutator.protected = true
|
||||
})
|
||||
const criteria = {
|
||||
searchQuery: { query: 'world', includeProtectedNoteText: true },
|
||||
}
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
notesAndFilesMatchingOptions(criteria, itemManager.collection.all(ContentType.TYPES.Note), itemManager.collection)
|
||||
.length,
|
||||
).to.equal(1)
|
||||
})
|
||||
|
||||
it('tags', async function () {
|
||||
const note = await this.createNote()
|
||||
const tag = await this.createTag([note])
|
||||
const looseTag = await this.createTag([], 'loose')
|
||||
const note = await createNote()
|
||||
const tag = await createTag([note])
|
||||
const looseTag = await createTag([], 'loose')
|
||||
|
||||
const matchingCriteria = {
|
||||
tags: [tag],
|
||||
@@ -210,8 +186,8 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
matchingCriteria,
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
@@ -221,125 +197,125 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
nonmatchingCriteria,
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
})
|
||||
|
||||
describe('smart views', function () {
|
||||
it('normal note', async function () {
|
||||
await this.createNote()
|
||||
await createNote()
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
views: [itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
})
|
||||
|
||||
it('trashed note', async function () {
|
||||
const normal = await this.createNote()
|
||||
await this.mutator.changeItem(normal, (mutator) => {
|
||||
const normal = await createNote()
|
||||
await mutator.changeItem(normal, (mutator) => {
|
||||
mutator.trashed = true
|
||||
})
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
includeTrashed: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
views: [itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
})
|
||||
|
||||
it('archived note', async function () {
|
||||
const normal = await this.createNote()
|
||||
await this.mutator.changeItem(normal, (mutator) => {
|
||||
const normal = await createNote()
|
||||
await mutator.changeItem(normal, (mutator) => {
|
||||
mutator.trashed = false
|
||||
mutator.archived = true
|
||||
})
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
views: [itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
})
|
||||
|
||||
it('archived + trashed note', async function () {
|
||||
const normal = await this.createNote()
|
||||
await this.mutator.changeItem(normal, (mutator) => {
|
||||
const normal = await createNote()
|
||||
await mutator.changeItem(normal, (mutator) => {
|
||||
mutator.trashed = true
|
||||
mutator.archived = true
|
||||
})
|
||||
@@ -347,30 +323,30 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
views: [itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
})
|
||||
@@ -378,87 +354,87 @@ describe('note display criteria', function () {
|
||||
|
||||
describe('includeTrash', function () {
|
||||
it('normal note', async function () {
|
||||
await this.createNote()
|
||||
await createNote()
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
})
|
||||
|
||||
it('trashed note', async function () {
|
||||
const normal = await this.createNote()
|
||||
const normal = await createNote()
|
||||
|
||||
await this.mutator.changeItem(normal, (mutator) => {
|
||||
await mutator.changeItem(normal, (mutator) => {
|
||||
mutator.trashed = true
|
||||
})
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
includeTrashed: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
views: [itemManager.archivedSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
})
|
||||
|
||||
it('archived + trashed note', async function () {
|
||||
const normal = await this.createNote()
|
||||
const normal = await createNote()
|
||||
|
||||
await this.mutator.changeItem(normal, (mutator) => {
|
||||
await mutator.changeItem(normal, (mutator) => {
|
||||
mutator.trashed = true
|
||||
mutator.archived = true
|
||||
})
|
||||
@@ -466,30 +442,30 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
views: [itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
})
|
||||
@@ -497,85 +473,85 @@ describe('note display criteria', function () {
|
||||
|
||||
describe('includeArchived', function () {
|
||||
it('normal note', async function () {
|
||||
await this.createNote()
|
||||
await createNote()
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
})
|
||||
|
||||
it('archived note', async function () {
|
||||
const normal = await this.createNote()
|
||||
await this.mutator.changeItem(normal, (mutator) => {
|
||||
const normal = await createNote()
|
||||
await mutator.changeItem(normal, (mutator) => {
|
||||
mutator.archived = true
|
||||
})
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
views: [itemManager.archivedSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
})
|
||||
|
||||
it('archived + trashed note', async function () {
|
||||
const normal = await this.createNote()
|
||||
await this.mutator.changeItem(normal, (mutator) => {
|
||||
const normal = await createNote()
|
||||
await mutator.changeItem(normal, (mutator) => {
|
||||
mutator.trashed = true
|
||||
mutator.archived = true
|
||||
})
|
||||
@@ -583,33 +559,33 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
views: [itemManager.archivedSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
})
|
||||
@@ -617,7 +593,7 @@ describe('note display criteria', function () {
|
||||
|
||||
describe.skip('multiple tags', function () {
|
||||
it('normal note', async function () {
|
||||
await this.createNote()
|
||||
await createNote()
|
||||
/**
|
||||
* This test presently fails because the compound predicate created
|
||||
* when using multiple views is an AND predicate instead of OR
|
||||
@@ -625,82 +601,78 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [
|
||||
this.itemManager.allNotesSmartView,
|
||||
this.itemManager.archivedSmartView,
|
||||
this.itemManager.trashSmartView,
|
||||
],
|
||||
views: [itemManager.allNotesSmartView, itemManager.archivedSmartView, itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
})
|
||||
|
||||
it('archived note', async function () {
|
||||
const normal = await this.createNote()
|
||||
await this.mutator.changeItem(normal, (mutator) => {
|
||||
const normal = await createNote()
|
||||
await mutator.changeItem(normal, (mutator) => {
|
||||
mutator.archived = true
|
||||
})
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
views: [itemManager.archivedSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
})
|
||||
|
||||
it('archived + trashed note', async function () {
|
||||
const normal = await this.createNote()
|
||||
await this.mutator.changeItem(normal, (mutator) => {
|
||||
const normal = await createNote()
|
||||
await mutator.changeItem(normal, (mutator) => {
|
||||
mutator.trashed = true
|
||||
mutator.archived = true
|
||||
})
|
||||
@@ -708,33 +680,33 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
views: [itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
views: [itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
views: [itemManager.archivedSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
itemManager.collection.all(ContentType.TYPES.Note),
|
||||
itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user