Skip to content

Commit 3317f8b

Browse files
Add unit test
1 parent 1a58867 commit 3317f8b

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

packages/@aws-cdk/core/test/test.assets.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,29 @@ export = {
4646
});
4747

4848
test.done();
49+
},
50+
51+
'addFileAsset correctly sets object urls'(test: Test) {
52+
// GIVEN
53+
const stack = new Stack();
54+
55+
// WHEN
56+
const assetLocation = stack.addFileAsset({
57+
fileName: 'file-name',
58+
packaging: FileAssetPackaging.ZIP_DIRECTORY,
59+
sourceHash: 'source-hash',
60+
});
4961

62+
// THEN
63+
const expectedS3UrlPrefix = 's3://';
64+
const expectedHttpUrlPrefix = `https://s3.${stack.region}.${stack.urlSuffix}/`;
65+
66+
test.equal(
67+
assetLocation.s3ObjectUrl.replace(expectedS3UrlPrefix, ''),
68+
assetLocation.httpUrl.replace(expectedHttpUrlPrefix, ''),
69+
);
70+
71+
test.done();
5072
},
5173

5274
'addDockerImageAsset correctly sets metadata'(test: Test) {

0 commit comments

Comments
 (0)