-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add browserLocationHrefPipe (#63)
- Loading branch information
1 parent
47ce5d1
commit 7b8f53d
Showing
5 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { IPromise } from '@qiwi/substrate' | ||
|
||
import { IPipe, IPipeOutput, ITransmittable } from '../interfaces' | ||
import { clone, set } from '../utils/index' | ||
|
||
export const type = 'browser-location-href' | ||
|
||
export const createBrowserLocationHrefPipe = (): IPipe => ({ | ||
type, | ||
execute({ data }: ITransmittable): IPromise<IPipeOutput> { | ||
const output = set(clone(data), 'meta.location', window.location.href) | ||
return Promise.resolve([null, output]) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { test } from 'uvu' | ||
import * as assert from 'uvu/assert' | ||
|
||
import { createBrowserLocationHrefPipe } from '../../../main/ts/index' | ||
|
||
test('browserLocationHref is returned by factory', async () => { | ||
const browserLocationHrefPipe = createBrowserLocationHrefPipe() | ||
const res = await browserLocationHrefPipe.execute( | ||
{ data: {}, err: null, meta: { history: [] } }, | ||
() => { /* noop */ }, | ||
) | ||
assert.equal(res, [ | ||
null, | ||
{ meta: { location: 'https://github.com/qiwi/event-transmitter' } }, | ||
]) | ||
}) | ||
|
||
test.run() |