From ae2903c002a39d94dace738aafcca6e4d4d165d7 Mon Sep 17 00:00:00 2001 From: ShMcK Date: Tue, 27 Sep 2016 13:14:06 -0700 Subject: [PATCH 01/18] use mocks for unit tests --- lib/__mocks__/editor.js | 5 ++++ lib/__mocks__/editor.js.map | 1 + lib/modules/dir/index.js | 1 + lib/modules/dir/index.js.map | 2 +- package.json | 3 ++- src/__mocks__/editor/index.js | 6 +++++ src/__mocks__/editor/index.js.map | 1 + src/__mocks__/editor/index.ts | 7 ++++++ src/__mocks__/tsconfig.json | 24 +++++++++++++++++++ src/components/Start/Start.test.tsx | 37 ++++++++++++++++------------- src/modules/dir/reducer.test.ts | 23 +++++++----------- src/modules/editor/reducer.test.ts | 4 +++- src/typings/index.d.ts | 3 ++- tsconfig.json | 2 ++ 14 files changed, 83 insertions(+), 36 deletions(-) create mode 100644 lib/__mocks__/editor.js create mode 100644 lib/__mocks__/editor.js.map create mode 100644 src/__mocks__/editor/index.js create mode 100644 src/__mocks__/editor/index.js.map create mode 100644 src/__mocks__/editor/index.ts create mode 100644 src/__mocks__/tsconfig.json diff --git a/lib/__mocks__/editor.js b/lib/__mocks__/editor.js new file mode 100644 index 0000000..2a2c501 --- /dev/null +++ b/lib/__mocks__/editor.js @@ -0,0 +1,5 @@ +"use strict"; +exports.editor = { + directory: function () { return 'something'; } +}; +//# sourceMappingURL=editor.js.map \ No newline at end of file diff --git a/lib/__mocks__/editor.js.map b/lib/__mocks__/editor.js.map new file mode 100644 index 0000000..9a4ae59 --- /dev/null +++ b/lib/__mocks__/editor.js.map @@ -0,0 +1 @@ +{"version":3,"file":"editor.js","sourceRoot":"","sources":["../../src/__mocks__/editor.ts"],"names":[],"mappings":";AAAa,cAAM,GAAG;IACpB,SAAS,EAAE,cAAM,OAAA,WAAW,EAAX,CAAW;CAC7B,CAAC"} \ No newline at end of file diff --git a/lib/modules/dir/index.js b/lib/modules/dir/index.js index e529169..cb90917 100644 --- a/lib/modules/dir/index.js +++ b/lib/modules/dir/index.js @@ -1,6 +1,7 @@ "use strict"; var index_1 = require('../../index'); function dirReducer(dir) { + console.log(index_1.editor); return index_1.editor ? index_1.editor.directory() : ''; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/modules/dir/index.js.map b/lib/modules/dir/index.js.map index 0db5d62..e733f5c 100644 --- a/lib/modules/dir/index.js.map +++ b/lib/modules/dir/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/dir/index.ts"],"names":[],"mappings":";AAAA,sBAAqB,aAAa,CAAC,CAAA;AAOnC,oBACE,GAAW;IAGX,MAAM,CAAC,cAAM,GAAG,cAAM,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC;AAC1C,CAAC;AALD;4BAKC,CAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/dir/index.ts"],"names":[],"mappings":";AAAA,sBAAqB,aAAa,CAAC,CAAA;AAOnC,oBACE,GAAW;IAEX,OAAO,CAAC,GAAG,CAAC,cAAM,CAAC,CAAC;IAEpB,MAAM,CAAC,cAAM,GAAG,cAAM,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC;AAC1C,CAAC;AAND;4BAMC,CAAA"} \ No newline at end of file diff --git a/package.json b/package.json index dac0fca..0d40dcc 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "repository": "https://github.com/coderoad/core-coderoad", "scripts": { "compile": "tsc", - "test": "jest" + "test": "jest", + "mocks": "tsc -p ./src/__mocks__" }, "dependencies": { "atom-plugin-command-line": "1.0.2", diff --git a/src/__mocks__/editor/index.js b/src/__mocks__/editor/index.js new file mode 100644 index 0000000..1db717c --- /dev/null +++ b/src/__mocks__/editor/index.js @@ -0,0 +1,6 @@ +"use strict"; +exports.editor = { + name: 'editorName', + directory: function () { return './path/to/dir'; }, +}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/__mocks__/editor/index.js.map b/src/__mocks__/editor/index.js.map new file mode 100644 index 0000000..8a5bc1e --- /dev/null +++ b/src/__mocks__/editor/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAGa,cAAM,GAAG;IACpB,IAAI,EAAE,YAAY;IAClB,SAAS,EAAE,cAAM,OAAA,eAAe,EAAf,CAAe;CACjC,CAAC"} \ No newline at end of file diff --git a/src/__mocks__/editor/index.ts b/src/__mocks__/editor/index.ts new file mode 100644 index 0000000..e1a3347 --- /dev/null +++ b/src/__mocks__/editor/index.ts @@ -0,0 +1,7 @@ +/** + * Pass in a configuration object to the mock + */ +export const editor = { + name: 'editorName', + directory: () => './path/to/dir', +}; diff --git a/src/__mocks__/tsconfig.json b/src/__mocks__/tsconfig.json new file mode 100644 index 0000000..6918e6e --- /dev/null +++ b/src/__mocks__/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "target": "ES5", + "module": "commonjs", + "declaration": false, + "noImplicitAny": false, + "removeComments": true, + "jsx": "react", + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "sourceMap": true, + "moduleResolution": "node", + "strictNullChecks": true + }, + "filesGlob": [ + "*.ts", + "**/*.ts", + "*.tsx", + "**/*.tsx" + ], + "files": [ + "editor/index.ts" + ] +} diff --git a/src/components/Start/Start.test.tsx b/src/components/Start/Start.test.tsx index 1024381..ab89b47 100644 --- a/src/components/Start/Start.test.tsx +++ b/src/components/Start/Start.test.tsx @@ -1,29 +1,32 @@ /// +/// +/// +/// import * as React from 'react'; import * as renderer from 'react-test-renderer'; -import Start from './index'; -import { Provider } from 'react-redux'; +// import Start from './index'; +// import { Provider } from 'react-redux'; -import '../../__tests__/mocks'; -import mockStore from '../../__tests__/mocks/store'; +// import '../../__tests__/mocks'; +// import mockStore from '../../__tests__/mocks/store'; -describe('', () => { +xdescribe('', () => { - it('renders if checks pass', () => { - const store = mockStore({ - checks: { - passed: false - } - }); - const tree = renderer.create( - - - - ).toJSON(); - expect(tree).toMatchSnapshot(); + xit('renders if checks pass', () => { + // const store = mockStore({ + // checks: { + // passed: false + // } + // }); + // const tree = renderer.create( + // + // + // + // ).toJSON(); + // expect(tree).toMatchSnapshot(); }); // xit('renders if check fails', () => { diff --git a/src/modules/dir/reducer.test.ts b/src/modules/dir/reducer.test.ts index 5f572a3..2763c77 100644 --- a/src/modules/dir/reducer.test.ts +++ b/src/modules/dir/reducer.test.ts @@ -1,23 +1,16 @@ -/// /// +/// +/// +jest.setMock('../../index', require('../../__mocks__/editor/index.js')); import dir from './index'; -import {atomPath} from '../../__tests__/mocks/atom'; describe('dir reducer', () => { - afterEach(() => { - global.atom = null; - }); - - it('should return the project directory in Atom', () => { - const pathToDir = './path/to/dir'; - global.atom = atomPath(pathToDir); - expect(dir('')).toBe(pathToDir); - }); - - it('should throw an error if no project directory is found', () => { - expect(() => dir('')).toThrowError(/No project directory/); + it('should return the project directory from the editor', () => { + const directory = './path/to/dir'; + // directory() => './path/to/dir' is default + expect(dir('')).toBe(directory); }); -}); \ No newline at end of file +}); diff --git a/src/modules/editor/reducer.test.ts b/src/modules/editor/reducer.test.ts index 012d683..21bc734 100644 --- a/src/modules/editor/reducer.test.ts +++ b/src/modules/editor/reducer.test.ts @@ -1,5 +1,6 @@ /// +jest.setMock('../../index', require('../../__mocks__/editor/index.js')); import reducer from './reducer'; import * as types from './types'; @@ -7,7 +8,8 @@ describe('editor reducer', () => { it('does nothing if action types do not match', () => { const action = { type: 'unknown' }; - expect(reducer(undefined, action)).toBe('atom'); + // name: 'editorName' is default + expect(reducer(undefined, action)).toBe('editorName'); }); }); \ No newline at end of file diff --git a/src/typings/index.d.ts b/src/typings/index.d.ts index 5b5fa15..6696aa5 100644 --- a/src/typings/index.d.ts +++ b/src/typings/index.d.ts @@ -4,6 +4,7 @@ /// /// /// +/// /// /// /// @@ -16,6 +17,7 @@ /// /// /// +/// /// /// /// @@ -36,4 +38,3 @@ /// /// /// -/// diff --git a/tsconfig.json b/tsconfig.json index ae76b84..6fc6043 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -54,6 +54,7 @@ "src/typings/globals/node-file-exists/index.d.ts", "src/typings/globals/node/index.d.ts", "src/typings/globals/pathwatcher/index.d.ts", + "src/typings/globals/proxyquire/index.d.ts", "src/typings/globals/q/index.d.ts", "src/typings/globals/react-addons-shallow-compare/index.d.ts", "src/typings/globals/react-addons-test-utils/index.d.ts", @@ -78,6 +79,7 @@ "src/typings/tests/index.d.ts", "src/typings/tests/validation.d.ts", "src/typings/tutorial/index.d.ts", + "src/__mocks__/editor/index.ts", "src/actions.ts", "src/components/Common/Markdown/formatText.ts", "src/components/Common/Markdown/syntax-highlighter.ts", From 857d8302b9bb75ee2bca9d82dc04e1ae81ca9c50 Mon Sep 17 00:00:00 2001 From: ShMcK Date: Tue, 27 Sep 2016 13:19:07 -0700 Subject: [PATCH 02/18] add travis-ci config --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1f9c778 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "6.1" + - "5.11" From de37dc91ea3caa0a6d8740f0ab35f5150b6f49e5 Mon Sep 17 00:00:00 2001 From: ShMcK Date: Tue, 27 Sep 2016 13:19:07 -0700 Subject: [PATCH 03/18] add travis-ci config --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6e1a947 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "6.1" + - "5.11" +script: npm test \ No newline at end of file From 51cffe3c80e10b92f8dd99615dc20ae13189743b Mon Sep 17 00:00:00 2001 From: ShMcK Date: Tue, 27 Sep 2016 13:30:47 -0700 Subject: [PATCH 04/18] cleanup mocks, edit travis-ci build --- .gitignore | 4 +++- .travis.yml | 3 ++- package.json | 2 +- src/__mocks__/editor/index.js | 6 ------ src/__mocks__/editor/index.js.map | 1 - 5 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 src/__mocks__/editor/index.js delete mode 100644 src/__mocks__/editor/index.js.map diff --git a/.gitignore b/.gitignore index b28e6e6..271de28 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,6 @@ npm-debug.log # Testing e2e src/__coverage__ -src/__tests__/__cache__ \ No newline at end of file +src/__tests__/__cache__ +src/__mocks__/**/*.js +src/__mocks__/**/*.js.map diff --git a/.travis.yml b/.travis.yml index 6e1a947..308c535 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,5 @@ language: node_js node_js: - "6.1" - "5.11" -script: npm test \ No newline at end of file +script: npm test +before_script: npm run mocks \ No newline at end of file diff --git a/package.json b/package.json index 0d40dcc..0e82994 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "devDependencies": { "coderoad-cli": "^0.10.0", "electron-chromedriver": "^1.4.0", - "eslint": "^3.6.0", + "eslint": "^3.6.1", "eslint-plugin-react": "^6.3.0", "jest": "^15.1.1", "jest-cli": "^15.1.1", diff --git a/src/__mocks__/editor/index.js b/src/__mocks__/editor/index.js deleted file mode 100644 index 1db717c..0000000 --- a/src/__mocks__/editor/index.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; -exports.editor = { - name: 'editorName', - directory: function () { return './path/to/dir'; }, -}; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/__mocks__/editor/index.js.map b/src/__mocks__/editor/index.js.map deleted file mode 100644 index 8a5bc1e..0000000 --- a/src/__mocks__/editor/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAGa,cAAM,GAAG;IACpB,IAAI,EAAE,YAAY;IAClB,SAAS,EAAE,cAAM,OAAA,eAAe,EAAf,CAAe;CACjC,CAAC"} \ No newline at end of file From 79505c790f83a42bd104916721becc5797257046 Mon Sep 17 00:00:00 2001 From: ShMcK Date: Tue, 27 Sep 2016 14:46:18 -0700 Subject: [PATCH 05/18] edit mocks --- .gitignore | 3 +-- lib/__mocks__/editor/index.js | 16 ++++++++++++++++ lib/__mocks__/editor/index.js.map | 1 + lib/components/common/Markdown/CodeBlock.js.map | 2 +- .../common/Markdown/formatText.js.map | 2 +- .../common/Markdown/syntax-highlighter.js.map | 2 +- lib/components/common/TextEditor/index.js.map | 2 +- lib/modules/alert/index.js.map | 2 +- lib/modules/dir/index.js | 1 - lib/modules/dir/index.js.map | 2 +- package.json | 2 +- src/__mocks__/editor/index.js | 17 +++++++++++++++++ src/__mocks__/editor/index.js.map | 1 + src/__mocks__/editor/index.ts | 10 ++++++++++ src/modules/alert/index.ts | 2 +- src/modules/alert/reducer.test.ts | 2 +- src/modules/editor/reducer.test.ts | 10 ++++++++-- src/modules/tutorial/reducer.test.ts | 2 +- src/typings/index.d.ts | 1 - tsconfig.json | 15 +++++++-------- tslint.json | 1 + 21 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 lib/__mocks__/editor/index.js create mode 100644 lib/__mocks__/editor/index.js.map create mode 100644 src/__mocks__/editor/index.js create mode 100644 src/__mocks__/editor/index.js.map diff --git a/.gitignore b/.gitignore index 271de28..7fbc96d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,4 @@ npm-debug.log e2e src/__coverage__ src/__tests__/__cache__ -src/__mocks__/**/*.js -src/__mocks__/**/*.js.map +src/__mocks__/**/*.ts diff --git a/lib/__mocks__/editor/index.js b/lib/__mocks__/editor/index.js new file mode 100644 index 0000000..f3fe684 --- /dev/null +++ b/lib/__mocks__/editor/index.js @@ -0,0 +1,16 @@ +"use strict"; +exports.editor = { + name: 'editorName', + directory: function () { return './path/to/dir'; }, + action: { + toggleDevTools: function () { return true; }, + save: function () { return true; }, + open: function (file) { return true; }, + insert: function (text) { return true; }, + set: function (text) { return true; }, + scroll: function (text) { return true; }, + writeFileFromFile: function (options) { return true; }, + writeFileFromContent: function (options) { return true; }, + } +}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/__mocks__/editor/index.js.map b/lib/__mocks__/editor/index.js.map new file mode 100644 index 0000000..2dc6919 --- /dev/null +++ b/lib/__mocks__/editor/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/__mocks__/editor/index.ts"],"names":[],"mappings":";AAGa,cAAM,GAAG;IACpB,IAAI,EAAE,YAAY;IAClB,SAAS,EAAE,cAAM,OAAA,eAAe,EAAf,CAAe;IAChC,MAAM,EAAE;QACN,cAAc,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QAC1B,IAAI,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QAChB,IAAI,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC5B,MAAM,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC9B,GAAG,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC3B,MAAM,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC9B,iBAAiB,EAAE,UAAC,OAAe,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC5C,oBAAoB,EAAE,UAAC,OAAe,IAAK,OAAA,IAAI,EAAJ,CAAI;KAChD;CACF,CAAC"} \ No newline at end of file diff --git a/lib/components/common/Markdown/CodeBlock.js.map b/lib/components/common/Markdown/CodeBlock.js.map index 9d8ff58..aae6e06 100644 --- a/lib/components/common/Markdown/CodeBlock.js.map +++ b/lib/components/common/Markdown/CodeBlock.js.map @@ -1 +1 @@ -{"version":3,"file":"CodeBlock.js","sourceRoot":"","sources":["../../../../src/components/Common/Markdown/CodeBlock.tsx"],"names":[],"mappings":";AAAA,IAAY,KAAK,WAAM,OAAO,CAAC,CAAA;AAE/B,mCAAsB,sBAAsB,CAAC,CAAA;AAE7C,IAAM,SAAS,GAEV,UAAC,EAAuB;QAAtB,gBAAK,EAAE,sBAAQ,EAAE,cAAI;IAAM,OAAA,CAChC,qBAAC,GAAG;QACF,qBAAC,IAAI,IACH,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,EAAG,EAC1B,uBAAuB,EAAE,EAAC,MAAM,EAAE,4BAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAC7D;KACE,CACP;AAPiC,CAOjC,CAAC;AACF;kBAAe,SAAS,CAAC"} \ No newline at end of file +{"version":3,"file":"CodeBlock.js","sourceRoot":"","sources":["../../../../src/components/common/Markdown/CodeBlock.tsx"],"names":[],"mappings":";AAAA,IAAY,KAAK,WAAM,OAAO,CAAC,CAAA;AAE/B,mCAAsB,sBAAsB,CAAC,CAAA;AAE7C,IAAM,SAAS,GAEV,UAAC,EAAuB;QAAtB,gBAAK,EAAE,sBAAQ,EAAE,cAAI;IAAM,OAAA,CAChC,qBAAC,GAAG;QACF,qBAAC,IAAI,IACH,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,EAAG,EAC1B,uBAAuB,EAAE,EAAC,MAAM,EAAE,4BAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAC7D;KACE,CACP;AAPiC,CAOjC,CAAC;AACF;kBAAe,SAAS,CAAC"} \ No newline at end of file diff --git a/lib/components/common/Markdown/formatText.js.map b/lib/components/common/Markdown/formatText.js.map index 543a379..70eb91b 100644 --- a/lib/components/common/Markdown/formatText.js.map +++ b/lib/components/common/Markdown/formatText.js.map @@ -1 +1 @@ -{"version":3,"file":"formatText.js","sourceRoot":"","sources":["../../../../src/components/Common/Markdown/formatText.ts"],"names":[],"mappings":";AAAA,IAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAEjC,mCAAsB,sBAAsB,CAAC,CAAA;AAE7C,IAAM,OAAO,GAAG;IACd,MAAM,EAAE,IAAI;IACZ,GAAG,EAAE,IAAI;IACT,uCAAS;IACT,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,IAAI;CACjB,CAAC;AAEF,mBAAyB,IAAY;IACnC,MAAM,CAAC,OAAO,IAAI,KAAK,QAAQ,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;AAC1E,CAAC;AAFD;2BAEC,CAAA"} \ No newline at end of file +{"version":3,"file":"formatText.js","sourceRoot":"","sources":["../../../../src/components/common/Markdown/formatText.ts"],"names":[],"mappings":";AAAA,IAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAEjC,mCAAsB,sBAAsB,CAAC,CAAA;AAE7C,IAAM,OAAO,GAAG;IACd,MAAM,EAAE,IAAI;IACZ,GAAG,EAAE,IAAI;IACT,uCAAS;IACT,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,IAAI;CACjB,CAAC;AAEF,mBAAyB,IAAY;IACnC,MAAM,CAAC,OAAO,IAAI,KAAK,QAAQ,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;AAC1E,CAAC;AAFD;2BAEC,CAAA"} \ No newline at end of file diff --git a/lib/components/common/Markdown/syntax-highlighter.js.map b/lib/components/common/Markdown/syntax-highlighter.js.map index 2625a50..d2ed974 100644 --- a/lib/components/common/Markdown/syntax-highlighter.js.map +++ b/lib/components/common/Markdown/syntax-highlighter.js.map @@ -1 +1 @@ -{"version":3,"file":"syntax-highlighter.js","sourceRoot":"","sources":["../../../../src/components/Common/Markdown/syntax-highlighter.ts"],"names":[],"mappings":";AAAA,sBAAqB,gBAAgB,CAAC,CAAA;AAEtC,mBAAkC,IAAY,EAAE,IAAY;IAC1D,IAAM,SAAS,GAAG,YAAU,IAAM,CAAC;IAEnC,IAAM,OAAO,GAAG,cAAM,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAEvD,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACb,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;IAED,IAAM,UAAU,GAAG,cAAM,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC/D,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAM,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACzD,EAAE,CAAC,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC;YAClE,UAAU,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IACD,IAAI,IAAI,GAAG,oCAAoC,CAAC;IAEhD,UAAU,CAAC,OAAO,CAAC,UAAA,IAAI;QACrB,IAAI,IAAI,oBAAoB,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,UAAC,EAAe;gBAAd,gBAAK,EAAE,kBAAM;YAE1B,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBACX,KAAK,GAAG,GAAG,CAAC;YACd,CAAC;YAED,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;gBAClB,IAAI,IAAI,mBAAgB,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,QAAI,CAAC;YACxD,CAAC,CAAC,CAAC;YAEH,IAAI,IAAI,KAAG,KAAO,CAAC;YAEnB,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;gBAClB,IAAI,IAAI,SAAS,CAAC;YACpB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,IAAI,IAAI,cAAc,CAAC;IACvB,MAAM,CAAC,IAAI,CAAC;AACd,CAAC;AAvCD;2BAuCC,CAAA"} \ No newline at end of file +{"version":3,"file":"syntax-highlighter.js","sourceRoot":"","sources":["../../../../src/components/common/Markdown/syntax-highlighter.ts"],"names":[],"mappings":";AAAA,sBAAqB,gBAAgB,CAAC,CAAA;AAEtC,mBAAkC,IAAY,EAAE,IAAY;IAC1D,IAAM,SAAS,GAAG,YAAU,IAAM,CAAC;IAEnC,IAAM,OAAO,GAAG,cAAM,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAEvD,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACb,MAAM,CAAC,IAAI,CAAC;IACd,CAAC;IAED,IAAM,UAAU,GAAG,cAAM,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC/D,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAM,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACzD,EAAE,CAAC,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC;YAClE,UAAU,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IACD,IAAI,IAAI,GAAG,oCAAoC,CAAC;IAEhD,UAAU,CAAC,OAAO,CAAC,UAAA,IAAI;QACrB,IAAI,IAAI,oBAAoB,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,UAAC,EAAe;gBAAd,gBAAK,EAAE,kBAAM;YAE1B,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBACX,KAAK,GAAG,GAAG,CAAC;YACd,CAAC;YAED,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;gBAClB,IAAI,IAAI,mBAAgB,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,QAAI,CAAC;YACxD,CAAC,CAAC,CAAC;YAEH,IAAI,IAAI,KAAG,KAAO,CAAC;YAEnB,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;gBAClB,IAAI,IAAI,SAAS,CAAC;YACpB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,IAAI,IAAI,cAAc,CAAC;IACvB,MAAM,CAAC,IAAI,CAAC;AACd,CAAC;AAvCD;2BAuCC,CAAA"} \ No newline at end of file diff --git a/lib/components/common/TextEditor/index.js.map b/lib/components/common/TextEditor/index.js.map index 40a7a59..199e8dc 100644 --- a/lib/components/common/TextEditor/index.js.map +++ b/lib/components/common/TextEditor/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Common/TextEditor/index.tsx"],"names":[],"mappings":";;;;;;AAAA,IAAY,KAAK,WAAM,OAAO,CAAC,CAAA;AAI9B,CAAC;AAEF,IAAM,MAAM,GAAY;IACtB,MAAM,EAAE;QACN,SAAS,EAAE,MAAM;KAClB;CACF,CAAC;AAEF;IAAwC,8BAGlC;IAHN;QAAwC,8BAGlC;QAGG,OAAE,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC;IAsB/C,CAAC;IArBQ,wBAAG,GAAV;QACE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IACM,2BAAM,GAAb;QACE,MAAM,CAAC,qBAAC,GAAG,IAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,IAAK,EAAC,KAAK,EAAE,MAAM,CAAC,MAAO,EAAG,CAAC;IAC5D,CAAC;IACO,sCAAiB,GAAzB;QACE,IAAA,eAAkD,EAA3C,cAAI,EAAE,cAAI,EAAE,cAAI,EAAE,4BAAW,CAAe;QAEnD,IAAI,CAAC,EAAE,CAAC,UAAU,CAChB,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,YAAU,IAAM,CAAC,CACpD,CAAC;QACF,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YACT,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAC9B,CAAC;QACD,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;YAChB,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QAC1C,CAAC;QAED,QAAQ,CAAC,aAAa,CAAC,MAAI,IAAM,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC;IACvE,CAAC;IACH,iBAAC;AAAD,CAAC,AA5BD,CAAwC,KAAK,CAAC,SAAS,GA4BtD;AA5BD;4BA4BC,CAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/common/TextEditor/index.tsx"],"names":[],"mappings":";;;;;;AAAA,IAAY,KAAK,WAAM,OAAO,CAAC,CAAA;AAI9B,CAAC;AAEF,IAAM,MAAM,GAAY;IACtB,MAAM,EAAE;QACN,SAAS,EAAE,MAAM;KAClB;CACF,CAAC;AAEF;IAAwC,8BAGlC;IAHN;QAAwC,8BAGlC;QAGG,OAAE,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC;IAsB/C,CAAC;IArBQ,wBAAG,GAAV;QACE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IACM,2BAAM,GAAb;QACE,MAAM,CAAC,qBAAC,GAAG,IAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,IAAK,EAAC,KAAK,EAAE,MAAM,CAAC,MAAO,EAAG,CAAC;IAC5D,CAAC;IACO,sCAAiB,GAAzB;QACE,IAAA,eAAkD,EAA3C,cAAI,EAAE,cAAI,EAAE,cAAI,EAAE,4BAAW,CAAe;QAEnD,IAAI,CAAC,EAAE,CAAC,UAAU,CAChB,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,YAAU,IAAM,CAAC,CACpD,CAAC;QACF,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YACT,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAC9B,CAAC;QACD,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;YAChB,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QAC1C,CAAC;QAED,QAAQ,CAAC,aAAa,CAAC,MAAI,IAAM,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC;IACvE,CAAC;IACH,iBAAC;AAAD,CAAC,AA5BD,CAAwC,KAAK,CAAC,SAAS,GA4BtD;AA5BD;4BA4BC,CAAA"} \ No newline at end of file diff --git a/lib/modules/alert/index.js.map b/lib/modules/alert/index.js.map index e91dbbe..6950df7 100644 --- a/lib/modules/alert/index.js.map +++ b/lib/modules/alert/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/alert/index.ts"],"names":[],"mappings":";AAAA,sBAAqD,SAAS,CAAC,CAAA;AAGlD,cAAM,GAAG;IACpB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;CAChB,CAAC;AAGW,cAAM,GAAa;IAC9B,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,cAAM,CAAC,IAAI;CACnB,CAAC;AAEF,IAAM,IAAI,GAAG;IACX,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,IAAI;CACf,CAAC;AAEF,IAAI,OAAO,GAAa,cAAM,CAAC;AAM/B,kBAAkB,CAAW;IAC3B,CAAC,CAAC,KAAK,GAAG,cAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,cAAM,CAAC,IAAI,CAAC;IAC1C,IAAI,cAAc,GAAgB,QAAQ,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IACxF,cAAc,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IACrC,OAAO,GAAG,CAAC,CAAC;IACZ,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACpC,CAAC;AAQD,eACE,KAAc,EAAE,MAAc;IAA9B,qBAAc,GAAd,sBAAc;IAEd,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAEpB,KAAK,oBAAY;YACf,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE3B,KAAK,kBAAU;YACb,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAExC,KAAK,mBAAW;YACd,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAEnD;YACE,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAjBD;uBAiBC,CAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/alert/index.ts"],"names":[],"mappings":";AAAA,sBAAoD,SAAS,CAAC,CAAA;AAGjD,cAAM,GAAG;IACpB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;CAChB,CAAC;AAGW,cAAM,GAAa;IAC9B,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,cAAM,CAAC,IAAI;CACnB,CAAC;AAEF,IAAM,IAAI,GAAG;IACX,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,IAAI;CACf,CAAC;AAEF,IAAI,OAAO,GAAa,cAAM,CAAC;AAM/B,kBAAkB,CAAW;IAC3B,CAAC,CAAC,KAAK,GAAG,cAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,cAAM,CAAC,IAAI,CAAC;IAC1C,IAAI,cAAc,GAAgB,QAAQ,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IACxF,cAAc,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IACrC,OAAO,GAAG,CAAC,CAAC;IACZ,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACpC,CAAC;AAQD,eACE,KAAc,EAAE,MAAc;IAA9B,qBAAc,GAAd,sBAAc;IAEd,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAEpB,KAAK,oBAAY;YACf,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE3B,KAAK,kBAAU;YACb,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAExC,KAAK,mBAAW;YACd,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAEnD;YACE,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAjBD;uBAiBC,CAAA"} \ No newline at end of file diff --git a/lib/modules/dir/index.js b/lib/modules/dir/index.js index cb90917..e529169 100644 --- a/lib/modules/dir/index.js +++ b/lib/modules/dir/index.js @@ -1,7 +1,6 @@ "use strict"; var index_1 = require('../../index'); function dirReducer(dir) { - console.log(index_1.editor); return index_1.editor ? index_1.editor.directory() : ''; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/modules/dir/index.js.map b/lib/modules/dir/index.js.map index e733f5c..0db5d62 100644 --- a/lib/modules/dir/index.js.map +++ b/lib/modules/dir/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/dir/index.ts"],"names":[],"mappings":";AAAA,sBAAqB,aAAa,CAAC,CAAA;AAOnC,oBACE,GAAW;IAEX,OAAO,CAAC,GAAG,CAAC,cAAM,CAAC,CAAC;IAEpB,MAAM,CAAC,cAAM,GAAG,cAAM,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC;AAC1C,CAAC;AAND;4BAMC,CAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/dir/index.ts"],"names":[],"mappings":";AAAA,sBAAqB,aAAa,CAAC,CAAA;AAOnC,oBACE,GAAW;IAGX,MAAM,CAAC,cAAM,GAAG,cAAM,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC;AAC1C,CAAC;AALD;4BAKC,CAAA"} \ No newline at end of file diff --git a/package.json b/package.json index 0e82994..325984c 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ ], "testRegex": "src/*/.*\\.test\\.(ts|tsx|js)$", "coverageDirectory": "src/__coverage__", - "collectCoverage": false, + "collectCoverage": true, "coveragePathIgnorePatterns": [ "/node_modules/", "src/typings/", diff --git a/src/__mocks__/editor/index.js b/src/__mocks__/editor/index.js new file mode 100644 index 0000000..3f2e397 --- /dev/null +++ b/src/__mocks__/editor/index.js @@ -0,0 +1,17 @@ +"use strict"; +var jest_1 = require('jest'); +exports.editor = { + name: 'editorName', + directory: function () { return './path/to/dir'; }, + action: { + toggleDevTools: jest_1.default.fn(), + save: function () { return true; }, + open: function (file) { return true; }, + insert: function (text) { return true; }, + set: function (text) { return true; }, + scroll: function (text) { return true; }, + writeFileFromFile: function (options) { return true; }, + writeFileFromContent: function (options) { return true; }, + } +}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/__mocks__/editor/index.js.map b/src/__mocks__/editor/index.js.map new file mode 100644 index 0000000..df2fe0c --- /dev/null +++ b/src/__mocks__/editor/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,qBAAiB,MAAM,CAAC,CAAA;AAKX,cAAM,GAAG;IACpB,IAAI,EAAE,YAAY;IAClB,SAAS,EAAE,cAAM,OAAA,eAAe,EAAf,CAAe;IAChC,MAAM,EAAE;QACN,cAAc,EAAE,cAAI,CAAC,EAAE,EAAE;QACzB,IAAI,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QAChB,IAAI,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC5B,MAAM,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC9B,GAAG,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC3B,MAAM,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC9B,iBAAiB,EAAE,UAAC,OAAe,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC5C,oBAAoB,EAAE,UAAC,OAAe,IAAK,OAAA,IAAI,EAAJ,CAAI;KAChD;CACF,CAAC"} \ No newline at end of file diff --git a/src/__mocks__/editor/index.ts b/src/__mocks__/editor/index.ts index e1a3347..e754e51 100644 --- a/src/__mocks__/editor/index.ts +++ b/src/__mocks__/editor/index.ts @@ -4,4 +4,14 @@ export const editor = { name: 'editorName', directory: () => './path/to/dir', + action: { + toggleDevTools: () => true, + save: () => true, + open: (file: string) => true, + insert: (text: string) => true, + set: (text: string) => true, + scroll: (text: string) => true, + writeFileFromFile: (options: Object) => true, + writeFileFromContent: (options: Object) => true, + } }; diff --git a/src/modules/alert/index.ts b/src/modules/alert/index.ts index ff86101..1a8fa5c 100644 --- a/src/modules/alert/index.ts +++ b/src/modules/alert/index.ts @@ -1,4 +1,4 @@ -import {ALERT_CLOSE, ALERT_OPEN, ALERT_REPLAY} from './types'; +import {ALERT_CLOSE, ALERT_OPEN, ALERT_REPLAY} from './types'; // alert styles export const colors = { diff --git a/src/modules/alert/reducer.test.ts b/src/modules/alert/reducer.test.ts index db0ba30..f3ae3bb 100644 --- a/src/modules/alert/reducer.test.ts +++ b/src/modules/alert/reducer.test.ts @@ -2,7 +2,7 @@ /// import reducer, { _alert, colors } from './index'; -import { ALERT_OPEN, ALERT_REPLAY, ALERT_CLOSE } from './types'; +import { ALERT_CLOSE, ALERT_OPEN, ALERT_REPLAY } from './types'; describe('alert reducer', () => { diff --git a/src/modules/editor/reducer.test.ts b/src/modules/editor/reducer.test.ts index 21bc734..0b5840d 100644 --- a/src/modules/editor/reducer.test.ts +++ b/src/modules/editor/reducer.test.ts @@ -1,8 +1,8 @@ /// -jest.setMock('../../index', require('../../__mocks__/editor/index.js')); +let mock = jest.setMock('../../index', require('../../__mocks__/editor/index.js')); import reducer from './reducer'; -import * as types from './types'; +import * as type from './types'; describe('editor reducer', () => { @@ -12,4 +12,10 @@ describe('editor reducer', () => { expect(reducer(undefined, action)).toBe('editorName'); }); + xit('it toggles editor devtools', () => { + const action = { type: type.EDITOR_DEVTOOLS_TOGGLE }; + reducer(undefined, action); + expect(mock).toBeCalled(); + }); + }); \ No newline at end of file diff --git a/src/modules/tutorial/reducer.test.ts b/src/modules/tutorial/reducer.test.ts index 439cd29..dcbd847 100644 --- a/src/modules/tutorial/reducer.test.ts +++ b/src/modules/tutorial/reducer.test.ts @@ -16,7 +16,7 @@ describe('tutorial reducer', () => { dir: 'path/to/file', }; const action = { type: 'TUTORIAL_SET', payload }; - const expected = {} + const expected = {}; expect(reducer(undefined, action)).toEqual(expected); }); diff --git a/src/typings/index.d.ts b/src/typings/index.d.ts index 6696aa5..7bb8ecc 100644 --- a/src/typings/index.d.ts +++ b/src/typings/index.d.ts @@ -17,7 +17,6 @@ /// /// /// -/// /// /// /// diff --git a/tsconfig.json b/tsconfig.json index 6fc6043..656bacb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -54,7 +54,6 @@ "src/typings/globals/node-file-exists/index.d.ts", "src/typings/globals/node/index.d.ts", "src/typings/globals/pathwatcher/index.d.ts", - "src/typings/globals/proxyquire/index.d.ts", "src/typings/globals/q/index.d.ts", "src/typings/globals/react-addons-shallow-compare/index.d.ts", "src/typings/globals/react-addons-test-utils/index.d.ts", @@ -81,8 +80,8 @@ "src/typings/tutorial/index.d.ts", "src/__mocks__/editor/index.ts", "src/actions.ts", - "src/components/Common/Markdown/formatText.ts", - "src/components/Common/Markdown/syntax-highlighter.ts", + "src/components/common/Markdown/formatText.ts", + "src/components/common/Markdown/syntax-highlighter.ts", "src/components/index.ts", "src/components/SidePanel/index.ts", "src/components/SidePanel/sideElement.ts", @@ -176,11 +175,11 @@ "src/components/AppMenu/menuRight.tsx", "src/components/AppMenu/menuRightRouteOptions.tsx", "src/components/AppMenu/Quit/index.tsx", - "src/components/Common/ContentCard.tsx", - "src/components/Common/Markdown/CodeBlock.tsx", - "src/components/Common/Markdown/index.tsx", - "src/components/Common/RouteButton.tsx", - "src/components/Common/TextEditor/index.tsx", + "src/components/common/ContentCard.tsx", + "src/components/common/Markdown/CodeBlock.tsx", + "src/components/common/Markdown/index.tsx", + "src/components/common/RouteButton.tsx", + "src/components/common/TextEditor/index.tsx", "src/components/FinalPage/index.tsx", "src/components/FinalPage/SeeMore.tsx", "src/components/Page/EditPage/index.tsx", diff --git a/tslint.json b/tslint.json index 2bf7432..28cc01c 100644 --- a/tslint.json +++ b/tslint.json @@ -37,6 +37,7 @@ "no-empty": true, "no-eval": true, "no-inferrable-types": true, + "no-reference": false, "no-shadowed-variable": true, "no-string-literal": true, "no-switch-case-fall-through": true, From 3b82ed3a041a96075f40b8eac0239c8a3bf4f27a Mon Sep 17 00:00:00 2001 From: ShMcK Date: Tue, 27 Sep 2016 14:47:14 -0700 Subject: [PATCH 06/18] fix editor mock --- src/__mocks__/editor/index.js | 3 +-- src/__mocks__/editor/index.js.map | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/__mocks__/editor/index.js b/src/__mocks__/editor/index.js index 3f2e397..f3fe684 100644 --- a/src/__mocks__/editor/index.js +++ b/src/__mocks__/editor/index.js @@ -1,10 +1,9 @@ "use strict"; -var jest_1 = require('jest'); exports.editor = { name: 'editorName', directory: function () { return './path/to/dir'; }, action: { - toggleDevTools: jest_1.default.fn(), + toggleDevTools: function () { return true; }, save: function () { return true; }, open: function (file) { return true; }, insert: function (text) { return true; }, diff --git a/src/__mocks__/editor/index.js.map b/src/__mocks__/editor/index.js.map index df2fe0c..3ff0a0e 100644 --- a/src/__mocks__/editor/index.js.map +++ b/src/__mocks__/editor/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,qBAAiB,MAAM,CAAC,CAAA;AAKX,cAAM,GAAG;IACpB,IAAI,EAAE,YAAY;IAClB,SAAS,EAAE,cAAM,OAAA,eAAe,EAAf,CAAe;IAChC,MAAM,EAAE;QACN,cAAc,EAAE,cAAI,CAAC,EAAE,EAAE;QACzB,IAAI,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QAChB,IAAI,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC5B,MAAM,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC9B,GAAG,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC3B,MAAM,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC9B,iBAAiB,EAAE,UAAC,OAAe,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC5C,oBAAoB,EAAE,UAAC,OAAe,IAAK,OAAA,IAAI,EAAJ,CAAI;KAChD;CACF,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAGa,cAAM,GAAG;IACpB,IAAI,EAAE,YAAY;IAClB,SAAS,EAAE,cAAM,OAAA,eAAe,EAAf,CAAe;IAChC,MAAM,EAAE;QACN,cAAc,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QAC1B,IAAI,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QAChB,IAAI,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC5B,MAAM,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC9B,GAAG,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC3B,MAAM,EAAE,UAAC,IAAY,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC9B,iBAAiB,EAAE,UAAC,OAAe,IAAK,OAAA,IAAI,EAAJ,CAAI;QAC5C,oBAAoB,EAAE,UAAC,OAAe,IAAK,OAAA,IAAI,EAAJ,CAAI;KAChD;CACF,CAAC"} \ No newline at end of file From 50656aa7376e0679e58d69b9037df2c49261120e Mon Sep 17 00:00:00 2001 From: ShMcK Date: Tue, 27 Sep 2016 14:59:59 -0700 Subject: [PATCH 07/18] attempt to repair jest for travis build --- .travis.yml | 2 +- src/modules/tutorial/reducer.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ff2ecfc..cd8a8de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ node_js: - "6.1" - "5.11" script: npm test -before_script: npm run mocks +before_script: npm install diff --git a/src/modules/tutorial/reducer.test.ts b/src/modules/tutorial/reducer.test.ts index dcbd847..676c180 100644 --- a/src/modules/tutorial/reducer.test.ts +++ b/src/modules/tutorial/reducer.test.ts @@ -20,4 +20,4 @@ describe('tutorial reducer', () => { expect(reducer(undefined, action)).toEqual(expected); }); -}); \ No newline at end of file +}); From 5176afdff3fef96059dd2959d403846f8accea88 Mon Sep 17 00:00:00 2001 From: ShMcK Date: Sun, 9 Oct 2016 12:05:56 -0700 Subject: [PATCH 08/18] use redux diff-logger --- lib/options/configureStore.js | 8 +- lib/options/configureStore.js.map | 2 +- package.json | 8 +- src/components/AppMenu/common/ContentCard.tsx | 29 +++++ .../AppMenu/common/Markdown/CodeBlock.tsx | 15 +++ .../AppMenu/common/Markdown/formatText.ts | 16 +++ .../AppMenu/common/Markdown/index.tsx | 14 +++ .../common/Markdown/syntax-highlighter.ts | 42 +++++++ src/components/AppMenu/common/RouteButton.tsx | 37 ++++++ .../AppMenu/common/TextEditor/index.tsx | 41 +++++++ src/options/configureStore.ts | 2 +- src/typings/globals/radium/index.d.ts | 113 ++++++++++++++++++ src/typings/globals/radium/typings.json | 8 ++ tsconfig.json | 22 ++-- 14 files changed, 340 insertions(+), 17 deletions(-) create mode 100644 src/components/AppMenu/common/ContentCard.tsx create mode 100644 src/components/AppMenu/common/Markdown/CodeBlock.tsx create mode 100644 src/components/AppMenu/common/Markdown/formatText.ts create mode 100644 src/components/AppMenu/common/Markdown/index.tsx create mode 100644 src/components/AppMenu/common/Markdown/syntax-highlighter.ts create mode 100644 src/components/AppMenu/common/RouteButton.tsx create mode 100644 src/components/AppMenu/common/TextEditor/index.tsx create mode 100644 src/typings/globals/radium/index.d.ts create mode 100644 src/typings/globals/radium/typings.json diff --git a/lib/options/configureStore.js b/lib/options/configureStore.js index 84cb003..1a0365c 100644 --- a/lib/options/configureStore.js +++ b/lib/options/configureStore.js @@ -1,12 +1,12 @@ "use strict"; -var redux_1 = require('redux'); -var createLogger = require('redux-logger'); -var redux_thunk_1 = require('redux-thunk'); +var redux_1 = require("redux"); +var createLogger = require("redux-logger"); +var redux_thunk_1 = require("redux-thunk"); var configureStore = function (_a) { var reducer = _a.reducer, devMode = _a.devMode; var middlewares = [redux_thunk_1.default]; if (devMode) { - var logger = createLogger(); + var logger = createLogger({ diff: true }); middlewares.push(logger); } else { diff --git a/lib/options/configureStore.js.map b/lib/options/configureStore.js.map index 96cd00e..5de9112 100644 --- a/lib/options/configureStore.js.map +++ b/lib/options/configureStore.js.map @@ -1 +1 @@ -{"version":3,"file":"configureStore.js","sourceRoot":"","sources":["../../src/options/configureStore.ts"],"names":[],"mappings":";AAAA,sBAA6C,OAAO,CAAC,CAAA;AACrD,IAAY,YAAY,WAAM,cAAc,CAAC,CAAA;AAC7C,4BAAkB,aAAa,CAAC,CAAA;AAEhC,IAAM,cAAc,GAAG,UAAC,EAAkB;QAAjB,oBAAO,EAAE,oBAAO;IAEvC,IAAI,WAAW,GAAG,CAAC,qBAAK,CAAC,CAAC;IAG1B,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACZ,IAAM,MAAM,GAAI,YAAoB,EAAE,CAAC;QACvC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAAC,IAAI,CAAC,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;IACtC,CAAC;IAGD,IAAM,KAAK,GAAqB,mBAAW,CACzC,OAAO,EACP,uBAAe,eAAI,WAAW,CAAC,CAChC,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;kBAAe,cAAc,CAAC"} \ No newline at end of file +{"version":3,"file":"configureStore.js","sourceRoot":"","sources":["../../src/options/configureStore.ts"],"names":[],"mappings":";AAAA,+BAAqD;AACrD,2CAA6C;AAC7C,2CAAgC;AAEhC,IAAM,cAAc,GAAG,UAAC,EAAkB;QAAjB,oBAAO,EAAE,oBAAO;IAEvC,IAAI,WAAW,GAAG,CAAC,qBAAK,CAAC,CAAC;IAG1B,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACZ,IAAM,MAAM,GAAI,YAAoB,CAAC,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;QACnD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAAC,IAAI,CAAC,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;IACtC,CAAC;IAGD,IAAM,KAAK,GAAqB,mBAAW,CACzC,OAAO,EACP,uBAAe,eAAI,WAAW,EAC/B,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC;AACf,CAAC,CAAC;;AAEF,kBAAe,cAAc,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json index 325984c..91b27f6 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "atom-plugin-command-line": "1.0.2", "coderoad-cli": "0.10.0", "marked": "0.3.6", - "material-ui": "0.15.4", + "material-ui": "0.16.0", "node-file-exists": "1.1.0", "react": "15.3.2", "react-dom": "15.3.2", @@ -40,7 +40,7 @@ "react-router-sans-urls": "0.1.2", "react-tap-event-plugin": "1.0.0", "redux": "3.6.0", - "redux-logger": "2.6.1", + "redux-logger": "2.7.0", "redux-thunk": "2.1.0", "reselect": "2.5.4" }, @@ -49,8 +49,8 @@ "electron-chromedriver": "^1.4.0", "eslint": "^3.6.1", "eslint-plugin-react": "^6.3.0", - "jest": "^15.1.1", - "jest-cli": "^15.1.1", + "jest": "^16.0.1", + "jest-cli": "^16.0.1", "react-addons-test-utils": "15.3.2", "react-test-renderer": "15.3.2", "redux-mock-store": "^1.2.1", diff --git a/src/components/AppMenu/common/ContentCard.tsx b/src/components/AppMenu/common/ContentCard.tsx new file mode 100644 index 0000000..6b7dc22 --- /dev/null +++ b/src/components/AppMenu/common/ContentCard.tsx @@ -0,0 +1,29 @@ +import Radium from 'radium'; +import * as React from 'react'; + +import {Markdown} from '../index'; +import {Card, CardHeader, CardText} from 'material-ui/Card'; + +const styles = { + card: { + margin: '5px', + }, +}; + +@Radium() +const ContentCard: React.StatelessComponent<{ + title: string, content?: string +}> = ({title, content}) => ( + + {title ? : null} + + + + +); +export default ContentCard; + +// ContentCard.propTypes = { +// title: React.PropTypes.string, +// content: React.PropTypes.string.optional, +// }; diff --git a/src/components/AppMenu/common/Markdown/CodeBlock.tsx b/src/components/AppMenu/common/Markdown/CodeBlock.tsx new file mode 100644 index 0000000..940af09 --- /dev/null +++ b/src/components/AppMenu/common/Markdown/CodeBlock.tsx @@ -0,0 +1,15 @@ +import * as React from 'react'; + +import highlight from './syntax-highlighter'; + +const CodeBlock: React.StatelessComponent<{ + children: string, style?: React.CSSProperties, lang: string +}> = ({style, children, lang}) => ( +
+    
+  
+); +export default CodeBlock; diff --git a/src/components/AppMenu/common/Markdown/formatText.ts b/src/components/AppMenu/common/Markdown/formatText.ts new file mode 100644 index 0000000..74d70a3 --- /dev/null +++ b/src/components/AppMenu/common/Markdown/formatText.ts @@ -0,0 +1,16 @@ +import * as marked from 'marked'; + +import highlight from './syntax-highlighter'; + +const options = { + breaks: true, + gfm: true, + highlight, + tables: true, + sanitize: true, + smartLists: true, +}; + +export default function (text: string): string { + return typeof text !== 'string' ? '' : marked(text.toString(), options); +} diff --git a/src/components/AppMenu/common/Markdown/index.tsx b/src/components/AppMenu/common/Markdown/index.tsx new file mode 100644 index 0000000..700a71e --- /dev/null +++ b/src/components/AppMenu/common/Markdown/index.tsx @@ -0,0 +1,14 @@ +import * as React from 'react'; + +import formatText from './formatText'; + +const Markdown: React.StatelessComponent<{ + children: string, style?: React.CSSProperties +}> = ({style, children}) => ( + +); +export default Markdown; diff --git a/src/components/AppMenu/common/Markdown/syntax-highlighter.ts b/src/components/AppMenu/common/Markdown/syntax-highlighter.ts new file mode 100644 index 0000000..2cead5d --- /dev/null +++ b/src/components/AppMenu/common/Markdown/syntax-highlighter.ts @@ -0,0 +1,42 @@ +import {editor} from '../../../index'; + +export default function highlight(text: string, lang: string): string { + const scopeName = `source.${lang}`; + // get grammar + const grammar = editor.grammar.getFromScope(scopeName); + // no grammar, return text + if (!grammar) { + return text; + } + // get tokens + const lineTokens = editor.grammar.tokenizeLines(grammar, text); + if (lineTokens.length > 0) { + const lastLineTokens = lineTokens[lineTokens.length - 1]; + if (lastLineTokens.length === 1 && lastLineTokens[0].value === '') { + lineTokens.pop(); + } + } + let html = '
';
+
+  lineTokens.forEach(line => {
+    html += '
'; + line.forEach(({value, scopes}) => { + // account for spaces + if (!value) { + value = ' '; + } + // wrap text with class spans + scopes.forEach(scope => { + html += ``; + }); + // text + html += `${value}`; + // closing tags + scopes.forEach(scope => { + html += ''; + }); + }); + }); + html += '
'; + return html; +} diff --git a/src/components/AppMenu/common/RouteButton.tsx b/src/components/AppMenu/common/RouteButton.tsx new file mode 100644 index 0000000..453d4e7 --- /dev/null +++ b/src/components/AppMenu/common/RouteButton.tsx @@ -0,0 +1,37 @@ +import * as React from 'react'; +import {connect} from 'react-redux'; + +import {routeSet} from '../../actions'; +import RaisedButton from 'material-ui/RaisedButton'; + +class RouteButton extends React.Component<{ + label: string, route: string, routeSet: any, style: React.CSSProperties +}, {}> { + public render() { + const {label, route, style, routeSet} = this.props; + return ( + + ); + } +} + +// RouteButton.propTypes = { +// label: React.PropTypes.string, +// route: React.PropTypes.string, +// routeSet: React.PropTypes.func.optional, +// style: React.PropTypes.object.optional, +// }; + +const mapStateToProps = (state, props) => ({ + label: props.label, + route: props.route, + style: props.style || {} +}); +const mapDispatchToProps = {routeSet}; + +export default connect(mapStateToProps, mapDispatchToProps)(RouteButton); \ No newline at end of file diff --git a/src/components/AppMenu/common/TextEditor/index.tsx b/src/components/AppMenu/common/TextEditor/index.tsx new file mode 100644 index 0000000..311cd6d --- /dev/null +++ b/src/components/AppMenu/common/TextEditor/index.tsx @@ -0,0 +1,41 @@ +import * as React from 'react'; + +interface IStyles { + editor: React.CSSProperties; +}; + +const styles: IStyles = { + editor: { + textAlign: 'left', + }, +}; + +export default class TextEditor extends React.Component<{ + name: string, text?: string, lang: string, onSave?: () => any, + placeholder?: string, +}, {}> { + + // create a new TextEditor + public ed = atom.workspace.buildTextEditor(); + public get(): string { + return this.ed.getText(); + } + public render() { + return
; + } + private componentDidMount() { + const {name, text, lang, placeholder} = this.props; + // specify language + this.ed.setGrammar( + atom.grammars.grammarForScopeName(`source.${lang}`) + ); + if (text) { + this.ed.setText(text || ''); + } + if (placeholder) { + this.ed.setPlaceholderText(placeholder); + } + // append editor to rendered div + document.querySelector(`#${name}`).appendChild(this.ed.getElement()); + } +} diff --git a/src/options/configureStore.ts b/src/options/configureStore.ts index 6e0fec1..c748289 100644 --- a/src/options/configureStore.ts +++ b/src/options/configureStore.ts @@ -8,7 +8,7 @@ const configureStore = ({reducer, devMode}) => { // use logger if devMode if (devMode) { - const logger = (createLogger as any)(); + const logger = (createLogger as any)({diff: true}); middlewares.push(logger); } else { process.env.NODE_ENV = 'production'; diff --git a/src/typings/globals/radium/index.d.ts b/src/typings/globals/radium/index.d.ts new file mode 100644 index 0000000..efc0c8a --- /dev/null +++ b/src/typings/globals/radium/index.d.ts @@ -0,0 +1,113 @@ +// Generated by typings +// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/092e7f33ba65b4162419b7c5d56e8f1a55ffdbf9/radium/radium.d.ts +declare module 'radium' { + import * as React from 'react'; + + + namespace Radium { + interface StyleRules { + [index: string]: React.CSSProperties; + } + + /** + * Style component properties + */ + export interface StyleProps { + /** + * An object of styles, or an object of CSS rules to render. Each key of the rules object is a CSS + * selector and the value is an object of styles. If rules is empty, the component will render nothing. + */ + rules: React.CSSProperties | StyleRules; + /** + * A string that any included selectors in rules will be appended to. + * Use to scope styles in the component to a particular element. A good use case might be to generate a unique + * ID for a component to scope any styles to the particular component that owns the