Skip to content

Commit cc0a45c

Browse files
committed
Update rules-unit-testing files
1 parent 887e683 commit cc0a45c

File tree

5 files changed

+25
-19
lines changed

5 files changed

+25
-19
lines changed

packages/rules-unit-testing/src/impl/discovery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function discoverEmulators(
2929
hub: HostAndPort,
3030
fetch: typeof nodeFetch = nodeFetch
3131
): Promise<DiscoveredEmulators> {
32-
const res = await fetch(makeUrl(hub, '/emulators'));
32+
const res = await fetch(makeUrl(hub, '/emulators').toString());
3333
if (!res.ok) {
3434
throw new Error(
3535
`HTTP Error ${res.status} when attempting to reach Emulator Hub at ${res.url}, are you sure it is running?`
@@ -38,7 +38,7 @@ export async function discoverEmulators(
3838

3939
const emulators: DiscoveredEmulators = {};
4040

41-
const data = await res.json();
41+
const data = (await res.json()) as any;
4242

4343
if (data.database) {
4444
emulators.database = {

packages/rules-unit-testing/src/impl/rules.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function loadDatabaseRules(
2929
): Promise<void> {
3030
const url = makeUrl(hostAndPort, '/.settings/rules.json');
3131
url.searchParams.append('ns', databaseName);
32-
const resp = await fetch(url, {
32+
const resp = await fetch(url.toString(), {
3333
method: 'PUT',
3434
headers: { Authorization: 'Bearer owner' },
3535
body: rules
@@ -49,7 +49,10 @@ export async function loadFirestoreRules(
4949
rules: string
5050
): Promise<void> {
5151
const resp = await fetch(
52-
makeUrl(hostAndPort, `/emulator/v1/projects/${projectId}:securityRules`),
52+
makeUrl(
53+
hostAndPort,
54+
`/emulator/v1/projects/${projectId}:securityRules`
55+
).toString(),
5356
{
5457
method: 'PUT',
5558
body: JSON.stringify({
@@ -72,17 +75,20 @@ export async function loadStorageRules(
7275
hostAndPort: HostAndPort,
7376
rules: string
7477
): Promise<void> {
75-
const resp = await fetch(makeUrl(hostAndPort, '/internal/setRules'), {
76-
method: 'PUT',
77-
headers: {
78-
'Content-Type': 'application/json'
79-
},
80-
body: JSON.stringify({
81-
rules: {
82-
files: [{ name: 'storage.rules', content: rules }]
83-
}
84-
})
85-
});
78+
const resp = await fetch(
79+
makeUrl(hostAndPort, '/internal/setRules').toString(),
80+
{
81+
method: 'PUT',
82+
headers: {
83+
'Content-Type': 'application/json'
84+
},
85+
body: JSON.stringify({
86+
rules: {
87+
files: [{ name: 'storage.rules', content: rules }]
88+
}
89+
})
90+
}
91+
);
8692
if (!resp.ok) {
8793
throw new Error(await resp.text());
8894
}

packages/rules-unit-testing/src/impl/test_environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class RulesTestEnvironmentImpl implements RulesTestEnvironment {
110110
makeUrl(
111111
this.emulators.firestore,
112112
`/emulator/v1/projects/${this.projectId}/databases/(default)/documents`
113-
),
113+
).toString(),
114114
{
115115
method: 'DELETE'
116116
}

packages/rules-unit-testing/src/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export async function withFunctionTriggersDisabled<TResult>(
8080
makeUrl(hub, '/functions/disableBackgroundTriggers');
8181
// Disable background triggers
8282
const disableRes = await fetch(
83-
makeUrl(hub, '/functions/disableBackgroundTriggers'),
83+
makeUrl(hub, '/functions/disableBackgroundTriggers').toString(),
8484
{
8585
method: 'PUT'
8686
}
@@ -98,7 +98,7 @@ export async function withFunctionTriggersDisabled<TResult>(
9898
} finally {
9999
// Re-enable background triggers
100100
const enableRes = await fetch(
101-
makeUrl(hub, '/functions/enableBackgroundTriggers'),
101+
makeUrl(hub, '/functions/enableBackgroundTriggers').toString(),
102102
{
103103
method: 'PUT'
104104
}

repo-scripts/changelog-generator/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ async function getFixedIssueLink(
103103
'Authorization': `Bearer ${process.env.GITHUB_TOKEN}`
104104
}
105105
}
106-
).then(data => data.json());
106+
).then(data => data.json() as Promise<{ body: string }>);
107107

108108
const match = fixedIssueRegex.exec(body);
109109
if (!match) {

0 commit comments

Comments
 (0)