From b6e2d721066fe3372f0f5280d125dd6afc499d74 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Wed, 15 Apr 2020 16:15:18 -0700 Subject: [PATCH 1/5] Add jest config to aws-amplify --- packages/aws-amplify/package.json | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/packages/aws-amplify/package.json b/packages/aws-amplify/package.json index 83785e0d5aa..ecf42c315fb 100644 --- a/packages/aws-amplify/package.json +++ b/packages/aws-amplify/package.json @@ -46,5 +46,47 @@ "@aws-amplify/storage": "^3.1.6", "@aws-amplify/ui": "^2.0.2", "@aws-amplify/xr": "^2.1.6" + }, + "jest": { + "globals": { + "ts-jest": { + "diagnostics": false, + "tsConfig": { + "lib": [ + "es5", + "es2015", + "dom", + "esnext.asynciterable", + "es2017.object" + ], + "allowJs": true + } + } + }, + "transform": { + "^.+\\.(js|jsx|ts|tsx)$": "ts-jest" + }, + "preset": "ts-jest", + "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$", + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "json", + "jsx" + ], + "testEnvironment": "jsdom", + "testURL": "http://localhost/", + "coverageThreshold": { + "global": { + "branches": 0, + "functions": 0, + "lines": 0, + "statements": 0 + } + }, + "coveragePathIgnorePatterns": [ + "/node_modules/" + ] } } From 1158231825db1a821212e20e0f91a9ae7784d5d4 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Wed, 15 Apr 2020 16:15:30 -0700 Subject: [PATCH 2/5] Add exports-test.ts --- .../aws-amplify/src/__tests__/exports-test.ts | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 packages/aws-amplify/src/__tests__/exports-test.ts diff --git a/packages/aws-amplify/src/__tests__/exports-test.ts b/packages/aws-amplify/src/__tests__/exports-test.ts new file mode 100644 index 00000000000..3994ade929a --- /dev/null +++ b/packages/aws-amplify/src/__tests__/exports-test.ts @@ -0,0 +1,94 @@ +import * as exported from '..'; + +describe('aws-amplify', () => { + describe('import * as exported', () => { + it('should match snapshot', () => { + expect(Object.keys(exported)).toMatchInlineSnapshot(` + Array [ + "Amplify", + "Analytics", + "AWSPinpointProvider", + "AWSKinesisProvider", + "AWSKinesisFirehoseProvider", + "AmazonPersonalizeProvider", + "Auth", + "Storage", + "StorageClass", + "API", + "APIClass", + "graphqlOperation", + "PubSub", + "Cache", + "Interactions", + "a", + "button", + "signInButton", + "googleSignInButton", + "signInButtonIcon", + "auth0SignInButton", + "facebookSignInButton", + "amazonSignInButton", + "oAuthSignInButton", + "signInButtonContent", + "formContainer", + "formSection", + "formField", + "formRow", + "hint", + "input", + "inputLabel", + "label", + "radio", + "navBar", + "navRight", + "nav", + "navItem", + "photoPickerButton", + "photoPlaceholder", + "photoPlaceholderIcon", + "container", + "actionRow", + "sectionHeader", + "sectionHeaderHint", + "sectionBody", + "sectionHeaderContent", + "sectionFooter", + "sectionFooterPrimaryContent", + "sectionFooterSecondaryContent", + "selectInput", + "strike", + "strikeContent", + "toast", + "toastClose", + "totpQrcode", + "sumerianSceneContainer", + "sumerianScene", + "loadingOverlay", + "loadingContainer", + "loadingLogo", + "loadingSceneName", + "loadingBar", + "loadingBarFill", + "sceneErrorText", + "sceneBar", + "sceneName", + "sceneActions", + "actionButton", + "tooltip", + "actionIcon", + "autoShowTooltip", + "XR", + "Predictions", + "Logger", + "Hub", + "JS", + "ClientDevice", + "Signer", + "I18n", + "ServiceWorker", + "default", + ] + `); + }); + }); +}); From a07e0accac043b186891205f2672607283c56b41 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Wed, 15 Apr 2020 16:16:40 -0700 Subject: [PATCH 3/5] aws-amplify has named export DataStore --- packages/aws-amplify/src/__tests__/exports-test.ts | 1 + packages/aws-amplify/src/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/aws-amplify/src/__tests__/exports-test.ts b/packages/aws-amplify/src/__tests__/exports-test.ts index 3994ade929a..2a4b36f94b6 100644 --- a/packages/aws-amplify/src/__tests__/exports-test.ts +++ b/packages/aws-amplify/src/__tests__/exports-test.ts @@ -17,6 +17,7 @@ describe('aws-amplify', () => { "API", "APIClass", "graphqlOperation", + "DataStore", "PubSub", "Cache", "Interactions", diff --git a/packages/aws-amplify/src/index.ts b/packages/aws-amplify/src/index.ts index 67ee516358a..9f3e8e2addd 100644 --- a/packages/aws-amplify/src/index.ts +++ b/packages/aws-amplify/src/index.ts @@ -33,6 +33,7 @@ export { export { Auth } from '@aws-amplify/auth'; export { Storage, StorageClass } from '@aws-amplify/storage'; export { API, APIClass, graphqlOperation } from '@aws-amplify/api'; +export { DataStore } from '@aws-amplify/datastore'; export { PubSub } from '@aws-amplify/pubsub'; export { default as Cache } from '@aws-amplify/cache'; export { Interactions } from '@aws-amplify/interactions'; From 7dd9dde94e9c10439ab85aa9301f5028186879df Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Wed, 15 Apr 2020 16:43:23 -0700 Subject: [PATCH 4/5] Move __tests__ so build script ignores them --- packages/aws-amplify/{src => }/__tests__/exports-test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename packages/aws-amplify/{src => }/__tests__/exports-test.ts (98%) diff --git a/packages/aws-amplify/src/__tests__/exports-test.ts b/packages/aws-amplify/__tests__/exports-test.ts similarity index 98% rename from packages/aws-amplify/src/__tests__/exports-test.ts rename to packages/aws-amplify/__tests__/exports-test.ts index 2a4b36f94b6..7410e789aae 100644 --- a/packages/aws-amplify/src/__tests__/exports-test.ts +++ b/packages/aws-amplify/__tests__/exports-test.ts @@ -1,4 +1,4 @@ -import * as exported from '..'; +import * as exported from '../src'; describe('aws-amplify', () => { describe('import * as exported', () => { From aaa31f5c5ed6f7b10592860a4b4a5abd93a4aa69 Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Wed, 15 Apr 2020 16:48:24 -0700 Subject: [PATCH 5/5] Add Predicates from DataStore --- packages/aws-amplify/__tests__/exports-test.ts | 3 ++- packages/aws-amplify/src/index.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/aws-amplify/__tests__/exports-test.ts b/packages/aws-amplify/__tests__/exports-test.ts index 7410e789aae..243ac72a3d3 100644 --- a/packages/aws-amplify/__tests__/exports-test.ts +++ b/packages/aws-amplify/__tests__/exports-test.ts @@ -1,7 +1,7 @@ import * as exported from '../src'; describe('aws-amplify', () => { - describe('import * as exported', () => { + describe('import * keys', () => { it('should match snapshot', () => { expect(Object.keys(exported)).toMatchInlineSnapshot(` Array [ @@ -18,6 +18,7 @@ describe('aws-amplify', () => { "APIClass", "graphqlOperation", "DataStore", + "Predicates", "PubSub", "Cache", "Interactions", diff --git a/packages/aws-amplify/src/index.ts b/packages/aws-amplify/src/index.ts index 9f3e8e2addd..4e8f336b8b4 100644 --- a/packages/aws-amplify/src/index.ts +++ b/packages/aws-amplify/src/index.ts @@ -33,7 +33,7 @@ export { export { Auth } from '@aws-amplify/auth'; export { Storage, StorageClass } from '@aws-amplify/storage'; export { API, APIClass, graphqlOperation } from '@aws-amplify/api'; -export { DataStore } from '@aws-amplify/datastore'; +export { DataStore, Predicates } from '@aws-amplify/datastore'; export { PubSub } from '@aws-amplify/pubsub'; export { default as Cache } from '@aws-amplify/cache'; export { Interactions } from '@aws-amplify/interactions';