From 311d6b3799fd2ceab7bc04675d0a6ba0d3b5c7d7 Mon Sep 17 00:00:00 2001 From: "Kristian D. Dimitrov" Date: Mon, 3 Jun 2019 21:21:16 +0300 Subject: [PATCH] test: unit tests for log-source-map-service --- .gitignore | 1 + Gruntfile.js | 1 + .../sourceMapBundle/android/app/bundle.js | 330 ++++++++++++++++++ test/files/sourceMapBundle/ios/app/bundle.js | 322 +++++++++++++++++ test/services/log-source-map-service.ts | 82 +++++ 5 files changed, 736 insertions(+) create mode 100644 test/files/sourceMapBundle/android/app/bundle.js create mode 100644 test/files/sourceMapBundle/ios/app/bundle.js create mode 100644 test/services/log-source-map-service.ts diff --git a/.gitignore b/.gitignore index 26c35ffb93..3cb5a81f11 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,7 @@ docs/html docs-cli !test-scripts/*.js +!test/files/**/*.js # From previous submodule lib/common/*.js diff --git a/Gruntfile.js b/Gruntfile.js index fb02e2b240..69ee423df5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -114,6 +114,7 @@ module.exports = function (grunt) { clean: { src: ["test/**/*.js*", + "!test/files/**/*.js*", "lib/**/*.js*", "!test-scripts/**/*", "!lib/common/vendor/*.js", diff --git a/test/files/sourceMapBundle/android/app/bundle.js b/test/files/sourceMapBundle/android/app/bundle.js new file mode 100644 index 0000000000..b2e25b9fd2 --- /dev/null +++ b/test/files/sourceMapBundle/android/app/bundle.js @@ -0,0 +1,330 @@ +module.exports = +(global["webpackJsonp"] = global["webpackJsonp"] || []).push([["bundle"],{ + +/***/ "./ sync ^\\.\\/app\\.(css|scss|less|sass)$": +/***/ (function(module, exports, __webpack_require__) { + +var map = { + "./app.css": "./app.css" +}; + + +function webpackContext(req) { + var id = webpackContextResolve(req); + return __webpack_require__(id); +} +function webpackContextResolve(req) { + var id = map[req]; + if(!(id + 1)) { // check for number or string + var e = new Error("Cannot find module '" + req + "'"); + e.code = 'MODULE_NOT_FOUND'; + throw e; + } + return id; +} +webpackContext.keys = function webpackContextKeys() { + return Object.keys(map); +}; +webpackContext.resolve = webpackContextResolve; +module.exports = webpackContext; +webpackContext.id = "./ sync ^\\.\\/app\\.(css|scss|less|sass)$"; + +/***/ }), + +/***/ "./ sync recursive (root|page)\\.(xml|css|js|ts|scss)$": +/***/ (function(module, exports, __webpack_require__) { + +var map = { + "./app-root.xml": "./app-root.xml", + "./main-page.js": "./main-page.js", + "./main-page.ts": "./main-page.ts", + "./main-page.xml": "./main-page.xml" +}; + + +function webpackContext(req) { + var id = webpackContextResolve(req); + return __webpack_require__(id); +} +function webpackContextResolve(req) { + var id = map[req]; + if(!(id + 1)) { // check for number or string + var e = new Error("Cannot find module '" + req + "'"); + e.code = 'MODULE_NOT_FOUND'; + throw e; + } + return id; +} +webpackContext.keys = function webpackContextKeys() { + return Object.keys(map); +}; +webpackContext.resolve = webpackContextResolve; +module.exports = webpackContext; +webpackContext.id = "./ sync recursive (root|page)\\.(xml|css|js|ts|scss)$"; + +/***/ }), + +/***/ "./app-root.xml": +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) { +module.exports = "\n\n"; + if (true) { + module.hot.accept(); + module.hot.dispose(() => { + global.hmrRefresh({ type: 'markup', path: './app-root.xml' }); + }) + } + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("../node_modules/webpack/buildin/global.js"))) + +/***/ }), + +/***/ "./app.css": +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {exports = module.exports = __webpack_require__("../node_modules/css-loader/dist/runtime/api.js")(false); +// Imports +exports.i(__webpack_require__("../node_modules/css-loader/dist/cjs.js?!../node_modules/nativescript-theme-core/css/core.light.css"), ""); + +// Module +exports.push([module.i, "/*\nIn NativeScript, the app.css file is where you place CSS rules that\nyou would like to apply to your entire application. Check out\nhttp://docs.nativescript.org/ui/styling for a full list of the CSS\nselectors and properties you can use to style UI components.\n\n/*\nIn many cases you may want to use the NativeScript core theme instead\nof writing your own CSS rules. For a full list of class names in the theme\nrefer to http://docs.nativescript.org/ui/theme. \nThe imported CSS rules must precede all other types of rules.\n*/\n\n/*\nThe following CSS rule changes the font size of all UI\ncomponents that have the btn class name.\n*/\n.btn {\n font-size: 18;\n}\n", ""]); + +; + if (true) { + module.hot.accept(); + module.hot.dispose(() => { + global.hmrRefresh({ type: 'style', path: './app.css' }); + }) + } + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("../node_modules/webpack/buildin/global.js"))) + +/***/ }), + +/***/ "./app.ts": +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var tns_core_modules_application__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../node_modules/tns-core-modules/application/application.js"); +/* harmony import */ var tns_core_modules_application__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(tns_core_modules_application__WEBPACK_IMPORTED_MODULE_0__); + + let applicationCheckPlatform = __webpack_require__("../node_modules/tns-core-modules/application/application.js"); + if (applicationCheckPlatform.android && !global["__snapshot"]) { + __webpack_require__("../node_modules/tns-core-modules/ui/frame/frame.js"); +__webpack_require__("../node_modules/tns-core-modules/ui/frame/activity.js"); + } + + + __webpack_require__("../node_modules/nativescript-dev-webpack/load-application-css-regular.js")(); + + + if (true) { + const hmrUpdate = __webpack_require__("../node_modules/nativescript-dev-webpack/hmr/index.js").hmrUpdate; + global.__initialHmrUpdate = true; + global.__hmrSyncBackup = global.__onLiveSync; + + global.__onLiveSync = function () { + hmrUpdate(); + }; + + global.hmrRefresh = function({ type, path } = {}) { + if (global.__initialHmrUpdate) { + return; + } + + setTimeout(() => { + global.__hmrSyncBackup({ type, path }); + }); + }; + + hmrUpdate().then(() => { + global.__initialHmrUpdate = false; + }) + } + + const context = __webpack_require__("./ sync recursive (root|page)\\.(xml|css|js|ts|scss)$"); + global.registerWebpackModules(context); + + __webpack_require__("../node_modules/tns-core-modules/bundle-entry-points.js"); + /* +In NativeScript, the app.ts file is the entry point to your application. +You can use this file to perform app-level initialization, but the primary +purpose of the file is to pass control to the app’s first module. +*/ + +tns_core_modules_application__WEBPACK_IMPORTED_MODULE_0__["run"]({ moduleName: "app-root" }); +/* +Do not place any code after the application has been started as it will not +be executed on iOS. +*/ + + + + + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("../node_modules/webpack/buildin/global.js"))) + +/***/ }), + +/***/ "./main-page.js": +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +/* +In NativeScript, a file with the same name as an XML file is known as +a code-behind file. The code-behind is a great place to place your view +logic, and to set up your page’s data binding. +*/ +Object.defineProperty(exports, "__esModule", { value: true }); +var main_view_model_1 = __webpack_require__("./main-view-model.ts"); +// Event handler for Page "navigatingTo" event attached in main-page.xml +function navigatingTo(args) { + /* + This gets a reference this page’s UI component. You can + view the API reference of the Page to see what’s available at + https://docs.nativescript.org/api-reference/classes/_ui_page_.page.html + */ + var page = args.object; + /* + A page’s bindingContext is an object that should be used to perform + data binding between XML markup and TypeScript code. Properties + on the bindingContext can be accessed using the {{ }} syntax in XML. + In this example, the {{ message }} and {{ onTap }} bindings are resolved + against the object returned by createViewModel(). + + You can learn more about data binding in NativeScript at + https://docs.nativescript.org/core-concepts/data-binding. + */ + page.bindingContext = new main_view_model_1.HelloWorldModel(); +} +exports.navigatingTo = navigatingTo; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi1wYWdlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsibWFpbi1wYWdlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7OztFQUlFOztBQUlGLHFEQUFvRDtBQUVwRCx3RUFBd0U7QUFDeEUsU0FBZ0IsWUFBWSxDQUFDLElBQWU7SUFDeEM7Ozs7TUFJRTtJQUNGLElBQU0sSUFBSSxHQUFTLElBQUksQ0FBQyxNQUFNLENBQ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m9yZy9hcGktcmVmZXJlbmNlL2NsYXNzZXMvX3VpX3BhZ2VfLnBhZ2UuaHRtbFxuICAgICovXG4gICAgY29uc3QgcGFnZSA9IDxQYWdlPmFyZ3Mub2JqZWN0O1xuXG4gICAgLypcbiAgICBBIHBhZ2XigJlzIGJpbmRpbmdDb250ZXh0IGlzIGFuIG9iamVjdCB0aGF0IHNob3VsZCBiZSB1c2VkIHRvIHBlcmZvcm1cbiAgICBkYXRhIGJpbmRpbmcgYmV0d2VlbiBYTUwgbWFya3VwIGFuZCBUeXBlU2NyaXB0IGNvZGUuIFByb3BlcnRpZXNcbiAgICBvbiB0aGUgYmluZGluZ0NvbnRleHQgY2FuIGJlIGFjY2Vzc2VkIHVzaW5nIHRoZSB7eyB9fSBzeW50YXggaW4gWE1MLlxuICAgIEluIHRoaXMgZXhhbXBsZSwgdGhlIHt7IG1lc3NhZ2UgfX0gYW5kIHt7IG9uVGFwIH19IGJpbmRpbmdzIGFyZSByZXNvbHZlZFxuICAgIGFnYWluc3QgdGhlIG9iamVjdCByZXR1cm5lZCBieSBjcmVhdGVWaWV3TW9kZWwoKS5cblxuICAgIFlvdSBjYW4gbGVhcm4gbW9yZSBhYm91dCBkYXRhIGJpbmRpbmcgaW4gTmF0aXZlU2NyaXB0IGF0XG4gICAgaHR0cHM6Ly9kb2NzLm5hdGl2ZXNjcmlwdC5vcmcvY29yZS1jb25jZXB0cy9kYXRhLWJpbmRpbmcuXG4gICAgKi9cbiAgICBwYWdlLmJpbmRpbmdDb250ZXh0ID0gbmV3IEhlbGxvV29ybGRNb2RlbCgpO1xufVxuIl19 + +/***/ }), + +/***/ "./main-page.ts": +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "navigatingTo", function() { return navigatingTo; }); +/* harmony import */ var _main_view_model__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./main-view-model.ts"); +/* +In NativeScript, a file with the same name as an XML file is known as +a code-behind file. The code-behind is a great place to place your view +logic, and to set up your page’s data binding. +*/ + +// Event handler for Page "navigatingTo" event attached in main-page.xml +function navigatingTo(args) { + /* + This gets a reference this page’s UI component. You can + view the API reference of the Page to see what’s available at + https://docs.nativescript.org/api-reference/classes/_ui_page_.page.html + */ + var page = args.object; + /* + A page’s bindingContext is an object that should be used to perform + data binding between XML markup and TypeScript code. Properties + on the bindingContext can be accessed using the {{ }} syntax in XML. + In this example, the {{ message }} and {{ onTap }} bindings are resolved + against the object returned by createViewModel(). + + You can learn more about data binding in NativeScript at + https://docs.nativescript.org/core-concepts/data-binding. + */ + page.bindingContext = new _main_view_model__WEBPACK_IMPORTED_MODULE_0__["HelloWorldModel"](); +} +; + if (true) { + module.hot.accept(); + module.hot.dispose(() => { + global.hmrRefresh({ type: 'script', path: './main-page.ts' }); + }) + } + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("../node_modules/webpack/buildin/global.js"))) + +/***/ }), + +/***/ "./main-page.xml": +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) { +module.exports = "\n\n \n \n \n \n \n \n \n