Skip to content

Commit

Permalink
fix: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
neet committed Dec 23, 2022
1 parent 836d356 commit 58ba2c7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ describe('Config', () => {
expect(config.createWebsocketProtocols()).toEqual([]);
});

it('creates timeout controller with specific limit', () => {
it('creates timeout controller with specific limit', (done) => {
jest.useFakeTimers();
const config = new MastoConfig(
{
url: 'https://mastodon.social',
Expand All @@ -146,7 +147,10 @@ describe('Config', () => {
new SerializerNativeImpl(),
);

jest.useFakeTimers();
if (globalThis.AbortController === undefined) {
return done();
}

const controller = config.createTimeoutController();
assert(controller != undefined);

Expand Down
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export class MastoConfig {
if (this.props.timeout == undefined) {
return;
}
// FIXME
if (globalThis.AbortController === undefined) {
return;
}

const abortController = new AbortController();
setTimeout(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/http/get-content-type.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Headers } from '@mastojs/isomorphic-web';

import { getContentType } from './get-content-type';

test.each([
Expand Down
2 changes: 2 additions & 0 deletions src/paginator.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Headers } from '@mastojs/isomorphic-web';

import { HttpMockImpl } from './http/http-mock-impl';
import { Paginator } from './paginator';

Expand Down
8 changes: 7 additions & 1 deletion src/serializers/serializer-native-impl.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import assert from 'node:assert';

import { FormData } from '@mastojs/isomorphic-web';

import { SerializerNativeImpl } from './serializer-native-impl';

describe('SerializerNativeImpl', () => {
Expand All @@ -16,7 +18,11 @@ describe('SerializerNativeImpl', () => {
);
});

it('encodes an object to form-data', () => {
it('encodes an object to form-data', (done) => {
if (globalThis.FormData === undefined) {
return done();
}

const data = serializer.serialize('multipart/form-data', {
keyName: 'value',
anotherKeyName: ['value1', 'value2'],
Expand Down

0 comments on commit 58ba2c7

Please sign in to comment.