ouisys-engine 2.1.13 → 2.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jest.config.js +194 -0
- package/dist/reducers/pinFlow/index.js +86 -70
- package/dist/reducers/pinFlow/utils.js +18 -13
- package/dist/{__tests__/index.test.d.ts → reducers/strategy/__tests__/strategy.spec.d.ts} +0 -0
- package/dist/reducers/strategy/__tests__/strategy.spec.js +33 -0
- package/dist/reducers/strategy/index.js +161 -150
- package/dist/reducers/strategy/utils.js +6 -5
- package/dist/store/index.d.ts +2 -2
- package/dist/test/renderWithRouterAndUserMock.d.ts +21 -0
- package/dist/test/renderWithRouterAndUserMock.js +40 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/setup.js +24 -0
- package/mockData/config.json +28 -0
- package/package.json +32 -9
- package/prettier.config.js +7 -0
- package/setupJest.js +6 -0
- package/src/@types/window.d.ts +1 -0
- package/src/jest.config.js +194 -0
- package/src/reducers/pinFlow/index.ts +21 -3
- package/src/reducers/pinFlow/utils.ts +11 -1
- package/src/reducers/strategy/index.ts +2 -2
- package/src/reducers/strategy/utils.ts +2 -2
- package/src/store/index.ts +1 -1
- package/dist/__tests__/domMocker.js +0 -31
- package/dist/__tests__/index.test.js +0 -95
- package/dist/__tests__/strategy.test.d.ts +0 -1
- package/dist/__tests__/strategy.test.js +0 -51
- package/src/__tests__/domMocker.js +0 -31
- package/src/__tests__/index.test.tsx +0 -36
- package/src/__tests__/strategy.test.ts +0 -55
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ouisys-engine",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"directories": "dist dev-tools",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "
|
|
8
|
+
"test": "testing=true jest",
|
|
9
9
|
"build": "NODE_ENV=production npx babel ./src --out-dir dist --extensions \".ts,.tsx\" --copy-files && yarn build:types",
|
|
10
10
|
"build:types": "tsc --emitDeclarationOnly",
|
|
11
11
|
"build:init": "tsc --init --declaration --allowSyntheticDefaultImports --target esnext --outDir dist",
|
|
12
12
|
"release": "ts-node ./src/dev-tools/publish-package",
|
|
13
|
-
"manage:configs": "ts-node ./src/test-tools/configure-page-strategy.ts"
|
|
13
|
+
"manage:configs": "ts-node ./src/test-tools/configure-page-strategy.ts",
|
|
14
|
+
"format": "prettier --write ."
|
|
14
15
|
},
|
|
15
16
|
"author": "",
|
|
16
17
|
"license": "ISC",
|
|
@@ -18,11 +19,12 @@
|
|
|
18
19
|
"awesome-phonenumber": "^2.53.0",
|
|
19
20
|
"pacman-client": "^1.5.4",
|
|
20
21
|
"react-addons-update": "^15.6.2",
|
|
21
|
-
"redux": "^4.
|
|
22
|
+
"redux": "^4.1.1",
|
|
22
23
|
"redux-logger": "^3.0.6",
|
|
23
24
|
"redux-thunk": "^2.3.0",
|
|
24
25
|
"rxjs": "^6.3.3",
|
|
25
26
|
"rxjs-compat": "^6.3.3",
|
|
27
|
+
"typescript": "^4.4.3",
|
|
26
28
|
"uuid": "^3.3.2"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
@@ -39,7 +41,7 @@
|
|
|
39
41
|
"@types/fs-extra": "^7.0.0",
|
|
40
42
|
"@types/inquirer": "^6.5.0",
|
|
41
43
|
"@types/mocha": "^5.2.5",
|
|
42
|
-
"@types/node": "^
|
|
44
|
+
"@types/node": "^16.9.4",
|
|
43
45
|
"@types/node-fetch": "^2.5.7",
|
|
44
46
|
"@types/ramda": "^0.25.42",
|
|
45
47
|
"@types/react": "^16.8.6",
|
|
@@ -52,15 +54,26 @@
|
|
|
52
54
|
"@types/uuid": "^8.0.0",
|
|
53
55
|
"chai": "^4.2.0",
|
|
54
56
|
"core-js": "3.6.5",
|
|
55
|
-
"
|
|
57
|
+
"eslint": "^7.16.0",
|
|
58
|
+
"eslint-config-airbnb": "^18.2.1",
|
|
59
|
+
"eslint-config-prettier": "^7.1.0",
|
|
60
|
+
"eslint-plugin-import": "^2.22.1",
|
|
61
|
+
"eslint-plugin-jest": "^24.1.3",
|
|
62
|
+
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
63
|
+
"eslint-plugin-prettier": "^3.3.0",
|
|
64
|
+
"eslint-plugin-react": "^7.21.5",
|
|
65
|
+
"eslint-plugin-react-hooks": "^4.2.0",
|
|
66
|
+
"eslint-plugin-testing-library": "^3.10.1",
|
|
67
|
+
"eslint-webpack-plugin": "^2.5.2",
|
|
56
68
|
"jsdom": "^13.2.0",
|
|
57
69
|
"jsdom-global": "^3.0.2",
|
|
58
|
-
"
|
|
70
|
+
"msw": "^0.35.0",
|
|
71
|
+
"prettier": "^2.4.1",
|
|
72
|
+
"prettier-plugin-organize-imports": "^2.3.3",
|
|
59
73
|
"react-test-renderer": "^16.7.0",
|
|
60
74
|
"redux-cli-logger": "^2.1.0",
|
|
61
75
|
"redux-mock-store": "^1.5.4",
|
|
62
76
|
"ts-node": "^8.0.2",
|
|
63
|
-
"typescript": "^3.2.2",
|
|
64
77
|
"yarn": "^1.17.3"
|
|
65
78
|
},
|
|
66
79
|
"resolutions": {
|
|
@@ -69,5 +82,15 @@
|
|
|
69
82
|
"react": "16.8.3",
|
|
70
83
|
"react-dom": "16.8.3"
|
|
71
84
|
},
|
|
72
|
-
"proxy": "http://localhost:3030/"
|
|
85
|
+
"proxy": "http://localhost:3030/",
|
|
86
|
+
"lint-staged": {
|
|
87
|
+
"*": "prettier --ignore-unknown --write",
|
|
88
|
+
"src/**/*.{ts,tsx}": "eslint --fix"
|
|
89
|
+
},
|
|
90
|
+
"prettier": "./prettier-config",
|
|
91
|
+
"jest": {
|
|
92
|
+
"testPathIgnorePatterns": [
|
|
93
|
+
"dist"
|
|
94
|
+
]
|
|
95
|
+
}
|
|
73
96
|
}
|
package/setupJest.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// adds the 'fetchMock' global variable and rewires 'fetch' global to call 'fetchMock' instead of the real implementation
|
|
2
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
|
+
|
|
4
|
+
require('jest-fetch-mock').enableMocks();
|
|
5
|
+
// changes default behavior of fetchMock to use the real 'fetch' implementation and not mock responses
|
|
6
|
+
fetchMock.dontMock()
|
package/src/@types/window.d.ts
CHANGED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// For a detailed explanation regarding each configuration property, visit:
|
|
2
|
+
// https://jestjs.io/docs/en/configuration.html
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
// All imported modules in your tests should be mocked automatically
|
|
6
|
+
// automock: false,
|
|
7
|
+
|
|
8
|
+
// Stop running tests after `n` failures
|
|
9
|
+
// bail: 0,
|
|
10
|
+
|
|
11
|
+
// The directory where Jest should store its cached dependency information
|
|
12
|
+
// cacheDirectory: "/private/var/folders/wr/8ghl3gfx0cldjmd7jhzs8gt80000gn/T/jest_dx",
|
|
13
|
+
|
|
14
|
+
// Automatically clear mock calls and instances between every test
|
|
15
|
+
clearMocks: true
|
|
16
|
+
|
|
17
|
+
// Indicates whether the coverage information should be collected while executing the test
|
|
18
|
+
// collectCoverage: false,
|
|
19
|
+
|
|
20
|
+
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
|
21
|
+
// collectCoverageFrom: undefined,
|
|
22
|
+
|
|
23
|
+
// The directory where Jest should output its coverage files
|
|
24
|
+
coverageDirectory: 'coverage',
|
|
25
|
+
|
|
26
|
+
// An array of regexp pattern strings used to skip coverage collection
|
|
27
|
+
// coveragePathIgnorePatterns: [
|
|
28
|
+
// "/node_modules/"
|
|
29
|
+
// ],
|
|
30
|
+
|
|
31
|
+
// Indicates which provider should be used to instrument code for coverage
|
|
32
|
+
// coverageProvider: 'babel',
|
|
33
|
+
|
|
34
|
+
// A list of reporter names that Jest uses when writing coverage reports
|
|
35
|
+
// coverageReporters: [
|
|
36
|
+
// "json",
|
|
37
|
+
// "text",
|
|
38
|
+
// "lcov",
|
|
39
|
+
// "clover"
|
|
40
|
+
// ],
|
|
41
|
+
|
|
42
|
+
// An object that configures minimum threshold enforcement for coverage results
|
|
43
|
+
// coverageThreshold: undefined,
|
|
44
|
+
|
|
45
|
+
// A path to a custom dependency extractor
|
|
46
|
+
// dependencyExtractor: undefined,
|
|
47
|
+
|
|
48
|
+
// Make calling deprecated APIs throw helpful error messages
|
|
49
|
+
// errorOnDeprecated: false,
|
|
50
|
+
|
|
51
|
+
// Force coverage collection from ignored files using an array of glob patterns
|
|
52
|
+
// forceCoverageMatch: [],
|
|
53
|
+
|
|
54
|
+
collectCoverageFrom: [
|
|
55
|
+
'src/**/*.{js,ts,tsx}',
|
|
56
|
+
'!src/serviceWorker.{ts,js}',
|
|
57
|
+
'!src/storybook/**',
|
|
58
|
+
'!src/mockServer/**'
|
|
59
|
+
],
|
|
60
|
+
|
|
61
|
+
// A path to a module which exports an async function that is triggered once before all test suites
|
|
62
|
+
// globalSetup: undefined,
|
|
63
|
+
|
|
64
|
+
// A path to a module which exports an async function that is triggered once after all test suites
|
|
65
|
+
// globalTeardown: undefined,
|
|
66
|
+
|
|
67
|
+
// A set of global variables that need to be available in all test environments
|
|
68
|
+
// globals: {},
|
|
69
|
+
|
|
70
|
+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
|
71
|
+
// maxWorkers: "50%",
|
|
72
|
+
|
|
73
|
+
// An array of directory names to be searched recursively up from the requiring module's location
|
|
74
|
+
moduleDirectories: ['node_modules', 'test', __dirname],
|
|
75
|
+
|
|
76
|
+
// An array of file extensions your modules use
|
|
77
|
+
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'svg', 'node'],
|
|
78
|
+
|
|
79
|
+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
|
80
|
+
moduleNameMapper: {
|
|
81
|
+
'.+\\.(css|scss|png)$': 'identity-obj-proxy'
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
85
|
+
// modulePathIgnorePatterns: [],
|
|
86
|
+
|
|
87
|
+
// Activates notifications for test results
|
|
88
|
+
// notify: false,
|
|
89
|
+
|
|
90
|
+
// An enum that specifies notification mode. Requires { notify: true }
|
|
91
|
+
// notifyMode: "failure-change",
|
|
92
|
+
|
|
93
|
+
// A preset that is used as a base for Jest's configuration
|
|
94
|
+
// preset: undefined,
|
|
95
|
+
|
|
96
|
+
// Run tests from one or more projects
|
|
97
|
+
// projects: undefined,
|
|
98
|
+
|
|
99
|
+
// Use this configuration option to add custom reporters to Jest
|
|
100
|
+
// reporters: undefined,
|
|
101
|
+
|
|
102
|
+
// Automatically reset mock state between every test
|
|
103
|
+
resetMocks: true,
|
|
104
|
+
|
|
105
|
+
// Reset the module registry before running each individual test
|
|
106
|
+
// resetModules: false,
|
|
107
|
+
|
|
108
|
+
// A path to a custom resolver
|
|
109
|
+
// resolver: undefined,
|
|
110
|
+
|
|
111
|
+
// Automatically restore mock state between every test
|
|
112
|
+
// restoreMocks: false,
|
|
113
|
+
|
|
114
|
+
// The root directory that Jest should scan for tests and modules within
|
|
115
|
+
// rootDir: undefined,
|
|
116
|
+
|
|
117
|
+
// A list of paths to directories that Jest should use to search for files in
|
|
118
|
+
roots: ['<rootDir>/src'],
|
|
119
|
+
|
|
120
|
+
// Allows you to use a custom runner instead of Jest's default test runner
|
|
121
|
+
// runner: "jest-runner",
|
|
122
|
+
|
|
123
|
+
// The paths to modules that run some code to configure or set up the testing environment before each test
|
|
124
|
+
// setupFiles: ['<rootDir>/src/test/setup.ts', 'jest-localstorage-mock'],
|
|
125
|
+
|
|
126
|
+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
|
127
|
+
// setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
|
|
128
|
+
|
|
129
|
+
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
|
130
|
+
// slowTestThreshold: 5,
|
|
131
|
+
|
|
132
|
+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
|
133
|
+
// snapshotSerializers: [],
|
|
134
|
+
|
|
135
|
+
// The test environment that will be used for testing
|
|
136
|
+
testEnvironment: 'jest-environment-jsdom',
|
|
137
|
+
|
|
138
|
+
// Options that will be passed to the testEnvironment
|
|
139
|
+
// testEnvironmentOptions: {},
|
|
140
|
+
|
|
141
|
+
// Adds a location field to test results
|
|
142
|
+
// testLocationInResults: false,
|
|
143
|
+
|
|
144
|
+
// The glob patterns Jest uses to detect test files
|
|
145
|
+
// testMatch: [
|
|
146
|
+
// "**/__tests__/**/*.[jt]s?(x)",
|
|
147
|
+
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
|
148
|
+
// ],
|
|
149
|
+
|
|
150
|
+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
151
|
+
// testPathIgnorePatterns: [
|
|
152
|
+
// "/node_modules/"
|
|
153
|
+
// ],
|
|
154
|
+
|
|
155
|
+
// The regexp pattern or array of patterns that Jest uses to detect test files
|
|
156
|
+
testRegex: '(\\.|/)(test|spec)\\.tsx?$',
|
|
157
|
+
|
|
158
|
+
// This option allows the use of a custom results processor
|
|
159
|
+
// testResultsProcessor: undefined,
|
|
160
|
+
|
|
161
|
+
// This option allows use of a custom test runner
|
|
162
|
+
// testRunner: "jasmine2",
|
|
163
|
+
|
|
164
|
+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
|
|
165
|
+
// testURL: "http://localhost",
|
|
166
|
+
|
|
167
|
+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
|
|
168
|
+
// timers: "real",
|
|
169
|
+
|
|
170
|
+
// A map from regular expressions to paths to transformers
|
|
171
|
+
transform: {
|
|
172
|
+
'^.+\\.tsx?$': 'ts-jest',
|
|
173
|
+
'^.+\\.jsx?$': 'ts-jest'
|
|
174
|
+
// '^.+\\.svg$': '<rootDir>/src/test/svgTransformer.js'
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
178
|
+
// transformIgnorePatterns: [
|
|
179
|
+
// "/node_modules/",
|
|
180
|
+
// "\\.pnp\\.[^\\/]+$"
|
|
181
|
+
// ],
|
|
182
|
+
|
|
183
|
+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
|
184
|
+
// unmockedModulePathPatterns: undefined,
|
|
185
|
+
|
|
186
|
+
// Indicates whether each individual test should be reported during the run
|
|
187
|
+
// verbose: undefined,
|
|
188
|
+
|
|
189
|
+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
|
190
|
+
// watchPathIgnorePatterns: [],
|
|
191
|
+
|
|
192
|
+
// Whether to use watchman for file crawling
|
|
193
|
+
// watchman: true,
|
|
194
|
+
};
|
|
@@ -10,7 +10,8 @@ import { genericHandler, tracker } from "../strategy";
|
|
|
10
10
|
//ACTION CREATORS
|
|
11
11
|
export function submitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk{
|
|
12
12
|
return async (dispatch, store)=>{
|
|
13
|
-
const {currentState} = store().strategy
|
|
13
|
+
const {currentState} = store().strategy;
|
|
14
|
+
const pinFlowCurrentState = store().pinFlow.currentState;
|
|
14
15
|
if(currentState.type === "PIN"){
|
|
15
16
|
const config = currentState.result.config;
|
|
16
17
|
const pinMaxLengthByOp:{[key:string]:number} = {
|
|
@@ -22,6 +23,7 @@ export function submitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk{
|
|
|
22
23
|
dispatch({
|
|
23
24
|
type: "PIN_FLOW_MSISDN_SUBMIT",
|
|
24
25
|
payload:{
|
|
26
|
+
...pinFlowCurrentState,
|
|
25
27
|
type: "MSISDNEntry",
|
|
26
28
|
result: RDS.Loading()
|
|
27
29
|
}
|
|
@@ -39,6 +41,7 @@ export function submitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk{
|
|
|
39
41
|
dispatch({
|
|
40
42
|
type: "PIN_FLOW_MSISDN_SUBMIT",
|
|
41
43
|
payload:{
|
|
44
|
+
...pinFlowCurrentState,
|
|
42
45
|
type: "MSISDNEntry",
|
|
43
46
|
result: RDS.Success({})
|
|
44
47
|
}
|
|
@@ -47,6 +50,7 @@ export function submitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk{
|
|
|
47
50
|
dispatch({
|
|
48
51
|
type: "PIN_FLOW_MSISDN_SUBMIT",
|
|
49
52
|
payload:{
|
|
53
|
+
...pinFlowCurrentState,
|
|
50
54
|
type: "PINEntry",
|
|
51
55
|
result: RDS.NothingYet(),
|
|
52
56
|
data:{
|
|
@@ -70,6 +74,7 @@ export function submitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk{
|
|
|
70
74
|
dispatch({
|
|
71
75
|
type: "PIN_FLOW_MSISDN_SUBMIT_ERROR",
|
|
72
76
|
payload:{
|
|
77
|
+
...pinFlowCurrentState,
|
|
73
78
|
type:"MSISDNEntry",
|
|
74
79
|
result: RDS.Failure<MSISDNEntryFailure, MSISDNEntrySuccess>({
|
|
75
80
|
errorType: errorType,
|
|
@@ -83,6 +88,7 @@ export function submitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk{
|
|
|
83
88
|
dispatch({
|
|
84
89
|
type: "PIN_FLOW_MSISDN_SUBMIT_ERROR",
|
|
85
90
|
payload:{
|
|
91
|
+
...pinFlowCurrentState,
|
|
86
92
|
type:"MSISDNEntry",
|
|
87
93
|
result: RDS.Failure<MSISDNEntryFailure, MSISDNEntrySuccess>({
|
|
88
94
|
errorType: "UnknownError",
|
|
@@ -98,7 +104,8 @@ export function submitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk{
|
|
|
98
104
|
|
|
99
105
|
export function reSubmitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk{
|
|
100
106
|
return async (dispatch, store)=>{
|
|
101
|
-
const {currentState} = store().strategy
|
|
107
|
+
const {currentState} = store().strategy;
|
|
108
|
+
const pinFlowCurrentState = store().pinFlow.currentState;
|
|
102
109
|
if(currentState.type === "PIN"){
|
|
103
110
|
const config = currentState.result.config;
|
|
104
111
|
try {
|
|
@@ -121,6 +128,7 @@ export function reSubmitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk
|
|
|
121
128
|
dispatch({
|
|
122
129
|
type: "PIN_FLOW_MSISDN_SUBMIT",
|
|
123
130
|
payload:{
|
|
131
|
+
...pinFlowCurrentState,
|
|
124
132
|
type: "MSISDNEntry",
|
|
125
133
|
result: RDS.Success({})
|
|
126
134
|
}
|
|
@@ -129,6 +137,7 @@ export function reSubmitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk
|
|
|
129
137
|
dispatch({
|
|
130
138
|
type: "PIN_FLOW_MSISDN_SUBMIT",
|
|
131
139
|
payload:{
|
|
140
|
+
...pinFlowCurrentState,
|
|
132
141
|
type: "PINEntry",
|
|
133
142
|
result: RDS.NothingYet(),
|
|
134
143
|
data:{
|
|
@@ -150,6 +159,7 @@ export function reSubmitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk
|
|
|
150
159
|
dispatch({
|
|
151
160
|
type: "PIN_FLOW_MSISDN_SUBMIT_ERROR",
|
|
152
161
|
payload:{
|
|
162
|
+
...pinFlowCurrentState,
|
|
153
163
|
type:"MSISDNEntry",
|
|
154
164
|
result: RDS.Failure<MSISDNEntryFailure, MSISDNEntrySuccess>({
|
|
155
165
|
errorType: errorType,
|
|
@@ -163,6 +173,7 @@ export function reSubmitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk
|
|
|
163
173
|
dispatch({
|
|
164
174
|
type: "PIN_FLOW_MSISDN_SUBMIT_ERROR",
|
|
165
175
|
payload:{
|
|
176
|
+
...pinFlowCurrentState,
|
|
166
177
|
type:"MSISDNEntry",
|
|
167
178
|
result: RDS.Failure<MSISDNEntryFailure, MSISDNEntrySuccess>({
|
|
168
179
|
errorType: "UnknownError",
|
|
@@ -177,16 +188,20 @@ export function reSubmitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk
|
|
|
177
188
|
}
|
|
178
189
|
export function submitPinAction(msisdn:string, pin:string, extraParams?:{[key: string]: string}):AppThunk{
|
|
179
190
|
return async (dispatch, store)=>{
|
|
191
|
+
const {currentState} = store().strategy
|
|
192
|
+
|
|
193
|
+
const pinFlowCurrentState = store().pinFlow.currentState;
|
|
180
194
|
try {
|
|
181
195
|
dispatch({
|
|
182
196
|
type: "PIN_SUBMIT",
|
|
183
197
|
payload:{
|
|
198
|
+
...pinFlowCurrentState,
|
|
184
199
|
type: "PINEntry",
|
|
185
200
|
result: RDS.Loading()
|
|
186
201
|
}
|
|
187
202
|
});
|
|
188
203
|
tracker.advancedInFlow('tallyman.v1-pin', 'pin-submitted',{msisdn, pin})
|
|
189
|
-
|
|
204
|
+
|
|
190
205
|
if(currentState.type === "PIN"){
|
|
191
206
|
const config = currentState.result.config;
|
|
192
207
|
const result = await submitPIN(window, pin, config, extraParams)
|
|
@@ -195,6 +210,7 @@ export function submitPinAction(msisdn:string, pin:string, extraParams?:{[key: s
|
|
|
195
210
|
dispatch({
|
|
196
211
|
type: "PIN_SUBMIT",
|
|
197
212
|
payload:{
|
|
213
|
+
...pinFlowCurrentState,
|
|
198
214
|
type:"PINEntry",
|
|
199
215
|
result: RDS.Success<PINEntryFailure, PINEntrySuccess>({
|
|
200
216
|
finalUrl: result.productUrl,
|
|
@@ -208,6 +224,7 @@ export function submitPinAction(msisdn:string, pin:string, extraParams?:{[key: s
|
|
|
208
224
|
dispatch({
|
|
209
225
|
type: "PIN_SUBMIT_ERROR",
|
|
210
226
|
payload:{
|
|
227
|
+
...pinFlowCurrentState,
|
|
211
228
|
type:"PINEntry",
|
|
212
229
|
result: RDS.Failure<PINEntryFailure, PINEntrySuccess>({errorType: "UnexpectedState"})
|
|
213
230
|
}
|
|
@@ -226,6 +243,7 @@ export function submitPinAction(msisdn:string, pin:string, extraParams?:{[key: s
|
|
|
226
243
|
dispatch({
|
|
227
244
|
type: "PIN_SUBMIT_ERROR",
|
|
228
245
|
payload:{
|
|
246
|
+
...pinFlowCurrentState,
|
|
229
247
|
type:"PINEntry",
|
|
230
248
|
result: RDS.Failure<PINEntryFailure, PINEntrySuccess>({errorType: errorType})
|
|
231
249
|
}
|
|
@@ -69,7 +69,17 @@ async function submitMSISDNOnce(window: Window, config: IConfig, internationalMS
|
|
|
69
69
|
throw error
|
|
70
70
|
} else {
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
const kwCodesWithMcpShied:{[key:string]:string} = {
|
|
73
|
+
kw:"kw",
|
|
74
|
+
k2:"k2"
|
|
75
|
+
}
|
|
76
|
+
if(country && (
|
|
77
|
+
(
|
|
78
|
+
|
|
79
|
+
kwCodesWithMcpShied[country.toLowerCase()] && result.operator == "KW_VIVA") ||
|
|
80
|
+
country.toLowerCase() == "iq"
|
|
81
|
+
)
|
|
82
|
+
){
|
|
73
83
|
try{
|
|
74
84
|
|
|
75
85
|
const mcpShieldResult: IMcpShieldResult = await window.tallymanApi.mcpShield(host, country, slug, device, offer, rockmanId,result.operator, uniqid)
|
|
@@ -97,8 +97,8 @@ export function mockStrategyStateByUrlParam():AppThunk {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
|
|
100
|
-
export function
|
|
101
|
-
return (dispatch)=>{
|
|
100
|
+
export function identifyStrategy():AppThunk {
|
|
101
|
+
return async (dispatch)=>{
|
|
102
102
|
const { strategy, strategyConfigs } = getConfig();
|
|
103
103
|
const search = searchToObject() as IMockFlowParams<IMockPinFlowStates>;
|
|
104
104
|
|
|
@@ -39,9 +39,9 @@ export const getConfig = ():IStrategy=>{
|
|
|
39
39
|
|
|
40
40
|
if(process.env.testing == "true"){
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
const configs:IStrategy = require("../../../mockData/config.json");
|
|
43
43
|
//@ts-ignore
|
|
44
|
-
return
|
|
44
|
+
return configs;
|
|
45
45
|
}else{
|
|
46
46
|
const configs:IStrategy = require("../../../../../config.json");
|
|
47
47
|
return configs;
|
package/src/store/index.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { IClick2SmsActions } from "../reducers/click2smsFlow/Click2smsTypes";
|
|
|
16
16
|
import { ITpayHeActions } from "../reducers/tpayHeFlow/TpayHeTypes";
|
|
17
17
|
import { getConfig, getOperators } from "../reducers/strategy/utils";
|
|
18
18
|
|
|
19
|
-
type IApplicationActions = IStrategyActions | IPinActions | IMoActions | IMoRedirActions | IOneClickActions | IClick2SmsActions | IUssdActions | ITpayHeActions;
|
|
19
|
+
export type IApplicationActions = IStrategyActions | IPinActions | IMoActions | IMoRedirActions | IOneClickActions | IClick2SmsActions | IUssdActions | ITpayHeActions;
|
|
20
20
|
|
|
21
21
|
const log = createLogger({ diff: true, collapsed: true });
|
|
22
22
|
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
A helper script to mock a browser DOM with jsdom to enable testing.
|
|
3
|
-
This helper is intended to be required by mocha using the --require option so that the DOM can mocked before running the tests.
|
|
4
|
-
Reference: https://github.com/zinserjan/mocha-webpack/blob/master/docs/guides/jsdom.md
|
|
5
|
-
*/
|
|
6
|
-
const jsdom = require("jsdom");
|
|
7
|
-
const { JSDOM } = jsdom;
|
|
8
|
-
const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`, { url: "https://example.org/" });
|
|
9
|
-
global.document = dom.window.document;
|
|
10
|
-
global.window = {...dom.window,
|
|
11
|
-
dataLayer: {push: (...args) => {}},
|
|
12
|
-
pac_analytics: {
|
|
13
|
-
visitor: {
|
|
14
|
-
offer: 1
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
location: {
|
|
18
|
-
search: ''
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
window.console = global.console;
|
|
22
|
-
|
|
23
|
-
Object.keys(document.defaultView).forEach(property => {
|
|
24
|
-
if (typeof global[property] === "undefined") {
|
|
25
|
-
global[property] = document.defaultView[property];
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
global.navigator = {
|
|
30
|
-
userAgent: "node.js"
|
|
31
|
-
};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.symbol");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.description");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.symbol.iterator");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.array.find");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.array.iterator");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.array.join");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.function.name");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.object.get-own-property-descriptor");
|
|
20
|
-
|
|
21
|
-
require("core-js/modules/es.object.to-string");
|
|
22
|
-
|
|
23
|
-
require("core-js/modules/es.promise");
|
|
24
|
-
|
|
25
|
-
require("core-js/modules/es.string.iterator");
|
|
26
|
-
|
|
27
|
-
require("core-js/modules/es.weak-map");
|
|
28
|
-
|
|
29
|
-
require("core-js/modules/web.dom-collections.iterator");
|
|
30
|
-
|
|
31
|
-
require("regenerator-runtime/runtime");
|
|
32
|
-
|
|
33
|
-
var _chai = require("chai");
|
|
34
|
-
|
|
35
|
-
var React = _interopRequireWildcard(require("react"));
|
|
36
|
-
|
|
37
|
-
var _reactTestRenderer = _interopRequireDefault(require("react-test-renderer"));
|
|
38
|
-
|
|
39
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
|
-
|
|
41
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
42
|
-
|
|
43
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
44
|
-
|
|
45
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
46
|
-
|
|
47
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
48
|
-
|
|
49
|
-
var Hello = function Hello(_ref) {
|
|
50
|
-
var name = _ref.name;
|
|
51
|
-
return <h1>Hello {name}!</h1>;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
describe("Hello", function () {
|
|
55
|
-
var renderer;
|
|
56
|
-
beforeEach(function () {
|
|
57
|
-
renderer = _reactTestRenderer.default.create(<Hello name="Willson" />);
|
|
58
|
-
});
|
|
59
|
-
it("should have correct prop values", function () {
|
|
60
|
-
var content = renderer.root.find(function (e) {
|
|
61
|
-
return e.type == "h1";
|
|
62
|
-
}).children.join("");
|
|
63
|
-
(0, _chai.expect)(content).eq("Hello Willson!");
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
describe("tests", function () {
|
|
67
|
-
it("works!", function () {
|
|
68
|
-
(0, _chai.expect)(true).eq(true);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe("fetch", function () {
|
|
72
|
-
it("fetched ", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
73
|
-
var result;
|
|
74
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
75
|
-
while (1) {
|
|
76
|
-
switch (_context.prev = _context.next) {
|
|
77
|
-
case 0:
|
|
78
|
-
_context.next = 2;
|
|
79
|
-
return fetch("https://httpbin.davecheney.com/headers").then(function (x) {
|
|
80
|
-
return x.json();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
case 2:
|
|
84
|
-
result = _context.sent;
|
|
85
|
-
console.log(result);
|
|
86
|
-
(0, _chai.expect)(result).not.eq(null);
|
|
87
|
-
|
|
88
|
-
case 5:
|
|
89
|
-
case "end":
|
|
90
|
-
return _context.stop();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}, _callee);
|
|
94
|
-
})));
|
|
95
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|