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
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _reduxMockStore = _interopRequireDefault(require("redux-mock-store"));
|
|
4
|
-
|
|
5
|
-
var _reduxThunk = _interopRequireDefault(require("redux-thunk"));
|
|
6
|
-
|
|
7
|
-
var _strategy = require("../reducers/strategy");
|
|
8
|
-
|
|
9
|
-
var _expect = _interopRequireDefault(require("expect"));
|
|
10
|
-
|
|
11
|
-
var _ask_operator = require("../reducers/strategy/strategies/ask_operator");
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
var middlewares = [_reduxThunk.default];
|
|
16
|
-
var mockStore = (0, _reduxMockStore.default)(middlewares);
|
|
17
|
-
describe('async actions', function () {
|
|
18
|
-
it('creates OPERATOR_SELECT_FLOW_IDENTIFY when fetching todos has been done', function () {
|
|
19
|
-
var expectedActions = [{
|
|
20
|
-
type: "OPERATOR_SELECT_FLOW_IDENTIFY",
|
|
21
|
-
payload: {
|
|
22
|
-
result: {
|
|
23
|
-
type: "Loading"
|
|
24
|
-
},
|
|
25
|
-
type: "OPERATOR_SELECT_FLOW_IDENTIFY"
|
|
26
|
-
}
|
|
27
|
-
}, {
|
|
28
|
-
type: "OPERATOR_SELECT_FLOW_IDENTIFY",
|
|
29
|
-
payload: {
|
|
30
|
-
"nextAction": _ask_operator.selectOperator,
|
|
31
|
-
"state": {
|
|
32
|
-
"result": {
|
|
33
|
-
"data": {
|
|
34
|
-
"operators": ["AE_DU", "AE_ETISALAT"]
|
|
35
|
-
},
|
|
36
|
-
"type": "Success"
|
|
37
|
-
},
|
|
38
|
-
"type": "OPERATOR_SELECT_FLOW_IDENTIFY"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}];
|
|
42
|
-
var store = mockStore({
|
|
43
|
-
todos: []
|
|
44
|
-
}); //@ts-ignore
|
|
45
|
-
|
|
46
|
-
return store.dispatch((0, _strategy.identifyStrategy)()).then(function () {
|
|
47
|
-
// return of async actions
|
|
48
|
-
(0, _expect.default)(store.getActions()).toEqual(expectedActions);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -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,36 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import TestRenderer from "react-test-renderer";
|
|
4
|
-
|
|
5
|
-
const Hello = function({ name }: { name: string }) {
|
|
6
|
-
return <h1>Hello {name}!</h1>;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
describe("Hello", () => {
|
|
10
|
-
let renderer: TestRenderer.ReactTestRenderer;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
renderer = TestRenderer.create(<Hello name="Willson" />);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("should have correct prop values", () => {
|
|
17
|
-
const content = renderer.root.find(e => e.type == "h1").children.join("");
|
|
18
|
-
expect(content).eq("Hello Willson!");
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe("tests", () => {
|
|
23
|
-
it("works!", () => {
|
|
24
|
-
expect(true).eq(true);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe("fetch", () => {
|
|
29
|
-
it("fetched ", async () => {
|
|
30
|
-
const result = await fetch("https://httpbin.davecheney.com/headers").then(
|
|
31
|
-
x => x.json()
|
|
32
|
-
);
|
|
33
|
-
console.log(result);
|
|
34
|
-
expect(result).not.eq(null);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import configureMockStore from 'redux-mock-store'
|
|
2
|
-
import thunk from 'redux-thunk'
|
|
3
|
-
|
|
4
|
-
import { identifyStrategy } from "../reducers/strategy";
|
|
5
|
-
import jest from 'jest';
|
|
6
|
-
import expect from 'expect'
|
|
7
|
-
import { selectOperator } from '../reducers/strategy/strategies/ask_operator';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const middlewares = [thunk]
|
|
11
|
-
const mockStore = configureMockStore(middlewares)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
describe('async actions', () => {
|
|
15
|
-
|
|
16
|
-
it('creates OPERATOR_SELECT_FLOW_IDENTIFY when fetching todos has been done', () => {
|
|
17
|
-
const expectedActions = [
|
|
18
|
-
{
|
|
19
|
-
type: "OPERATOR_SELECT_FLOW_IDENTIFY",
|
|
20
|
-
payload:{
|
|
21
|
-
result:{
|
|
22
|
-
type:"Loading"
|
|
23
|
-
},
|
|
24
|
-
type: "OPERATOR_SELECT_FLOW_IDENTIFY"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
type: "OPERATOR_SELECT_FLOW_IDENTIFY",
|
|
29
|
-
payload: {
|
|
30
|
-
"nextAction": selectOperator,
|
|
31
|
-
"state": {
|
|
32
|
-
"result": {
|
|
33
|
-
"data": {
|
|
34
|
-
"operators": [
|
|
35
|
-
"AE_DU",
|
|
36
|
-
"AE_ETISALAT"
|
|
37
|
-
]
|
|
38
|
-
},
|
|
39
|
-
"type": "Success"
|
|
40
|
-
},
|
|
41
|
-
"type": "OPERATOR_SELECT_FLOW_IDENTIFY"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
]
|
|
47
|
-
const store = mockStore({ todos: [] })
|
|
48
|
-
|
|
49
|
-
//@ts-ignore
|
|
50
|
-
return store.dispatch(identifyStrategy()).then(() => {
|
|
51
|
-
// return of async actions
|
|
52
|
-
expect(store.getActions()).toEqual(expectedActions)
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
})
|