Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anniel-stripe committed Jan 31, 2023
1 parent 31c7948 commit 0b9ad42
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/PlatformFunctions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ require('../testUtils');
import DefaultPlatformFunctions = require('../lib/platform/DefaultPlatformFunctions');
import EventEmitter = require('events');
import NodePlatformFunctions = require('../lib/platform/NodePlatformFunctions');
import StripeEmitter = require('../lib/StripeEmitter');

import {expect} from 'chai';

Expand Down Expand Up @@ -188,15 +187,16 @@ for (const platform in platforms) {
describe('createEmitter', () => {
// Only run tests if EventTarget is available (Node >= 15).
if (process.version < '14') {
let oldCreateEmitter: StripeEmitter;
const StripeEmitter = require('../lib/StripeEmitter');
let oldCreateEmitter;

if (!isNodeEnvironment) {
before(() => {
oldCreateEmitter = platformFunctions.createEmitter;

// StripeEmitter uses the Event Web API. `createEmitter` needs
// to be defined here to avoid reference errors in Node versions <15.
platformFunctions.createEmitter = (): StripeEmitter => {
platformFunctions.createEmitter = () => {
return new StripeEmitter(new EventTarget());
};
});
Expand All @@ -206,7 +206,7 @@ for (const platform in platforms) {
});
}

let emitter: StripeEmitter | EventEmitter;
let emitter;
beforeEach(() => {
emitter = platformFunctions.createEmitter();
});
Expand Down

0 comments on commit 0b9ad42

Please sign in to comment.