├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .travis.yml ├── AUTHORS.md ├── CONTRIBUTING.md ├── GruntFile.js ├── README.md ├── app ├── index.js └── templates │ ├── .jshintrc │ ├── _spec.js │ ├── _specJasmine.js │ ├── _template.html │ ├── _test_page.html │ ├── _widget.css │ ├── _widget.js │ ├── _widget.ts │ └── tests.css ├── docs └── images │ └── yo-esri-widget.png ├── generator-dojo-widget.sublime-project ├── package.json └── test ├── test-creation.js └── test-load.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | *.sublime-workspace 4 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esnext": true, 4 | "bitwise": true, 5 | "camelcase": true, 6 | "curly": true, 7 | "devel": true, 8 | "eqeqeq": true, 9 | "eqnull": true, 10 | "es3": true, 11 | "forin": true, 12 | "gcl": true, 13 | "immed": true, 14 | "indent": 4, 15 | "jquery": true, 16 | "latedef": true, 17 | "maxcomplexity": 10, 18 | "maxerr": 250, 19 | "maxlen": 120, 20 | "newcap": true, 21 | "noarg": true, 22 | "noempty": true, 23 | "quotmark": "single", 24 | "trailing": true, 25 | "undef": true, 26 | "unused": true 27 | } 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.10' 4 | before_install: 5 | - currentfolder=${PWD##*/} 6 | - if [ "$currentfolder" != 'generator-esri-widget' ]; then cd .. && eval "mv $currentfolder generator-esri-widget" && cd generator-esri-widget; fi 7 | 8 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | Tom Wayson (https://github.com/tomwayson) -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | We welcome contributions from anyone and everyone. Please see the Esri [guidelines for contributing](https://github.com/esri/contributing). -------------------------------------------------------------------------------- /GruntFile.js: -------------------------------------------------------------------------------- 1 | /* 2 | * generator-esri-widget 3 | * github.com/tomwayson/generator-esri-widget 4 | * 5 | * Copyright (c) 2014 steveoh 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = function(grunt) { 12 | // Project configuration. 13 | grunt.initConfig({ 14 | bump: { 15 | options: { 16 | pushTo: 'origin', 17 | commit: true 18 | } 19 | } 20 | }); 21 | 22 | grunt.loadNpmTasks('grunt-bump'); 23 | }; 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generator-esri-widget [![Build Status](https://secure.travis-ci.org/tomwayson/generator-esri-widget.png?branch=master)](https://travis-ci.org/tomwayson/generator-esri-widget) 2 | 3 | > [Yeoman](http://yeoman.io) generator to create custom Dojo widgets for Esri web applications. 4 | 5 | **Not to be confused with [Esri/generator-esri-appbuilder-js](http://github.com/Esri/generator-esri-appbuilder-js) which scaffolds out widgets specifically for the ArcGIS Web AppBuilder** 6 | 7 | ## About 8 | 9 | This generator scaffolds out the boilerplate files that are need each time you create a new custom Dojo widget for a web application using Esri's ArcGIS API for JavaScript. 10 | 11 | ![Screenshot](https://raw.githubusercontent.com/tomwayson/generator-esri-widget/master/docs/images/yo-esri-widget.png) 12 | 13 | This generator was stolen forked and adapted from [@steveoh](https://github.com/steveoh)'s [generator-dojo-widget](https://github.com/steveoh/generator-dojo-widget). I've been using that generator for a while now, and it does an excellent job of scaffolding out the files needed for a Dojo widget. However, I found myself making the same changes to those files each time I ran it, so I wanted to change the generator so that it would: 14 | 15 | * Include a map in the test page by default 16 | * Write the spec tests with [mocha] instead of [jasmine](http://jasmine.github.io/) 17 | * Indent using 2 spaces instead of 4 for .js files, 'cause a hata's gotta hate. 18 | 19 | Since these are *my* preferences and I didn't think that they would make their way back into the original generator, I decided to make my fork its own source with a new name - with nothing but love and respect for [@steveoh](https://github.com/steveoh). 20 | 21 | ## Getting Started 22 | 23 | ### Installation 24 | 25 | To install Yeoman from npm (if not already), run: 26 | 27 | ```bash 28 | $ npm install -g yo 29 | ``` 30 | 31 | To install generator-esri-widget from npm, run: 32 | 33 | ```bash 34 | $ npm install -g generator-esri-widget 35 | ``` 36 | 37 | ### Running the Generator 38 | 39 | Navigate to your application's root folder and run the following at the command line: 40 | 41 | ``` 42 | $ yo esri-widget 43 | ``` 44 | 45 | A few opinionated files will be created. If you created a widget called `test` in the `app` folder, the following files will be created for you. 46 | 47 | 'app/test.js', 48 | 'app/templates/test.html', 49 | 'app/tests/testTests.html', 50 | 'app/tests/spec/Spectest.js', 51 | 'app/resources/test.css' 52 | 53 | The `/test.js` file will contain your widget logic. 54 | `/templates/test.html` will be an empty template file if your widget has a template. 55 | `tests/testTests.html` is an html page that you can load to see your widget in isolation. 56 | `tests/spec/Spectest.js` is a [mocha] test spec file with a default test instantiating your new widget. 57 | `tests/test.css` is the style sheet containing styles specific to your new widget. 58 | `resources/test.css` is the style sheet containing styles specific to your new widget. 59 | 60 | ## License 61 | 62 | MIT 63 | 64 | [mocha]:http://mochajs.org/ 65 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var yeoman = require('yeoman-generator'); 3 | var chalk = require('chalk'); 4 | 5 | var DojoWidgetGenerator = yeoman.generators.Base.extend({ 6 | askFor: function() { 7 | var done = this.async(); 8 | 9 | var testPageMapChoices = [ 'No map', 'Empty map - i.e. new Map()', 'Web map - i.e. arcgisUtils.createMap()' ]; 10 | 11 | var languageChoices = [ 'JavaScript', 'TypeScript']; 12 | 13 | var testingFrameworks = [ 'Jasmine', 'Mocha']; 14 | 15 | // have Yeoman greet the user 16 | console.log(this.yeoman); 17 | 18 | // replace it with a short and sweet description of your generator 19 | console.log(chalk.magenta('Welcome to the esri-widget generator.')); 20 | console.log(chalk.green('It is best to run this widget from the parent folder of your package.')); 21 | console.log(chalk.green('So like the', chalk.underline.bgWhite('/src') + ' folder')); 22 | 23 | var prompts = [{ 24 | name: 'widgetName', 25 | message: 'Widget Name:', 26 | 'default': 'Widget' 27 | }, { 28 | name: 'description', 29 | message: 'Description:' 30 | }, { 31 | name: 'path', 32 | message: 'Path to widget:', 33 | 'default': 'app' 34 | }, { 35 | type: 'confirm', 36 | name: 'widgetsInTemplate', 37 | message: 'Will the template contain other widgets?', 38 | 'default': true 39 | }, { 40 | type: 'list', 41 | name: 'testPageMap', 42 | message: 'What kind of map would you like in the test page?', 43 | choices: testPageMapChoices, 44 | 'default': 0 45 | },{ 46 | type: 'list', 47 | name: 'languageChoice', 48 | message: 'What language would you like to use?', 49 | choices: languageChoices, 50 | 'default': 0 51 | },{ 52 | type: 'list', 53 | name: 'testFramwork', 54 | message: 'What test framework would you like to use?', 55 | choices: testingFrameworks, 56 | 'default': 0 57 | }]; 58 | 59 | this.prompt(prompts, function(props) { 60 | this.widgetName = props.widgetName; 61 | this.description = props.description; 62 | this.path = props.path + '/'; 63 | this.widgetsInTemplate = props.widgetsInTemplate; 64 | this.testPageMap = testPageMapChoices.indexOf(props.testPageMap); 65 | this.language = languageChoices.indexOf(props.languageChoice); 66 | this.testFramework = testingFrameworks.indexOf(props.testFramwork); 67 | this.consoleLog = this.path + this.widgetName; 68 | this.consoleLog = this.consoleLog.replace(/\//g, '.'); 69 | var splitPath = this.path.split('/'); 70 | this.packageName = splitPath[0]; 71 | this.testPageBaseUrl = ''; 72 | for (var x = 0; x < splitPath.length; x++) { 73 | this.testPageBaseUrl += '../'; 74 | } 75 | done(); 76 | }.bind(this)); 77 | }, 78 | 79 | app: function() { 80 | this.copy('tests.css', this.path + 'tests/tests.css'); 81 | var ext = (this.language === 0) ? '.js' : '.ts'; 82 | this.template('_widget' + ext, this.path + this.widgetName + ext); 83 | this.template('_template.html', this.path + 'templates/' + this.widgetName + '.html'); 84 | this.template('_test_page.html', this.path + 'tests/' + this.widgetName + 'Test.html'); 85 | if(this.testFramework === 0) { 86 | //Jasmine 87 | this.template('_specJasmine.js', this.path + 'tests/spec/' + this.widgetName + 'Spec.js'); 88 | } else{ 89 | this.template('_spec.js', this.path + 'tests/spec/' + this.widgetName + 'Spec.js'); 90 | } 91 | 92 | this.template('_widget.css', this.path + 'resources/' + this.widgetName + '.css'); 93 | }, 94 | 95 | projectfiles: function() { 96 | 97 | } 98 | }); 99 | 100 | module.exports = DojoWidgetGenerator; -------------------------------------------------------------------------------- /app/templates/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | strict: false 3 | } -------------------------------------------------------------------------------- /app/templates/_spec.js: -------------------------------------------------------------------------------- 1 | define([ 2 | '<%= path %><%= widgetName %>', 3 | 4 | 'dojo/dom-construct' 5 | ], function( 6 | WidgetUnderTest, 7 | 8 | domConstruct 9 | ) { 10 | describe('<%= path %><%= widgetName %>', function() { 11 | var widget; 12 | var destroy = function (widget) { 13 | if (widget && widget.destroyRecursive) { 14 | widget.destroyRecursive(); 15 | widget = null; 16 | } 17 | }; 18 | 19 | beforeEach(function() { 20 | widget = new WidgetUnderTest(null, domConstruct.create('div', null, document.body)); 21 | }); 22 | 23 | afterEach(function() { 24 | destroy(widget); 25 | }); 26 | 27 | describe('Sanity', function() { 28 | it('should create a <%= widgetName %>', function() { 29 | expect(widget).to.be.a(WidgetUnderTest); 30 | }); 31 | }); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /app/templates/_specJasmine.js: -------------------------------------------------------------------------------- 1 | define([ 2 | '<%= path %><%= widgetName %>', 3 | 4 | 'dojo/dom-construct' 5 | ], function ( 6 | WidgetUnderTest, 7 | 8 | domConstruct 9 | ) { 10 | describe('<%= path %><%= widgetName %>', function () { 11 | var widget; 12 | var destroy = function (widget) { 13 | widget.destroyRecursive(); 14 | widget = null; 15 | }; 16 | 17 | beforeEach(function () { 18 | widget = new WidgetUnderTest(null, domConstruct.create('div', null, document.body)); 19 | widget.startup(); 20 | }); 21 | 22 | afterEach(function () { 23 | if (widget) { 24 | destroy(widget); 25 | } 26 | }); 27 | 28 | describe('Sanity', function () { 29 | it('should create a <%= widgetName %>', function () { 30 | expect(widget).toEqual(jasmine.any(WidgetUnderTest)); 31 | }); 32 | }); 33 | }); 34 | }); -------------------------------------------------------------------------------- /app/templates/_template.html: -------------------------------------------------------------------------------- 1 |
2 |

<%= widgetName %>

3 |

<%= description %>

4 |
-------------------------------------------------------------------------------- /app/templates/_test_page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <%= widgetName %> Tests 7 | 8 | 14 | 15 | 16 |
17 |
18 |
19 |
20 | 21 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /app/templates/_widget.css: -------------------------------------------------------------------------------- 1 | .<%= _.dasherize(widgetName).slice(1) %> { 2 | 3 | } -------------------------------------------------------------------------------- /app/templates/_widget.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'dojo/text!./templates/<%=widgetName%>.html', 3 | 4 | 'dojo/_base/declare', 5 | 6 | 'dijit/_WidgetBase',<% if(widgetsInTemplate) { %> 7 | 'dijit/_TemplatedMixin', 8 | 'dijit/_WidgetsInTemplateMixin'<% } else { %> 9 | 'dijit/_TemplatedMixin'<%}%> 10 | ], function( 11 | template, 12 | 13 | declare, 14 | 15 | _WidgetBase,<% if(widgetsInTemplate) { %> 16 | _TemplatedMixin, 17 | _WidgetsInTemplateMixin<% } else { %> 18 | _TemplatedMixin<%}%> 19 | ) {<% if(widgetsInTemplate) { %> 20 | return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {<% } else { %> 21 | return declare([_WidgetBase, _TemplatedMixin], {<%}%> 22 | // description: 23 | // <%= description %> 24 | 25 | templateString: template, 26 | baseClass: '<%= _.dasherize(widgetName).slice(1) %>',<% if(widgetsInTemplate) { %> 27 | widgetsInTemplate: true,<% }%> 28 | 29 | // Properties to be sent into constructor 30 | 31 | postCreate: function() { 32 | // summary: 33 | // Overrides method of same name in dijit._Widget. 34 | // tags: 35 | // private 36 | console.log('<%= consoleLog %>::postCreate', arguments); 37 | 38 | this.setupConnections(); 39 | 40 | this.inherited(arguments); 41 | }, 42 | setupConnections: function() { 43 | // summary: 44 | // wire events, and such 45 | // 46 | console.log('<%= consoleLog %>::setupConnections', arguments); 47 | 48 | } 49 | }); 50 | }); -------------------------------------------------------------------------------- /app/templates/_widget.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | declare var template: any; 4 | 5 | //dojo 6 | import dojoDeclare = require("dojo/_base/declare"); 7 | 8 | //dijit 9 | import WidgetBase = require("dijit/_WidgetBase"); 10 | import TemplatedMixin = require("dijit/_TemplatedMixin"); 11 | <% if(widgetsInTemplate) { %>import WidgetsInTemplateMixin = require("dijit/_WidgetsInTemplateMixin"); <% }%> 12 | 13 | interface WidgetInterface { 14 | constructor(options: any); 15 | startup(); 16 | baseClass: string; 17 | } 18 | 19 | var clazz = dojoDeclare([WidgetBase, TemplatedMixin<% if(widgetsInTemplate) { %>, WidgetsInTemplateMixin<% }%>], { 20 | 21 | // description: 22 | // <%= description %> 23 | 24 | <% if(widgetsInTemplate) { %>templateString: template,<% }%> 25 | baseClass: '<%= _.dasherize(widgetName).slice(1) %>', 26 | 27 | constructor(options: any) { 28 | }, 29 | 30 | startup: function (args) { 31 | //Not allowed in option strict this.inherited(arguments); 32 | <% if(widgetsInTemplate) { %>WidgetsInTemplateMixin.prototype.startup.call(this, args);<% } 33 | else { %>TemplatedMixin.prototype.startup.call(this, args);<%}%> 34 | 35 | var self: WidgetInterface = this; 36 | console.log(self.baseClass + '::startup', args); 37 | 38 | } 39 | 40 | }) 41 | 42 | export = clazz; -------------------------------------------------------------------------------- /app/templates/tests.css: -------------------------------------------------------------------------------- 1 | html, body, #map { 2 | height: 100%; 3 | width: 100%; 4 | margin: 0; 5 | padding: 0; 6 | } 7 | body { 8 | background-color: #FFF; 9 | overflow: hidden; 10 | font-family: "Trebuchet MS"; 11 | } 12 | #widgetContainer { 13 | position: absolute; 14 | top: 20px; 15 | right: 20px; 16 | padding: 10px; 17 | background: #fff; 18 | } 19 | -------------------------------------------------------------------------------- /docs/images/yo-esri-widget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomwayson/generator-esri-widget/0e66ed318f50a6312e821648309bebe1091f80c3/docs/images/yo-esri-widget.png -------------------------------------------------------------------------------- /generator-dojo-widget.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "folder_exclude_patterns": [ 6 | "node_modules" 7 | ], 8 | "file_exclude_patterns": [ 9 | "*.sublime-workspace", 10 | "*.sublime-project" 11 | ], 12 | "follow_symlinks": true, 13 | "path": "." 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-esri-widget", 3 | "version": "0.4.0", 4 | "description": "Yeoman generator for creating Esri widgets", 5 | "license": "MIT", 6 | "main": "app/index.js", 7 | "repository": "tomwayson/generator-esri-widget", 8 | "author": { 9 | "name": "Tom Wayson", 10 | "email": "tom@tomwayson.com", 11 | "url": "https://github.com/tomwayson" 12 | }, 13 | "engines": { 14 | "node": ">=0.10.0" 15 | }, 16 | "scripts": { 17 | "test": "mocha" 18 | }, 19 | "files": [ 20 | "app" 21 | ], 22 | "keywords": [ 23 | "yeoman-generator", 24 | "esri", 25 | "dojo", 26 | "widget" 27 | ], 28 | "dependencies": { 29 | "chalk": "*", 30 | "yeoman-generator": "^0.17.0" 31 | }, 32 | "devDependencies": { 33 | "grunt": "~0.4", 34 | "grunt-bump": "0.0.14", 35 | "mocha": "*" 36 | }, 37 | "peerDependencies": { 38 | "yo": ">=1.0.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test/test-creation.js: -------------------------------------------------------------------------------- 1 | /*global describe, beforeEach, it */ 2 | 'use strict'; 3 | var path = require('path'); 4 | var helpers = require('yeoman-generator').test; 5 | 6 | describe('esri-widget generator', function() { 7 | 8 | var expectedFiles; 9 | 10 | before(function() { 11 | expectedFiles = [ 12 | // add files you expect to exist here. 13 | 'app/test.js', 14 | 'app/templates/test.html', 15 | 'app/tests/tests.css', 16 | 'app/tests/testTest.html', 17 | 'app/tests/spec/testSpec.js', 18 | 'app/resources/test.css' 19 | ]; 20 | }); 21 | 22 | beforeEach(function(done) { 23 | helpers.testDirectory(path.join(__dirname, 'temp'), function(err) { 24 | if (err) { 25 | return done(err); 26 | } 27 | 28 | this.app = helpers.createGenerator('esri-widget:app', [ 29 | '../../app' 30 | ]); 31 | done(); 32 | }.bind(this)); 33 | }); 34 | 35 | it('creates expected files and defaults to no map', function(done) { 36 | 37 | helpers.mockPrompt(this.app, { 38 | 'widgetName': 'test', 39 | 'description': 'test description', 40 | 'path': 'app', 41 | 'widgetsInTemplate': true, 42 | 'languageChoice': 'JavaScript', 43 | 'testFramwork' : 'Jasmine' 44 | }); 45 | 46 | this.app.options['skip-install'] = true; 47 | this.app.run({}, function() { 48 | helpers.assertFile(expectedFiles); 49 | // by default, don't include a map in the test page 50 | helpers.assertNoFileContent('app/tests/testTest.html', /map\W?=/); 51 | done(); 52 | }); 53 | }); 54 | 55 | it('creates an empty map with new Map()', function(done) { 56 | 57 | helpers.mockPrompt(this.app, { 58 | 'widgetName': 'test', 59 | 'description': 'test description', 60 | 'path': 'app', 61 | 'widgetsInTemplate': true, 62 | 'testPageMap': 'Empty map - i.e. new Map()', 63 | 'languageChoice': 'JavaScript', 64 | 'testFramwork' : 'Jasmine' 65 | }); 66 | 67 | this.app.options['skip-install'] = true; 68 | this.app.run({}, function() { 69 | helpers.assertFile(expectedFiles); 70 | // create empty map in the test page 71 | helpers.assertFileContent('app/tests/testTest.html', /map\W?=\W?new Map\(/); 72 | done(); 73 | }); 74 | }); 75 | 76 | it('creates a map from a web map', function(done) { 77 | 78 | helpers.mockPrompt(this.app, { 79 | 'widgetName': 'test', 80 | 'description': 'test description', 81 | 'path': 'app', 82 | 'widgetsInTemplate': true, 83 | 'testPageMap': 'Web map - i.e. arcgisUtils.createMap()', 84 | 'languageChoice': 'JavaScript', 85 | 'testFramwork' : 'Jasmine' 86 | }); 87 | 88 | this.app.options['skip-install'] = true; 89 | this.app.run({}, function() { 90 | helpers.assertFile(expectedFiles); 91 | // create empty map in the test page 92 | helpers.assertFileContent('app/tests/testTest.html', /map\W?=\W?response\.map;/); 93 | done(); 94 | }); 95 | }); 96 | 97 | it('creates a TypeScript Widget when run in TS mode', function(done) { 98 | 99 | helpers.mockPrompt(this.app, { 100 | 'widgetName': 'test', 101 | 'description': 'test description', 102 | 'path': 'app', 103 | 'widgetsInTemplate': true, 104 | 'testPageMap': 'Web map - i.e. arcgisUtils.createMap()', 105 | 'languageChoice': 'TypeScript', 106 | 'testFramwork' : 'Jasmine' 107 | }); 108 | 109 | this.app.options['skip-install'] = true; 110 | this.app.run({}, function() { 111 | var expectedFilesTs = [ 112 | // expected files for TS 113 | 'app/test.ts', 114 | 'app/templates/test.html', 115 | 'app/tests/tests.css', 116 | 'app/tests/testTest.html', 117 | 'app/tests/spec/testSpec.js', 118 | 'app/resources/test.css' 119 | ]; 120 | helpers.assertFile(expectedFilesTs); 121 | done(); 122 | }); 123 | }); 124 | 125 | it('creates a Jasmine test', function(done) { 126 | 127 | helpers.mockPrompt(this.app, { 128 | 'widgetName': 'test', 129 | 'description': 'test description', 130 | 'path': 'app', 131 | 'widgetsInTemplate': true, 132 | 'testPageMap': 'Web map - i.e. arcgisUtils.createMap()', 133 | 'languageChoice': 'JavaScript', 134 | 'testFramwork' : 'Jasmine' 135 | }); 136 | 137 | this.app.options['skip-install'] = true; 138 | this.app.run({}, function() { 139 | helpers.assertFile(expectedFiles); 140 | // check the file is a jasmine file 141 | helpers.assertFileContent('app/tests/spec/testSpec.js', /jasmine\W/); 142 | done(); 143 | }); 144 | }); 145 | 146 | it('creates a Mocha test', function(done) { 147 | 148 | helpers.mockPrompt(this.app, { 149 | 'widgetName': 'test', 150 | 'description': 'test description', 151 | 'path': 'app', 152 | 'widgetsInTemplate': true, 153 | 'testPageMap': 'Web map - i.e. arcgisUtils.createMap()', 154 | 'languageChoice': 'JavaScript', 155 | 'testFramwork' : 'Mocha' 156 | }); 157 | 158 | this.app.options['skip-install'] = true; 159 | this.app.run({}, function() { 160 | helpers.assertFile(expectedFiles); 161 | // check the file is a Mocha file. Is there a better way to test this? 162 | helpers.assertFileContent('app/tests/spec/testSpec.js', /.to.be.a\W/); 163 | done(); 164 | }); 165 | }); 166 | 167 | }); 168 | -------------------------------------------------------------------------------- /test/test-load.js: -------------------------------------------------------------------------------- 1 | /*global describe, it*/ 2 | 'use strict'; 3 | var assert = require('assert'); 4 | 5 | describe('esri-widget generator', function () { 6 | it('can be imported without blowing up', function () { 7 | var app = require('../app'); 8 | assert(app !== undefined); 9 | }); 10 | }); 11 | --------------------------------------------------------------------------------