Skip to content

Commit

Permalink
chore(property-provider): arrow function in fromStatic (#1342)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Jul 8, 2020
1 parent d1e40c3 commit 558fcc8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 6 additions & 4 deletions packages/property-provider/src/fromStatic.spec.ts
Expand Up @@ -2,15 +2,17 @@ import { fromStatic } from "./fromStatic";

describe("fromStatic", () => {
it("should convert a static value into a provider", async () => {
const provider = fromStatic("string");

expect(await provider()).toBe("string");
const staticValue = "staticValue";
const provider = fromStatic(staticValue);
return expect(provider()).resolves.toStrictEqual(staticValue);
});

it("should always return the same promise", () => {
const provider = fromStatic("string");
const result = provider();

expect(provider()).toBe(result);
Array.from({ length: 5 }).forEach(item => {
expect(provider()).toStrictEqual(result);
});
});
});
6 changes: 2 additions & 4 deletions packages/property-provider/src/fromStatic.ts
@@ -1,6 +1,4 @@
import { Provider } from "@aws-sdk/types";

export function fromStatic<T>(staticValue: T): Provider<T> {
const promisified = Promise.resolve(staticValue);
return () => promisified;
}
export const fromStatic = <T>(staticValue: T): Provider<T> => () =>
Promise.resolve(staticValue);

0 comments on commit 558fcc8

Please sign in to comment.