本文整理匯總了TypeScript中@firebase/testing.assertFails函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript assertFails函數的具體用法?TypeScript assertFails怎麽用?TypeScript assertFails使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了assertFails函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: authedApp
@test
async "should require the user creating a room to be its owner"() {
const alice = authedApp({ uid: "alice" });
// should not be able to create room owned by another user
await firebase.assertFails(alice.ref("rooms/room1").set({ owner: "bob" }));
// should not be able to create room with no owner
await firebase.assertFails(
alice.ref("rooms/room1").set({ members: { alice: true } })
);
// alice should be allowed to create a room she owns
await firebase.assertSucceeds(
alice.ref("rooms/room1").set({ owner: "alice" })
);
}
示例2: authedApp
@test
async "should not let one user steal a room from another user"() {
const alice = authedApp({ uid: "alice" });
const bob = authedApp({ uid: "bob" });
await firebase.assertSucceeds(
bob
.collection("rooms")
.doc("snow")
.set({
owner: "bob",
topic: "All Things Snowboarding"
})
);
await firebase.assertFails(
alice
.collection("rooms")
.doc("snow")
.set({
owner: "alice",
topic: "skiing > snowboarding"
})
);
}