Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate 'test/unit_tests' to ES6 #1201

Merged
merged 31 commits into from
May 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,26 @@ globals:
CryptoJS: true
dcodeIO: true
Dexie: true
entities: true
hljs: true
jQuery: true
keyboardJS: true
ko: true
libsodium: true
lorem_ipsum: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is lorem_ipsum being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's part of the payloads.js. We might want to move this, entities and whatever is in there to a dedicated namespace in a separate PR.

LRUCache: true
marked: true
moment: true
OpenGraphMocks: true
pako: true
payload: true
platform: true
poster: true
Proteus: true
Raygun: true
sinon: true
sodium: true
TestFactory: true
twttr: true
UUID: true
wire: true
Expand Down
18 changes: 8 additions & 10 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = (grunt) => {
},
};

/* eslint-disable sort-keys */
const dir = {
app_: 'app',
app: {
Expand All @@ -57,18 +58,16 @@ module.exports = (grunt) => {
test_: 'test',
test: {
api: 'test/api',
coffee: 'test/coffee',
coverage: 'test/coverage',
js: 'test/js',
lib: 'test/lib',
unit_tests: 'test/unit_tests',
},
};

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
config,
dir,
config: config,
dir: dir,
aws_s3: require('./grunt/config/aws_s3'),
bower: require('./grunt/config/bower'),
clean: require('./grunt/config/clean'),
Expand All @@ -82,12 +81,13 @@ module.exports = (grunt) => {
less: require('./grunt/config/less'),
open: require('./grunt/config/open'),
path: require('path'),
postcss: require('./grunt/config/postcss'),
shell: require('./grunt/config/shell'),
todo: require('./grunt/config/todo'),
uglify: require('./grunt/config/uglify'),
watch: require('./grunt/config/watch'),
postcss: require('./grunt/config/postcss'),
});
/* eslint-enable sort-keys */

// Tasks
grunt.loadTasks('grunt/tasks');
Expand Down Expand Up @@ -116,29 +116,27 @@ module.exports = (grunt) => {
const scripts = grunt.config('scripts');

const prepare_file_names = (file_name_array) => {
return file_name_array.map(file_name => file_name.replace('deploy/', ''));
return file_name_array.map((file_name) => file_name.replace('deploy/', ''));
};

const helper_files = grunt.config.get('karma.options.files');
const app_files = prepare_file_names(scripts.app);
const component_files = prepare_file_names(scripts.component);
const vendor_files = prepare_file_names(scripts.vendor);
const test_files = test_name ? [`../test/js/${test_name}Spec.js`] : ['../test/**/*Spec.js'];
const test_files = test_name ? [`../test/unit_tests/${test_name}Spec.js`] : ['../test/unit_tests/**/*Spec.js'];

const files = [].concat(helper_files, vendor_files, component_files, app_files, test_files);
grunt.config('karma.options.files', files);
});

grunt.registerTask('test_init', ['prepare_dist', 'prepare_test']);
grunt.registerTask('test_init', ['prepare_dist']);

grunt.registerTask('test_run', (test_name) => {
grunt.config('karma.options.reporters', ['progress']);
grunt.task.run([
'scripts',
'newer:coffee:dist',
'newer:coffee:test',
'newer:copy:dist_js',
'copy:test',
`test_prepare:${test_name}`,
'karma:test',
]);
Expand Down
2 changes: 1 addition & 1 deletion app/script/util/ArrayUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ z.util.ArrayUtil = {

// couldn't find the item
if (current_index === -1) {
return null;
return undefined;
}

const next_index = current_index + 1;
Expand Down
1 change: 0 additions & 1 deletion grunt/config/clean.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module.exports =
docs: '<%= dir.docs %>'
docs_coverage: '<%= dir.docs.coverage %>'
ext: '<%= dir.app.ext %>/*'
test: '<%= dir.test.js %>'
temp: '<%= dir.temp %>'

###############################################################################
Expand Down
7 changes: 0 additions & 7 deletions grunt/config/coffee.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ module.exports =
ext: '.js'
src: '**/*.coffee'

test:
cwd: '<%= dir.test.unit_tests %>'
dest: '<%= dir.test.js %>'
expand: true
ext: '.js'
src: '**/*.coffee'

###############################################################################
# Production/Staging/Edge deployment related
###############################################################################
Expand Down
6 changes: 0 additions & 6 deletions grunt/config/copy.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ module.exports =
expand: true
src: 'favicon.ico'

test:
cwd: '<%= dir.test.unit_tests %>'
dest: '<%= dir.test.js %>'
expand: true
src: '**/*.js'

###############################################################################
# Prod/Staging/Edge deployment related
###############################################################################
Expand Down
8 changes: 0 additions & 8 deletions grunt/config/watch.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,3 @@ module.exports =
templates:
files: '<%= dir.app_ %>/**/*.htm*'
tasks: ['prepare_template']

test:
files: '<%= dir.test_ %>/**/*.coffee'
tasks: ['coffee:test', 'karma']

test_js:
files: '<%= dir.test_ %>/**/*.js'
tasks: ['copy:test', 'karma']
6 changes: 0 additions & 6 deletions grunt/tasks/misc.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@ module.exports = (grunt) ->
'clean:prod'
]

grunt.registerTask 'prepare_test', [
'clean:test'
'copy:test'
'coffee:test'
]

grunt.registerTask 'check', (file) ->
grunt.log.writeln '=== ' + grunt.task.current.name.toUpperCase() + ' ==='

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"deploy-travis-prod": "grunt app_deploy_travis:prod",
"deploy-travis-staging": "grunt app_deploy_travis:staging",
"lint": "yarn lint-scripts && yarn lint-styles",
"lint-scripts": "eslint -c .eslintrc.yaml --ignore-path .gitignore --quiet app/script/ test/ bin/ grunt/",
"lint-scripts": "eslint -c .eslintrc.yaml --ignore-path .gitignore --quiet app/script/ test/ bin/ grunt/ Gruntfile.js",
"lint-styles": "stylelint app/style/**/*.less --syntax less",
"postinstall": "grunt init",
"start": "grunt",
Expand Down
Loading