Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
wwahammy committed Oct 18, 2022
1 parent a89c2df commit 4af5b4f
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 335 deletions.
1 change: 0 additions & 1 deletion app/javascript/common/Callbacks/run.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// License: LGPL-3.0-or-later
import type { CallbackClass } from "./types";


/**
* A very simple function for conditionally running callbacks. Move into own file because we can mock it for CallbackController
* @param input The input properties to every callback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ describe('PlausibleCallback', () => {
describe('.canRun', () => {
it('false when getPlausible is undefined', () => {
const c = new PlausibleCallback({ props: {}} as any);
expect(c.canRun).toEqual(false)
expect(c.canRun()).toEqual(false)
})

it('false when getPlausible returns undefined', () => {
const c = new PlausibleCallback({ props: {getPlausible: ():any => undefined}} as any);
expect(c.canRun).toEqual(false)
expect(c.canRun()).toEqual(false)
})

it('true when returns plausible function', () => {
const realPlausibleFunc = jest.fn();
const c = new PlausibleCallback({ props: {getPlausible: ():any => realPlausibleFunc}} as any);
expect(c.canRun).toEqual(true);
expect(c.canRun()).toEqual(true);
})
})

Expand All @@ -28,7 +28,7 @@ describe('PlausibleCallback', () => {
plausible: realPlausibleFunc,
obj: new PlausibleCallback({ props: {getPlausible: ():any => realPlausibleFunc}, result} as any)
};

}

it('calls plausible with no amount when result is undefined', async () => {
Expand All @@ -40,7 +40,7 @@ describe('PlausibleCallback', () => {
}
});
})

it('calls plausible with no amount when charge is undefined', async () => {
const {plausible, obj} = build({});
await obj.run();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DonationSubmitterCallbackAction } from "./types";
import { Callback } from "../../../../../app/javascript/common/Callbacks";
import DonationSubmitter from './';

// License: LGPL-3.0-or-later
export interface PlausibleFunction {
Expand All @@ -11,12 +12,12 @@ export interface GetPlausible {
}


export default class PlausibleCallback extends DonationSubmitterCallbackAction {
export default class PlausibleCallback extends Callback<DonationSubmitter> {

private get plausibleFunction(): PlausibleFunction {
return this.props.props.getPlausible()
}
get canRun(): boolean {
canRun(): boolean {
return !!(this.props.props.getPlausible && this.props.props.getPlausible())
}

Expand All @@ -31,5 +32,5 @@ export default class PlausibleCallback extends DonationSubmitterCallbackAction {
catchError(e: unknown): void {
console.log(e);
}

}

This file was deleted.

This file was deleted.

129 changes: 0 additions & 129 deletions client/js/nonprofits/donate/DonationSubmitter/callbacks/Runner.spec.ts

This file was deleted.

54 changes: 0 additions & 54 deletions client/js/nonprofits/donate/DonationSubmitter/callbacks/Runner.ts

This file was deleted.

This file was deleted.

29 changes: 0 additions & 29 deletions client/js/nonprofits/donate/DonationSubmitter/callbacks/run.ts

This file was deleted.

12 changes: 0 additions & 12 deletions client/js/nonprofits/donate/DonationSubmitter/callbacks/types.ts

This file was deleted.

Loading

0 comments on commit 4af5b4f

Please sign in to comment.