-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathremoveRemote.spec.ts
More file actions
67 lines (59 loc) · 2.3 KB
/
Copy pathremoveRemote.spec.ts
File metadata and controls
67 lines (59 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { expect } from "chai";
import nock from "../test/helpers/nock";
import * as utils from "../utils";
import { RTDBRemoveRemote } from "./removeRemote";
describe("RemoveRemote", () => {
const instance = "fake-db";
const host = "https://firebaseio.com";
const remote = new RTDBRemoveRemote(instance, host, /* disableTriggers= */ false);
const serverUrl = utils.getDatabaseUrl(host, instance, "");
afterEach(() => {
nock.cleanAll();
});
it("should return true when patch is small", () => {
nock(serverUrl)
.patch("/a/b.json")
.query({ print: "silent", writeSizeLimit: "tiny", disableTriggers: "false" })
.reply(200, {});
return expect(remote.deletePath("/a/b")).to.eventually.eql(true);
});
it("should return false whem patch is large", () => {
nock(serverUrl)
.patch("/a/b.json")
.query({ print: "silent", writeSizeLimit: "tiny", disableTriggers: "false" })
.reply(400, {
error:
"Data requested exceeds the maximum size that can be accessed with a single request.",
});
return expect(remote.deleteSubPath("/a/b", ["1", "2", "3"])).to.eventually.eql(false);
});
it("should return true when multi-path patch is small", () => {
nock(serverUrl)
.patch("/a/b.json")
.query({ print: "silent", writeSizeLimit: "tiny", disableTriggers: "false" })
.reply(200, {});
return expect(remote.deleteSubPath("/a/b", ["1", "2", "3"])).to.eventually.eql(true);
});
it("should return false when multi-path patch is large", () => {
nock(serverUrl)
.patch("/a/b.json")
.query({ print: "silent", writeSizeLimit: "tiny", disableTriggers: "false" })
.reply(400, {
error:
"Data requested exceeds the maximum size that can be accessed with a single request.",
});
return expect(remote.deleteSubPath("/a/b", ["1", "2", "3"])).to.eventually.eql(false);
});
it("should send disableTriggers param", () => {
const remoteWithDisableTriggers = new RTDBRemoveRemote(
instance,
host,
/* disableTriggers= */ true,
);
nock(serverUrl)
.patch("/a/b.json")
.query({ print: "silent", writeSizeLimit: "tiny", disableTriggers: "true" })
.reply(200, {});
return expect(remoteWithDisableTriggers.deletePath("/a/b")).to.eventually.eql(true);
});
});