Skip to content

Commit

Permalink
Rework failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
harryadel committed Jun 19, 2024
1 parent 2e040c9 commit 064f9c2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/remove_allow.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const collection = new Mongo.Collection('test_remove_allow_collection')
if (Meteor.isServer) {
// full client-side access
collection.allow({
insertAsync () { return true },
updateAsync () { return true },
remove (userId, doc) { return doc.allowed },
removeAsync (userId, doc) { return doc.allowed }
insertAsync() { return true },

Check failure on line 11 in tests/remove_allow.js

View workflow job for this annotation

GitHub Actions / test

Missing space before function parentheses
updateAsync() { return true },

Check failure on line 12 in tests/remove_allow.js

View workflow job for this annotation

GitHub Actions / test

Missing space before function parentheses
remove(userId, doc) { return doc.allowed },

Check failure on line 13 in tests/remove_allow.js

View workflow job for this annotation

GitHub Actions / test

Missing space before function parentheses
removeAsync(userId, doc) { return doc.allowed }

Check failure on line 14 in tests/remove_allow.js

View workflow job for this annotation

GitHub Actions / test

Missing space before function parentheses
})

Meteor.methods({
Expand All @@ -30,6 +30,7 @@ if (Meteor.isClient) {

Tinytest.addAsync('remove - only one of two collection documents should be allowed to be removed', async function (test) {
collection.before.remove(function (userId, doc) {
// Ensuring remove gets triggered

Check failure on line 33 in tests/remove_allow.js

View workflow job for this annotation

GitHub Actions / test

Trailing spaces not allowed
test.equal(doc.start_value, true)
})

Expand All @@ -38,17 +39,16 @@ if (Meteor.isClient) {

const id1 = await collection.insertAsync({ start_value: true, allowed: true })
const id2 = await collection.insertAsync({ start_value: true, allowed: false })

// TODO(v3): allow-deny
await collection.removeAsync({ _id: id1 })
test.equal(collection.findOne({ _id: id1 }), undefined)
try {
// second document should be unremovable as allowed is set to false
await collection.removeAsync({ _id: id2 })
test.equal(collection.findOne({ _id: id2 }), { _id: id2, start_value: true, allowed: false })
test.fail('should not be allowed to remove')
} catch (e) {
// just ignore the error - it is expected
}

test.equal(collection.find({ start_value: true }).count(), 1, 'only one document should remain')
})
})
}

0 comments on commit 064f9c2

Please sign in to comment.