-
+
{t('doc_auth.headings.interstitial')}
diff --git a/app/javascript/packages/document-capture/hooks/use-asset.js b/app/javascript/packages/document-capture/hooks/use-asset.js
new file mode 100644
index 00000000000..196e2eadff8
--- /dev/null
+++ b/app/javascript/packages/document-capture/hooks/use-asset.js
@@ -0,0 +1,21 @@
+import { useContext } from 'react';
+import AssetContext from '../context/asset';
+
+function useAsset() {
+ const assets = useContext(AssetContext);
+
+ /**
+ * Returns the mapped URL path associated with the given asset path, or `undefined` if the mapped
+ * URL path is not known.
+ *
+ * @param {string} assetPath Asset path.
+ *
+ * @return {string|undefined} Mapped URL path, or undefined if there is no associated asset path.
+ */
+ const getAssetPath = (assetPath) =>
+ Object.prototype.hasOwnProperty.call(assets, assetPath) ? assets[assetPath] : undefined;
+
+ return { getAssetPath };
+}
+
+export default useAsset;
diff --git a/spec/javascripts/packages/document-capture/components/image-spec.jsx b/spec/javascripts/packages/document-capture/components/image-spec.jsx
deleted file mode 100644
index 3b763b66b52..00000000000
--- a/spec/javascripts/packages/document-capture/components/image-spec.jsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import React from 'react';
-import Image from '@18f/identity-document-capture/components/image';
-import AssetContext from '@18f/identity-document-capture/context/asset';
-import render from '../../../support/render';
-
-describe('document-capture/components/image', () => {
- it('renders the given assetPath as src if the asset is not known', () => {
- const { getByAltText } = render(
);
-
- const img = getByAltText('unknown');
-
- expect(img.getAttribute('src')).to.equal('unknown.png');
- });
-
- it('renders an img at mapped src if known by context', () => {
- const { getByAltText } = render(
-
-
- ,
- );
-
- const img = getByAltText('icon');
-
- expect(img.getAttribute('src')).to.equal('icon-12345.png');
- });
-
- it('renders with given props', () => {
- const { getByAltText } = render(
);
-
- const img = getByAltText('icon');
-
- expect(img.width).to.equal(50);
- });
-});
diff --git a/spec/javascripts/packages/document-capture/hooks/use-asset-spec.jsx b/spec/javascripts/packages/document-capture/hooks/use-asset-spec.jsx
new file mode 100644
index 00000000000..04aab5a5c77
--- /dev/null
+++ b/spec/javascripts/packages/document-capture/hooks/use-asset-spec.jsx
@@ -0,0 +1,36 @@
+import React, { createElement } from 'react';
+import useAsset from '@18f/identity-document-capture/hooks/use-asset';
+import AssetContext from '@18f/identity-document-capture/context/asset';
+import render from '../../../support/render';
+
+describe('document-capture/hooks/use-asset', () => {
+ describe('getAssetPath', () => {
+ it('returns undefined if the asset is not known', () => {
+ const { getByAltText } = render(
+ createElement(() => {
+ const { getAssetPath } = useAsset();
+ return
})
;
+ }),
+ );
+
+ const img = getByAltText('unknown');
+
+ expect(img.hasAttribute('src')).to.be.false();
+ });
+
+ it('returns mapped src if known by context', () => {
+ const { getByAltText } = render(
+
+ {createElement(() => {
+ const { getAssetPath } = useAsset();
+ return
;
+ })}
+ ,
+ );
+
+ const img = getByAltText('icon');
+
+ expect(img.getAttribute('src')).to.equal('icon-12345.png');
+ });
+ });
+});