diff --git a/packages/@aws-cdk/aws-cloudfront/.gitignore b/packages/@aws-cdk/aws-cloudfront/.gitignore index 27e8c6a71e4ff..b97b84d8d9189 100644 --- a/packages/@aws-cdk/aws-cloudfront/.gitignore +++ b/packages/@aws-cdk/aws-cloudfront/.gitignore @@ -13,3 +13,4 @@ nyc.config.js .LAST_PACKAGE *.snk !.eslintrc.js +!jest.config.js diff --git a/packages/@aws-cdk/aws-cloudfront/.npmignore b/packages/@aws-cdk/aws-cloudfront/.npmignore index eb063bd7f38c8..d9a27cdcdce6e 100644 --- a/packages/@aws-cdk/aws-cloudfront/.npmignore +++ b/packages/@aws-cdk/aws-cloudfront/.npmignore @@ -22,4 +22,5 @@ tsconfig.json .eslintrc.js # exclude cdk artifacts -**/cdk.out \ No newline at end of file +**/cdk.out +jest.config.js diff --git a/packages/@aws-cdk/aws-cloudfront/jest.config.js b/packages/@aws-cdk/aws-cloudfront/jest.config.js new file mode 100644 index 0000000000000..f5d5c4c8ad18f --- /dev/null +++ b/packages/@aws-cdk/aws-cloudfront/jest.config.js @@ -0,0 +1,2 @@ +const baseConfig = require('../../../tools/cdk-build-tools/config/jest.config'); +module.exports = baseConfig; \ No newline at end of file diff --git a/packages/@aws-cdk/aws-cloudfront/package.json b/packages/@aws-cdk/aws-cloudfront/package.json index 0ac31be17d436..19b3be311679b 100644 --- a/packages/@aws-cdk/aws-cloudfront/package.json +++ b/packages/@aws-cdk/aws-cloudfront/package.json @@ -47,7 +47,8 @@ "compat": "cdk-compat" }, "cdk-build": { - "cloudformation": "AWS::CloudFront" + "cloudformation": "AWS::CloudFront", + "jest": true }, "keywords": [ "aws", @@ -63,12 +64,11 @@ "license": "Apache-2.0", "devDependencies": { "@aws-cdk/assert": "0.0.0", - "@types/nodeunit": "^0.0.31", "aws-sdk": "^2.711.0", "cdk-build-tools": "0.0.0", "cdk-integ-tools": "0.0.0", "cfn2ts": "0.0.0", - "nodeunit": "^0.11.3", + "nodeunit-shim": "0.0.0", "pkglint": "0.0.0" }, "dependencies": { diff --git a/packages/@aws-cdk/aws-cloudfront/test/test.oai.ts b/packages/@aws-cdk/aws-cloudfront/test/oai.test.ts similarity index 95% rename from packages/@aws-cdk/aws-cloudfront/test/test.oai.ts rename to packages/@aws-cdk/aws-cloudfront/test/oai.test.ts index bd067aa902f03..36616f12471ba 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/test.oai.ts +++ b/packages/@aws-cdk/aws-cloudfront/test/oai.test.ts @@ -1,11 +1,11 @@ import { expect } from '@aws-cdk/assert'; import * as cdk from '@aws-cdk/core'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { OriginAccessIdentity } from '../lib'; // tslint:disable:object-literal-key-quotes -export = { +nodeunitShim({ 'Origin Access Identity with automatic comment'(test: Test) { const stack = new cdk.Stack(); @@ -66,4 +66,4 @@ export = { test.done(); }, -}; +}); diff --git a/packages/@aws-cdk/aws-cloudfront/test/test.basic.ts b/packages/@aws-cdk/aws-cloudfront/test/web_distribution.test.ts similarity index 95% rename from packages/@aws-cdk/aws-cloudfront/test/test.basic.ts rename to packages/@aws-cdk/aws-cloudfront/test/web_distribution.test.ts index 6aeeea31c4cf9..245f85a176d4b 100644 --- a/packages/@aws-cdk/aws-cloudfront/test/test.basic.ts +++ b/packages/@aws-cdk/aws-cloudfront/test/web_distribution.test.ts @@ -3,7 +3,7 @@ import * as certificatemanager from '@aws-cdk/aws-certificatemanager'; import * as lambda from '@aws-cdk/aws-lambda'; import * as s3 from '@aws-cdk/aws-s3'; import * as cdk from '@aws-cdk/core'; -import { Test } from 'nodeunit'; +import { nodeunitShim, Test } from 'nodeunit-shim'; import { CfnDistribution, CloudFrontWebDistribution, @@ -17,7 +17,7 @@ import { // tslint:disable:object-literal-key-quotes -export = { +nodeunitShim({ 'distribution with custom origin adds custom origin'(test: Test) { const stack = new cdk.Stack(); @@ -1046,22 +1046,22 @@ export = { 'throws if locations is empty array'(test: Test) { test.throws(() => { GeoRestriction.whitelist(); - }, 'Should provide at least 1 location'); + }, /Should provide at least 1 location/); test.throws(() => { GeoRestriction.blacklist(); - }, 'Should provide at least 1 location'); + }, /Should provide at least 1 location/); test.done(); }, 'throws if locations format is wrong'(test: Test) { test.throws(() => { GeoRestriction.whitelist('us'); - }, 'Invalid location format for location: us, location should be two-letter and uppercase country ISO 3166-1-alpha-2 code'); + }, /Invalid location format for location: us, location should be two-letter and uppercase country ISO 3166-1-alpha-2 code/); test.throws(() => { GeoRestriction.blacklist('us'); - }, 'Invalid location format for location: us, location should be two-letter and uppercase country ISO 3166-1-alpha-2 code'); + }, /Invalid location format for location: us, location should be two-letter and uppercase country ISO 3166-1-alpha-2 code/); test.done(); }, @@ -1080,7 +1080,7 @@ export = { customOriginSource: { domainName: 'myorigin.com' }, }], }); - }, 'connectionAttempts: You can specify 1, 2, or 3 as the number of attempts.'); + }, /connectionAttempts: You can specify 1, 2, or 3 as the number of attempts./); test.done(); }, '3 = connectionAttempts'(test: Test) { @@ -1093,7 +1093,7 @@ export = { customOriginSource: { domainName: 'myorigin.com' }, }], }); - }, 'connectionAttempts: You can specify 1, 2, or 3 as the number of attempts.'); + }, /connectionAttempts: You can specify 1, 2, or 3 as the number of attempts./); test.done(); }, 'connectionTimeout = 1'(test: Test) { @@ -1106,7 +1106,7 @@ export = { customOriginSource: { domainName: 'myorigin.com' }, }], }); - }, 'connectionTimeout: You can specify a number of seconds between 1 and 10 (inclusive).'); + }, /connectionTimeout: You can specify a number of seconds between 1 and 10 (inclusive)./); test.done(); }, '10 = connectionTimeout'(test: Test) { @@ -1119,7 +1119,7 @@ export = { customOriginSource: { domainName: 'myorigin.com' }, }], }); - }, 'connectionTimeout: You can specify a number of seconds between 1 and 10 (inclusive).'); + }, /connectionTimeout: You can specify a number of seconds between 1 and 10 (inclusive)./); test.done(); }, }, @@ -1134,7 +1134,7 @@ export = { customOriginSource: { domainName: 'myorigin.com' }, }], }); - }, 'connectionAttempts: You can specify 1, 2, or 3 as the number of attempts.'); + }, /connectionAttempts: You can specify 1, 2, or 3 as the number of attempts./); test.done(); }, 'connectionAttempts = -1'(test: Test) { @@ -1147,7 +1147,7 @@ export = { customOriginSource: { domainName: 'myorigin.com' }, }], }); - }, 'connectionAttempts: You can specify 1, 2, or 3 as the number of attempts.'); + }, /connectionAttempts: You can specify 1, 2, or 3 as the number of attempts./); test.done(); }, 'connectionAttempts < 1'(test: Test) { @@ -1160,7 +1160,7 @@ export = { customOriginSource: { domainName: 'myorigin.com' }, }], }); - }, 'connectionAttempts: You can specify 1, 2, or 3 as the number of attempts.'); + }, /connectionAttempts: You can specify 1, 2, or 3 as the number of attempts./); test.done(); }, '3 < connectionAttempts'(test: Test) { @@ -1173,7 +1173,7 @@ export = { customOriginSource: { domainName: 'myorigin.com' }, }], }); - }, 'connectionAttempts: You can specify 1, 2, or 3 as the number of attempts.'); + }, /connectionAttempts: You can specify 1, 2, or 3 as the number of attempts./); test.done(); }, 'connectionTimeout = 1.1'(test: Test) { @@ -1186,20 +1186,7 @@ export = { customOriginSource: { domainName: 'myorigin.com' }, }], }); - }, 'connectionTimeout: You can specify a number of seconds between 1 and 10 (inclusive).'); - test.done(); - }, - 'connectionTimeout = -1'(test: Test) { - const stack = new cdk.Stack(); - test.throws(() => { - new CloudFrontWebDistribution(stack, 'Distribution', { - originConfigs: [{ - behaviors: [{ isDefaultBehavior: true }], - connectionTimeout: cdk.Duration.seconds(-1), - customOriginSource: { domainName: 'myorigin.com' }, - }], - }); - }, 'connectionTimeout: You can specify a number of seconds between 1 and 10 (inclusive).'); + }, /connectionTimeout: You can specify a number of seconds between 1 and 10 \(inclusive\)./); test.done(); }, 'connectionTimeout < 1'(test: Test) { @@ -1212,7 +1199,7 @@ export = { customOriginSource: { domainName: 'myorigin.com' }, }], }); - }, 'connectionTimeout: You can specify a number of seconds between 1 and 10 (inclusive).'); + }, /connectionTimeout: You can specify a number of seconds between 1 and 10 \(inclusive\)./); test.done(); }, '10 < connectionTimeout'(test: Test) { @@ -1225,9 +1212,9 @@ export = { customOriginSource: { domainName: 'myorigin.com' }, }], }); - }, 'connectionTimeout: You can specify a number of seconds between 1 and 10 (inclusive).'); + }, /connectionTimeout: You can specify a number of seconds between 1 and 10 \(inclusive\)./); test.done(); }, }, }, -}; +});