From 810f457e205ce8062f17ba57fda30e9ef090c2d6 Mon Sep 17 00:00:00 2001 From: Jack Grossman Date: Fri, 9 Nov 2018 10:23:40 -0500 Subject: [PATCH] Initial commit for unit tests ref #1264 --- dist/locales/en.json | 13 +- karma.conf.js | 255 ++++++++++---------- modules/Hoot/hoot.js | 168 ++++++------- stats.json | 4 +- test/hoot/index.js | 50 ++-- test/hoot/spec/layerColorTest/layerColor.js | 76 ++++++ 6 files changed, 322 insertions(+), 244 deletions(-) create mode 100644 test/hoot/spec/layerColorTest/layerColor.js diff --git a/dist/locales/en.json b/dist/locales/en.json index cb168ec556..9e05a6f300 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -7256,9 +7256,6 @@ "SPW_PICC": { "name": "SPW(allonie) PICC numerical imagery" }, - "US-TIGER-Roads-2012": { - "name": "TIGER Roads 2012" - }, "US-TIGER-Roads-2014": { "description": "At zoom level 16+, public domain map data from the US Census. At lower zooms, only changes since 2006 minus changes already incorporated into OpenStreetMap", "name": "TIGER Roads 2014" @@ -7267,6 +7264,10 @@ "description": "Yellow = Public domain map data from the US Census. Red = Data not found in OpenStreetMap", "name": "TIGER Roads 2017" }, + "US-TIGER-Roads-2018": { + "description": "Yellow = Public domain map data from the US Census. Red = Data not found in OpenStreetMap", + "name": "TIGER Roads 2018" + }, "US_Forest_Service_roads_overlay": { "description": "Highway: Green casing = unclassified. Brown casing = track. Surface: gravel = light brown fill, Asphalt = black, paved = gray, ground =white, concrete = blue, grass = green. Seasonal = white bars", "name": "U.S. Forest Roads Overlay" @@ -7374,12 +7375,6 @@ "description": "Orthophotos from the municipality of Helsingborg 2016, public domain", "name": "Helsingborg Orthophoto" }, - "hike_n_bike": { - "attribution": { - "text": "© OpenStreetMap contributors" - }, - "name": "Hike & Bike" - }, "kalmar-orto-2014": { "attribution": { "text": "© Kalmar municipality" diff --git a/karma.conf.js b/karma.conf.js index 7d16103e37..440cb6d981 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,145 +1,152 @@ // Karma configuration // Generated on Mon Oct 29 2018 14:12:47 GMT-0400 (Eastern Daylight Time) -const path = require( 'path' ); -const Merge = require( 'webpack-merge' ); -const baseConfig = require( './webpack-config/webpack.base.config' ); +const path = require("path"); +const Merge = require("webpack-merge"); +const baseConfig = require("./webpack-config/webpack.base.config"); const materialIconFiles = [ - { pattern: 'node_modules/material-design-icons/iconfont/material-icons.css', included: true }, - { pattern: 'node_modules/material-design-icons/iconfont/MaterialIcons-Regular.eot', included: false }, - { pattern: 'node_modules/material-design-icons/iconfont/MaterialIcons-Regular.svg', included: false }, - { pattern: 'node_modules/material-design-icons/iconfont/MaterialIcons-Regular.ttf', included: false }, - { pattern: 'node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff', included: false }, - { pattern: 'node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff2', included: false }, + { + pattern: "node_modules/material-design-icons/iconfont/material-icons.css", + included: true + }, + { + pattern: + "node_modules/material-design-icons/iconfont/MaterialIcons-Regular.eot", + included: false + }, + { + pattern: + "node_modules/material-design-icons/iconfont/MaterialIcons-Regular.svg", + included: false + }, + { + pattern: + "node_modules/material-design-icons/iconfont/MaterialIcons-Regular.ttf", + included: false + }, + { + pattern: + "node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff", + included: false + }, + { + pattern: + "node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff2", + included: false + } ]; -const webpackConfig = Merge( baseConfig, { - mode: 'development', - entry: './test/hoot/index.js', - module: { - rules: [ - // instrument only testing sources with Istanbul - { - test: /\.js$/, - use: { - loader: 'istanbul-instrumenter-loader', - options: { esModules: true } - }, - include: path.resolve( __dirname, 'modules/Hoot/' ), - enforce: 'post' - // exclude: /node_modules|\.spec\.js$/ - } - ] - }, - resolve: { - alias: { - img: path.resolve( __dirname, 'img' ), - lib: path.resolve( __dirname, 'modules/lib' ) - } - }, -} ); - -module.exports = function( config ) { - config.set( { - - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', - - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: [ 'mocha' ], - - - client: { - mocha: { - timeout: 5000 - } +const webpackConfig = Merge(baseConfig, { + mode: "development", + entry: "./test/hoot/index.js", + module: { + rules: [ + // instrument only testing sources with Istanbul + { + test: /\.js$/, + use: { + loader: "istanbul-instrumenter-loader", + options: { esModules: true } }, + include: path.resolve(__dirname, "modules/Hoot/"), + enforce: "post" + // exclude: /node_modules|\.spec\.js$/ + } + ] + }, + resolve: { + alias: { + img: path.resolve(__dirname, "img"), + lib: path.resolve(__dirname, "modules/lib") + } + } +}); + +module.exports = function(config) { + config.set({ + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: "", + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ["mocha"], + + client: { + mocha: { + timeout: 5000 + } + }, + // list of files / patterns to load in the browser + files: [ + ...materialIconFiles, + + { pattern: "img/**/*.svg", included: false }, + { pattern: "img/**/*.png", included: false }, + { pattern: "img/**/*.gif", included: false }, + + { pattern: "test/data/UndividedHighway.osm", included: false }, + { pattern: "test/data/ImportMultiTest.dbf", included: false }, + { pattern: "test/data/ImportMultiTest.shp", included: false }, + { pattern: "test/data/ImportMultiTest.shx", included: false }, + + "css/**/*.css", + "css/**/*.scss", + "test/hoot/index.js" + ], + + // list of files / patterns to exclude + exclude: [], + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + "test/hoot/index.js": ["webpack"], + "test/hoot/helpers.js": ["webpack"], + "css/**/*.scss": ["scss"] + }, - // list of files / patterns to load in the browser - files: [ - ...materialIconFiles, - - { pattern: 'img/**/*.svg', included: false }, - { pattern: 'img/**/*.png', included: false }, - { pattern: 'img/**/*.gif', included: false }, - - { pattern: 'test/data/UndividedHighway.osm', included: false }, - { pattern: 'test/data/ImportMultiTest.dbf', included: false }, - { pattern: 'test/data/ImportMultiTest.shp', included: false }, - { pattern: 'test/data/ImportMultiTest.shx', included: false }, - - 'css/**/*.css', - 'css/**/*.scss', - 'test/hoot/index.js' - ], - - - // list of files / patterns to exclude - exclude: [], - - - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - 'test/hoot/index.js': [ 'webpack' ], - 'test/hoot/helpers.js': [ 'webpack' ], - 'css/**/*.scss': [ 'scss' ] - }, - - - proxies: { - '/img/': '/base/img/' - }, - - - webpack: webpackConfig, - - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: [ 'spec', 'coverage-istanbul' ], - - - coverageIstanbulReporter: { - reports: [ 'html', 'lcov', 'text-summary' ], - dir: path.join( __dirname, 'coverage' ), - fixWebpackSourcePaths: true - }, - - - // web server port - port: 9876, - + proxies: { + "/img/": "/base/img/" + }, - // enable / disable colors in the output (reporters and logs) - colors: true, + webpack: webpackConfig, + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ["spec", "coverage-istanbul"], - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, + coverageIstanbulReporter: { + reports: ["html", "lcov", "text-summary"], + dir: path.join(__dirname, "coverage"), + fixWebpackSourcePaths: true + }, + // web server port + port: 9876, - // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, + // enable / disable colors in the output (reporters and logs) + colors: true, + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: [ 'Chrome' ], + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ["Chrome"], - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: false, + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, - // Concurrency level - // how many browser should be started simultaneous - concurrency: 1 - } ); + // Concurrency level + // how many browser should be started simultaneous + concurrency: 1 + }); }; diff --git a/modules/Hoot/hoot.js b/modules/Hoot/hoot.js index a5ebdbcc33..2a749aa775 100644 --- a/modules/Hoot/hoot.js +++ b/modules/Hoot/hoot.js @@ -4,101 +4,101 @@ * @author Matt Putipong - matt.putipong@radiantsolutions.com on 8/16/18 *******************************************************************************************************/ -import _forEach from 'lodash-es/forEach'; - -import API from './managers/api'; -import MessageManager from './managers/messages/messageManager'; -import FolderManager from './managers/folderManager'; -import LayerManager from './managers/layerManager'; -import TranslationManager from './managers/translationManager'; -import EventManager from './managers/eventManager'; -import UI from './ui/init'; -import buildInfo from './config/buildInfo.json'; -import { tagInfo } from '../../data/index'; +import _forEach from "lodash-es/forEach"; + +import API from "./managers/api"; +import MessageManager from "./managers/messages/messageManager"; +import FolderManager from "./managers/folderManager"; +import LayerManager from "./managers/layerManager"; +import TranslationManager from "./managers/translationManager"; +import EventManager from "./managers/eventManager"; +import UI from "./ui/init"; +import buildInfo from "./config/buildInfo.json"; +import { tagInfo } from "../../data/index"; class Hoot { - constructor() { - this.api = new API( this ); - this.message = new MessageManager( this ); - this.layers = new LayerManager( this ); - this.folders = new FolderManager( this ); - this.translations = new TranslationManager( this ); - this.events = new EventManager(); - - this.config = { - urlroot: 'http://52.23.188.104:8080/hoot-services/osm', - tagInfo, - appInfo: [], - users: [], - exportSizeThreshold: null, - ingestSizeThreshold: null, - conflateSizeThreshold: null, - presetMaxDisplayNum: 12 - }; + constructor() { + this.api = new API(this); + this.message = new MessageManager(this); + this.layers = new LayerManager(this); + this.folders = new FolderManager(this); + this.translations = new TranslationManager(this); + this.events = new EventManager(); + + this.config = { + urlroot: "http://54.165.118.78:8080/hoot-services/osm", + tagInfo, + appInfo: [], + users: [], + exportSizeThreshold: null, + ingestSizeThreshold: null, + conflateSizeThreshold: null, + presetMaxDisplayNum: 12 + }; + } + + init(context) { + console.log("INIT"); + if (this.ui && this.ui instanceof UI) return; + + this.context = context; + + Promise.all([ + this.getAboutData(), + this.getAllUsers(), + this.getMapSizeThresholds(), + this.translations.getTranslations() + ]); + + this.ui = new UI(); + this.ui.render(); + + // prevent this class from being modified in any way. + // this does not affect children objects + Object.freeze(this); + } + + async getAboutData() { + try { + let info = await Promise.all([ + this.api.getCoreVersionInfo(), + this.api.getServicesVersionInfo() + ]); + + _forEach(info, d => this.config.appInfo.push(d)); + } catch (err) { + this.message.alert(err); } - init( context ) { - console.log( 'INIT' ); - if ( this.ui && this.ui instanceof UI ) return; + // build info will always be available + this.config.appInfo.push(buildInfo); + } - this.context = context; + async getAllUsers() { + try { + let resp = await this.api.getAllUsers(); - Promise.all( [ - this.getAboutData(), - this.getAllUsers(), - this.getMapSizeThresholds(), - this.translations.getTranslations() - ] ); + this.config.users = {}; - this.ui = new UI(); - this.ui.render(); - - // prevent this class from being modified in any way. - // this does not affect children objects - Object.freeze( this ); - } - - async getAboutData() { - try { - let info = await Promise.all( [ - this.api.getCoreVersionInfo(), - this.api.getServicesVersionInfo() - ] ); - - _forEach( info, d => this.config.appInfo.push( d ) ); - } catch ( err ) { - this.message.alert( err ); - } - - // build info will always be available - this.config.appInfo.push( buildInfo ); - } - - async getAllUsers() { - try { - let resp = await this.api.getAllUsers(); - - this.config.users = {}; - - _forEach( resp.users, user => { - this.config.users[ user.id ] = user; - } ); - } catch ( err ) { - this.message.alert( err ); - } + _forEach(resp.users, user => { + this.config.users[user.id] = user; + }); + } catch (err) { + this.message.alert(err); } + } - async getMapSizeThresholds() { - try { - let thresholds = await this.api.getMapSizeThresholds(); + async getMapSizeThresholds() { + try { + let thresholds = await this.api.getMapSizeThresholds(); - this.config.exportSizeThreshold = thresholds.export_threshold; - this.config.ingestSizeThreshold = thresholds.ingest_threshold; - this.config.conflateSizeThreshold = thresholds.conflate_threshold; - } catch ( err ) { - this.message.alert( err ); - } + this.config.exportSizeThreshold = thresholds.export_threshold; + this.config.ingestSizeThreshold = thresholds.ingest_threshold; + this.config.conflateSizeThreshold = thresholds.conflate_threshold; + } catch (err) { + this.message.alert(err); } + } } // Export this class as a "Singleton". When it is imported the very first time, diff --git a/stats.json b/stats.json index 3b05660619..7d8b4cae77 100644 --- a/stats.json +++ b/stats.json @@ -103162,7 +103162,7 @@ "ModuleConcatenation bailout: Module is not in any chunk" ], "depth": 3, - "source": "import _regeneratorRuntime from \"@babel/runtime/regenerator\";\nimport _asyncToGenerator from \"@babel/runtime/helpers/asyncToGenerator\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\n\n/*******************************************************************************************************\n * File: hoot.js\n * Project: hootenanny-ui\n * @author Matt Putipong - matt.putipong@radiantsolutions.com on 8/16/18\n *******************************************************************************************************/\nimport _forEach from 'lodash-es/forEach';\nimport API from './managers/api';\nimport MessageManager from './managers/messages/messageManager';\nimport FolderManager from './managers/folderManager';\nimport LayerManager from './managers/layerManager';\nimport TranslationManager from './managers/translationManager';\nimport EventManager from './managers/eventManager';\nimport UI from './ui/init';\nimport buildInfo from './config/buildInfo.json';\nimport { tagInfo } from '../../data/index';\n\nvar Hoot =\n/*#__PURE__*/\nfunction () {\n function Hoot() {\n _classCallCheck(this, Hoot);\n\n this.api = new API(this);\n this.message = new MessageManager(this);\n this.layers = new LayerManager(this);\n this.folders = new FolderManager(this);\n this.translations = new TranslationManager(this);\n this.events = new EventManager();\n this.config = {\n urlroot: 'http://52.23.188.104:8080/hoot-services/osm',\n tagInfo: tagInfo,\n appInfo: [],\n users: [],\n exportSizeThreshold: null,\n ingestSizeThreshold: null,\n conflateSizeThreshold: null,\n presetMaxDisplayNum: 12\n };\n }\n\n _createClass(Hoot, [{\n key: \"init\",\n value: function init(context) {\n if (this.ui && this.ui instanceof UI) return;\n this.context = context;\n Promise.all([this.getAboutData(), this.getAllUsers(), this.getMapSizeThresholds(), this.translations.getTranslations()]);\n this.ui = new UI();\n this.ui.render(); // prevent this class from being modified in any way.\n // this does not affect children objects\n\n Object.freeze(this);\n }\n }, {\n key: \"getAboutData\",\n value: function () {\n var _getAboutData = _asyncToGenerator(\n /*#__PURE__*/\n _regeneratorRuntime.mark(function _callee() {\n var _this = this;\n\n var info;\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n _context.next = 3;\n return Promise.all([this.api.getCoreVersionInfo(), this.api.getServicesVersionInfo()]);\n\n case 3:\n info = _context.sent;\n\n _forEach(info, function (d) {\n return _this.config.appInfo.push(d);\n });\n\n _context.next = 10;\n break;\n\n case 7:\n _context.prev = 7;\n _context.t0 = _context[\"catch\"](0);\n this.message.alert(_context.t0);\n\n case 10:\n // build info will always be available\n this.config.appInfo.push(buildInfo);\n\n case 11:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this, [[0, 7]]);\n }));\n\n return function getAboutData() {\n return _getAboutData.apply(this, arguments);\n };\n }()\n }, {\n key: \"getAllUsers\",\n value: function () {\n var _getAllUsers = _asyncToGenerator(\n /*#__PURE__*/\n _regeneratorRuntime.mark(function _callee2() {\n var _this2 = this;\n\n var resp;\n return _regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n _context2.next = 3;\n return this.api.getAllUsers();\n\n case 3:\n resp = _context2.sent;\n this.config.users = {};\n\n _forEach(resp.users, function (user) {\n _this2.config.users[user.id] = user;\n });\n\n _context2.next = 11;\n break;\n\n case 8:\n _context2.prev = 8;\n _context2.t0 = _context2[\"catch\"](0);\n this.message.alert(_context2.t0);\n\n case 11:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this, [[0, 8]]);\n }));\n\n return function getAllUsers() {\n return _getAllUsers.apply(this, arguments);\n };\n }()\n }, {\n key: \"getMapSizeThresholds\",\n value: function () {\n var _getMapSizeThresholds = _asyncToGenerator(\n /*#__PURE__*/\n _regeneratorRuntime.mark(function _callee3() {\n var thresholds;\n return _regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n _context3.next = 3;\n return this.api.getMapSizeThresholds();\n\n case 3:\n thresholds = _context3.sent;\n this.config.exportSizeThreshold = thresholds.export_threshold;\n this.config.ingestSizeThreshold = thresholds.ingest_threshold;\n this.config.conflateSizeThreshold = thresholds.conflate_threshold;\n _context3.next = 12;\n break;\n\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n this.message.alert(_context3.t0);\n\n case 12:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, this, [[0, 9]]);\n }));\n\n return function getMapSizeThresholds() {\n return _getMapSizeThresholds.apply(this, arguments);\n };\n }()\n }]);\n\n return Hoot;\n}(); // Export this class as a \"Singleton\". When it is imported the very first time,\n// it will create a new instance of the object and store it in memory. Every other\n// import afterwards will receive this cached object, and not create a new instance.\n// * Note: This is not a true Singleton, but it mimics the Singleton pattern\n// because of Node's module caching behavior.\n\n\nexport default new Hoot();" + "source": "import _regeneratorRuntime from \"@babel/runtime/regenerator\";\nimport _asyncToGenerator from \"@babel/runtime/helpers/asyncToGenerator\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\n\n/*******************************************************************************************************\n * File: hoot.js\n * Project: hootenanny-ui\n * @author Matt Putipong - matt.putipong@radiantsolutions.com on 8/16/18\n *******************************************************************************************************/\nimport _forEach from 'lodash-es/forEach';\nimport API from './managers/api';\nimport MessageManager from './managers/messages/messageManager';\nimport FolderManager from './managers/folderManager';\nimport LayerManager from './managers/layerManager';\nimport TranslationManager from './managers/translationManager';\nimport EventManager from './managers/eventManager';\nimport UI from './ui/init';\nimport buildInfo from './config/buildInfo.json';\nimport { tagInfo } from '../../data/index';\n\nvar Hoot =\n/*#__PURE__*/\nfunction () {\n function Hoot() {\n _classCallCheck(this, Hoot);\n\n this.api = new API(this);\n this.message = new MessageManager(this);\n this.layers = new LayerManager(this);\n this.folders = new FolderManager(this);\n this.translations = new TranslationManager(this);\n this.events = new EventManager();\n this.config = {\n urlroot: 'http://54.165.118.78:8080/hoot-services/osm',\n tagInfo: tagInfo,\n appInfo: [],\n users: [],\n exportSizeThreshold: null,\n ingestSizeThreshold: null,\n conflateSizeThreshold: null,\n presetMaxDisplayNum: 12\n };\n }\n\n _createClass(Hoot, [{\n key: \"init\",\n value: function init(context) {\n if (this.ui && this.ui instanceof UI) return;\n this.context = context;\n Promise.all([this.getAboutData(), this.getAllUsers(), this.getMapSizeThresholds(), this.translations.getTranslations()]);\n this.ui = new UI();\n this.ui.render(); // prevent this class from being modified in any way.\n // this does not affect children objects\n\n Object.freeze(this);\n }\n }, {\n key: \"getAboutData\",\n value: function () {\n var _getAboutData = _asyncToGenerator(\n /*#__PURE__*/\n _regeneratorRuntime.mark(function _callee() {\n var _this = this;\n\n var info;\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n _context.next = 3;\n return Promise.all([this.api.getCoreVersionInfo(), this.api.getServicesVersionInfo()]);\n\n case 3:\n info = _context.sent;\n\n _forEach(info, function (d) {\n return _this.config.appInfo.push(d);\n });\n\n _context.next = 10;\n break;\n\n case 7:\n _context.prev = 7;\n _context.t0 = _context[\"catch\"](0);\n this.message.alert(_context.t0);\n\n case 10:\n // build info will always be available\n this.config.appInfo.push(buildInfo);\n\n case 11:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this, [[0, 7]]);\n }));\n\n return function getAboutData() {\n return _getAboutData.apply(this, arguments);\n };\n }()\n }, {\n key: \"getAllUsers\",\n value: function () {\n var _getAllUsers = _asyncToGenerator(\n /*#__PURE__*/\n _regeneratorRuntime.mark(function _callee2() {\n var _this2 = this;\n\n var resp;\n return _regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n _context2.next = 3;\n return this.api.getAllUsers();\n\n case 3:\n resp = _context2.sent;\n this.config.users = {};\n\n _forEach(resp.users, function (user) {\n _this2.config.users[user.id] = user;\n });\n\n _context2.next = 11;\n break;\n\n case 8:\n _context2.prev = 8;\n _context2.t0 = _context2[\"catch\"](0);\n this.message.alert(_context2.t0);\n\n case 11:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this, [[0, 8]]);\n }));\n\n return function getAllUsers() {\n return _getAllUsers.apply(this, arguments);\n };\n }()\n }, {\n key: \"getMapSizeThresholds\",\n value: function () {\n var _getMapSizeThresholds = _asyncToGenerator(\n /*#__PURE__*/\n _regeneratorRuntime.mark(function _callee3() {\n var thresholds;\n return _regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n _context3.next = 3;\n return this.api.getMapSizeThresholds();\n\n case 3:\n thresholds = _context3.sent;\n this.config.exportSizeThreshold = thresholds.export_threshold;\n this.config.ingestSizeThreshold = thresholds.ingest_threshold;\n this.config.conflateSizeThreshold = thresholds.conflate_threshold;\n _context3.next = 12;\n break;\n\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n this.message.alert(_context3.t0);\n\n case 12:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, this, [[0, 9]]);\n }));\n\n return function getMapSizeThresholds() {\n return _getMapSizeThresholds.apply(this, arguments);\n };\n }()\n }]);\n\n return Hoot;\n}(); // Export this class as a \"Singleton\". When it is imported the very first time,\n// it will create a new instance of the object and store it in memory. Every other\n// import afterwards will receive this cached object, and not create a new instance.\n// * Note: This is not a true Singleton, but it mimics the Singleton pattern\n// because of Node's module caching behavior.\n\n\nexport default new Hoot();" }, { "id": null, @@ -440129,7 +440129,7 @@ "ModuleConcatenation bailout: Module is not in any chunk" ], "depth": 3, - "source": "import _regeneratorRuntime from \"@babel/runtime/regenerator\";\nimport _asyncToGenerator from \"@babel/runtime/helpers/asyncToGenerator\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\n\n/*******************************************************************************************************\n * File: hoot.js\n * Project: hootenanny-ui\n * @author Matt Putipong - matt.putipong@radiantsolutions.com on 8/16/18\n *******************************************************************************************************/\nimport _forEach from 'lodash-es/forEach';\nimport API from './managers/api';\nimport MessageManager from './managers/messages/messageManager';\nimport FolderManager from './managers/folderManager';\nimport LayerManager from './managers/layerManager';\nimport TranslationManager from './managers/translationManager';\nimport EventManager from './managers/eventManager';\nimport UI from './ui/init';\nimport buildInfo from './config/buildInfo.json';\nimport { tagInfo } from '../../data/index';\n\nvar Hoot =\n/*#__PURE__*/\nfunction () {\n function Hoot() {\n _classCallCheck(this, Hoot);\n\n this.api = new API(this);\n this.message = new MessageManager(this);\n this.layers = new LayerManager(this);\n this.folders = new FolderManager(this);\n this.translations = new TranslationManager(this);\n this.events = new EventManager();\n this.config = {\n urlroot: 'http://52.23.188.104:8080/hoot-services/osm',\n tagInfo: tagInfo,\n appInfo: [],\n users: [],\n exportSizeThreshold: null,\n ingestSizeThreshold: null,\n conflateSizeThreshold: null,\n presetMaxDisplayNum: 12\n };\n }\n\n _createClass(Hoot, [{\n key: \"init\",\n value: function init(context) {\n if (this.ui && this.ui instanceof UI) return;\n this.context = context;\n Promise.all([this.getAboutData(), this.getAllUsers(), this.getMapSizeThresholds(), this.translations.getTranslations()]);\n this.ui = new UI();\n this.ui.render(); // prevent this class from being modified in any way.\n // this does not affect children objects\n\n Object.freeze(this);\n }\n }, {\n key: \"getAboutData\",\n value: function () {\n var _getAboutData = _asyncToGenerator(\n /*#__PURE__*/\n _regeneratorRuntime.mark(function _callee() {\n var _this = this;\n\n var info;\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n _context.next = 3;\n return Promise.all([this.api.getCoreVersionInfo(), this.api.getServicesVersionInfo()]);\n\n case 3:\n info = _context.sent;\n\n _forEach(info, function (d) {\n return _this.config.appInfo.push(d);\n });\n\n _context.next = 10;\n break;\n\n case 7:\n _context.prev = 7;\n _context.t0 = _context[\"catch\"](0);\n this.message.alert(_context.t0);\n\n case 10:\n // build info will always be available\n this.config.appInfo.push(buildInfo);\n\n case 11:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this, [[0, 7]]);\n }));\n\n return function getAboutData() {\n return _getAboutData.apply(this, arguments);\n };\n }()\n }, {\n key: \"getAllUsers\",\n value: function () {\n var _getAllUsers = _asyncToGenerator(\n /*#__PURE__*/\n _regeneratorRuntime.mark(function _callee2() {\n var _this2 = this;\n\n var resp;\n return _regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n _context2.next = 3;\n return this.api.getAllUsers();\n\n case 3:\n resp = _context2.sent;\n this.config.users = {};\n\n _forEach(resp.users, function (user) {\n _this2.config.users[user.id] = user;\n });\n\n _context2.next = 11;\n break;\n\n case 8:\n _context2.prev = 8;\n _context2.t0 = _context2[\"catch\"](0);\n this.message.alert(_context2.t0);\n\n case 11:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this, [[0, 8]]);\n }));\n\n return function getAllUsers() {\n return _getAllUsers.apply(this, arguments);\n };\n }()\n }, {\n key: \"getMapSizeThresholds\",\n value: function () {\n var _getMapSizeThresholds = _asyncToGenerator(\n /*#__PURE__*/\n _regeneratorRuntime.mark(function _callee3() {\n var thresholds;\n return _regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n _context3.next = 3;\n return this.api.getMapSizeThresholds();\n\n case 3:\n thresholds = _context3.sent;\n this.config.exportSizeThreshold = thresholds.export_threshold;\n this.config.ingestSizeThreshold = thresholds.ingest_threshold;\n this.config.conflateSizeThreshold = thresholds.conflate_threshold;\n _context3.next = 12;\n break;\n\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n this.message.alert(_context3.t0);\n\n case 12:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, this, [[0, 9]]);\n }));\n\n return function getMapSizeThresholds() {\n return _getMapSizeThresholds.apply(this, arguments);\n };\n }()\n }]);\n\n return Hoot;\n}(); // Export this class as a \"Singleton\". When it is imported the very first time,\n// it will create a new instance of the object and store it in memory. Every other\n// import afterwards will receive this cached object, and not create a new instance.\n// * Note: This is not a true Singleton, but it mimics the Singleton pattern\n// because of Node's module caching behavior.\n\n\nexport default new Hoot();" + "source": "import _regeneratorRuntime from \"@babel/runtime/regenerator\";\nimport _asyncToGenerator from \"@babel/runtime/helpers/asyncToGenerator\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\n\n/*******************************************************************************************************\n * File: hoot.js\n * Project: hootenanny-ui\n * @author Matt Putipong - matt.putipong@radiantsolutions.com on 8/16/18\n *******************************************************************************************************/\nimport _forEach from 'lodash-es/forEach';\nimport API from './managers/api';\nimport MessageManager from './managers/messages/messageManager';\nimport FolderManager from './managers/folderManager';\nimport LayerManager from './managers/layerManager';\nimport TranslationManager from './managers/translationManager';\nimport EventManager from './managers/eventManager';\nimport UI from './ui/init';\nimport buildInfo from './config/buildInfo.json';\nimport { tagInfo } from '../../data/index';\n\nvar Hoot =\n/*#__PURE__*/\nfunction () {\n function Hoot() {\n _classCallCheck(this, Hoot);\n\n this.api = new API(this);\n this.message = new MessageManager(this);\n this.layers = new LayerManager(this);\n this.folders = new FolderManager(this);\n this.translations = new TranslationManager(this);\n this.events = new EventManager();\n this.config = {\n urlroot: 'http://54.165.118.78:8080/hoot-services/osm',\n tagInfo: tagInfo,\n appInfo: [],\n users: [],\n exportSizeThreshold: null,\n ingestSizeThreshold: null,\n conflateSizeThreshold: null,\n presetMaxDisplayNum: 12\n };\n }\n\n _createClass(Hoot, [{\n key: \"init\",\n value: function init(context) {\n if (this.ui && this.ui instanceof UI) return;\n this.context = context;\n Promise.all([this.getAboutData(), this.getAllUsers(), this.getMapSizeThresholds(), this.translations.getTranslations()]);\n this.ui = new UI();\n this.ui.render(); // prevent this class from being modified in any way.\n // this does not affect children objects\n\n Object.freeze(this);\n }\n }, {\n key: \"getAboutData\",\n value: function () {\n var _getAboutData = _asyncToGenerator(\n /*#__PURE__*/\n _regeneratorRuntime.mark(function _callee() {\n var _this = this;\n\n var info;\n return _regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n _context.next = 3;\n return Promise.all([this.api.getCoreVersionInfo(), this.api.getServicesVersionInfo()]);\n\n case 3:\n info = _context.sent;\n\n _forEach(info, function (d) {\n return _this.config.appInfo.push(d);\n });\n\n _context.next = 10;\n break;\n\n case 7:\n _context.prev = 7;\n _context.t0 = _context[\"catch\"](0);\n this.message.alert(_context.t0);\n\n case 10:\n // build info will always be available\n this.config.appInfo.push(buildInfo);\n\n case 11:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, this, [[0, 7]]);\n }));\n\n return function getAboutData() {\n return _getAboutData.apply(this, arguments);\n };\n }()\n }, {\n key: \"getAllUsers\",\n value: function () {\n var _getAllUsers = _asyncToGenerator(\n /*#__PURE__*/\n _regeneratorRuntime.mark(function _callee2() {\n var _this2 = this;\n\n var resp;\n return _regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n _context2.next = 3;\n return this.api.getAllUsers();\n\n case 3:\n resp = _context2.sent;\n this.config.users = {};\n\n _forEach(resp.users, function (user) {\n _this2.config.users[user.id] = user;\n });\n\n _context2.next = 11;\n break;\n\n case 8:\n _context2.prev = 8;\n _context2.t0 = _context2[\"catch\"](0);\n this.message.alert(_context2.t0);\n\n case 11:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this, [[0, 8]]);\n }));\n\n return function getAllUsers() {\n return _getAllUsers.apply(this, arguments);\n };\n }()\n }, {\n key: \"getMapSizeThresholds\",\n value: function () {\n var _getMapSizeThresholds = _asyncToGenerator(\n /*#__PURE__*/\n _regeneratorRuntime.mark(function _callee3() {\n var thresholds;\n return _regeneratorRuntime.wrap(function _callee3$(_context3) {\n while (1) {\n switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n _context3.next = 3;\n return this.api.getMapSizeThresholds();\n\n case 3:\n thresholds = _context3.sent;\n this.config.exportSizeThreshold = thresholds.export_threshold;\n this.config.ingestSizeThreshold = thresholds.ingest_threshold;\n this.config.conflateSizeThreshold = thresholds.conflate_threshold;\n _context3.next = 12;\n break;\n\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n this.message.alert(_context3.t0);\n\n case 12:\n case \"end\":\n return _context3.stop();\n }\n }\n }, _callee3, this, [[0, 9]]);\n }));\n\n return function getMapSizeThresholds() {\n return _getMapSizeThresholds.apply(this, arguments);\n };\n }()\n }]);\n\n return Hoot;\n}(); // Export this class as a \"Singleton\". When it is imported the very first time,\n// it will create a new instance of the object and store it in memory. Every other\n// import afterwards will receive this cached object, and not create a new instance.\n// * Note: This is not a true Singleton, but it mimics the Singleton pattern\n// because of Node's module caching behavior.\n\n\nexport default new Hoot();" }, { "id": null, diff --git a/test/hoot/index.js b/test/hoot/index.js index 9c1160e262..1469356c58 100644 --- a/test/hoot/index.js +++ b/test/hoot/index.js @@ -4,39 +4,39 @@ * @author Matt Putipong on 10/29/18 *******************************************************************************************************/ -let iD = require( '../../modules/index' ), - $ = require( 'jquery' ), - _ = require( 'lodash-es' ), - chai = require( 'chai' ), - sinonChai = require( 'sinon-chai' ); +let iD = require("../../modules/index"), + $ = require("jquery"), + _ = require("lodash-es"), + chai = require("chai"), + sinonChai = require("sinon-chai"); -chai.use( sinonChai ); +chai.use(sinonChai); let id = iD.Context(); -global.Hoot = id.hoot; -global.d3 = iD.d3; -global.$ = $; -global._ = _; -global.iD = iD; +global.Hoot = id.hoot; +global.d3 = iD.d3; +global.$ = $; +global._ = _; +global.iD = iD; global.expect = chai.expect; -before( () => { - localStorage.setItem( 'sawSplash', 'true' ); +before(() => { + localStorage.setItem("sawSplash", "true"); - d3.select( 'body' ) - .append( 'div' ) - .attr( 'id', 'id-container' ) - .append( 'div' ) - .attr( 'id', 'id-sink' ); + d3.select("body") + .append("div") + .attr("id", "id-container") + .append("div") + .attr("id", "id-sink"); - id.ui()( document.getElementById( 'id-sink' ) ); -} ); + id.ui()(document.getElementById("id-sink")); +}); -beforeEach( function( done ) { - setTimeout( done, 50 ); -} ); +beforeEach(function(done) { + setTimeout(done, 50); +}); -const tests = require.context( './spec/', true, /.js$/ ); +const tests = require.context("./spec/layerColorTest/", true, /.js$/); -tests.keys().forEach( tests ); +tests.keys().forEach(tests); diff --git a/test/hoot/spec/layerColorTest/layerColor.js b/test/hoot/spec/layerColorTest/layerColor.js new file mode 100644 index 0000000000..b4d3d078f5 --- /dev/null +++ b/test/hoot/spec/layerColorTest/layerColor.js @@ -0,0 +1,76 @@ +/******************************************************************************************************* + * File: layerColor.js + * Project: hootenanny-ui + * @author Jack Grossman on 11/7/18 jack.grossman@radiantsolutions.com + *******************************************************************************************************/ + +describe(" Add Dataset ", () => { + it(" opens add layer form ", done => { + d3.select("form#reference a.toggle-button").dispatch("click"); + + setTimeout(() => { + done(); + }, 1000); + }); +}); + +describe(" Active Color for New Layers ", function() { + it(" default layer color is active ", function() { + var dataColor = d3.selectAll("a.active._icon.check").attr("data-color"); + expect(dataColor).to.be.eql("violet"); + }); + + it(" layer color can be changed ", done => { + var newColor = d3 + .selectAll("a.block.float-left.keyline-right:nth-child(1)") + .attr("data-color"); + d3.selectAll("a.block.float-left.keyline-right:nth-child(1)").dispatch( + "click" + ); + + setTimeout(() => { + expect(newColor).to.be.eql("gold"); + done(); + }, 500); + }); +}); + +describe(" Secondary Dataset Form Working ", () => { + it(" closes primary dataset layer form ", done => { + d3.select("form#reference a.toggle-button").dispatch("click"); + + setTimeout(() => { + done(); + }, 1000); + }); + it(" opens secondary dataset layer form ", done => { + d3.select("form#secondary a.toggle-button").dispatch("click"); + + setTimeout(() => { + done(); + }, 1000); + }); +}); + +// describe(" loading display working ", async () => { +// it(" checks visible loading interaction ", function() { +// var loading = d3.selectAll("span.strong.padx1").text("Loading"); +// console.log(loading); +// expect(loading).to.be.eql("Loading"); +// }); +// }); + +// describe(" checks for layer added to map ", function() { +// it(" confirms layer was added to map ", {}); +// }); + +// it("checks for style color change", done => { +// expect(d3.select(".block").size()).to.equal(0); + +// d3.select(".dataset-action-button:first-child").dispatch("click"); + +// setTimeout(() => { +// expect(d3.select("#datasets-import-form").size()).to.equal(1); +// done(); +// }, 200); +// });