From 2acabc4b7d43aaa70f429ff744c66ebdfa412c24 Mon Sep 17 00:00:00 2001 From: Kevin van Zonneveld Date: Wed, 20 Jan 2016 11:21:33 +0100 Subject: [PATCH] Make tests adhere to standard --- .eslintrc | 4 ++-- package.json | 4 ++-- src/locale/ru.js | 4 ++-- test/core.spec.js | 30 +++++++++++++++--------------- test/index.js | 4 ++-- test/spec/fakeBlob.js | 10 +++++----- test/spec/uppy.js | 10 +++++----- test/translator.spec.js | 34 +++++++++++++++++----------------- 8 files changed, 50 insertions(+), 50 deletions(-) diff --git a/.eslintrc b/.eslintrc index 37744e9c8..943c7b770 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,10 +2,10 @@ "extends": "standard", "env": { "browser": true, - "node": false, + "node": false }, "globals": { - "Uppy": true, + "window": false }, "rules": { "key-spacing": [2, { "align": "colon" }], diff --git a/package.json b/package.json index 1a245193f..aef06f17c 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,8 @@ "build": "npm run build:lib && npm run build:umd && npm run build:umd:min && npm run build:css", "clean": "rm -rf lib && rm -rf dist", "docs": "cd website && node build-documentation.js", - "lint": "eslint src/**/*.js website/src/examples/*/*.es6", - "fix": "eslint src/**/*.js website/src/examples/*/*.es6 --fix", + "lint": "eslint src/**/*.js src/*.js test/*.js test/spec/*.js website/src/examples/*/*.es6", + "fix": "eslint src/**/*.js src/*.js test/*.js test/spec/*.js website/src/examples/*/*.es6 --fix", "server": "browser-sync start --config .browsersync.js", "start": "npm run build && npm run web", "test:phantom": "zuul test/spec/upload.js --phantom", diff --git a/src/locale/ru.js b/src/locale/ru.js index c3f935e23..34ed688db 100644 --- a/src/locale/ru.js +++ b/src/locale/ru.js @@ -23,8 +23,8 @@ ru.pluralize = function (n) { return 2 } -if (typeof Uppy !== 'undefined') { - Uppy.locale.ru = ru +if (typeof window.Uppy !== 'undefined') { + window.Uppy.locale.ru = ru } export default ru diff --git a/test/core.spec.js b/test/core.spec.js index f7a1481fb..5070dc3f9 100644 --- a/test/core.spec.js +++ b/test/core.spec.js @@ -1,22 +1,22 @@ -var test = require('tape'); -var Core = require('../src/core/index.js'); +var test = require('tape') +var Core = require('../src/core/index.js') test('core object', function (t) { - const core = new Core(); - t.equal(typeof core, 'object', 'new Core() should return an object'); - t.end(); -}); + const core = new Core() + t.equal(typeof core, 'object', 'new Core() should return an object') + t.end() +}) test('core type', function (t) { - const core = new Core(); - t.equal(core.type, 'core', 'core.type should equal core'); - t.end(); -}); + const core = new Core() + t.equal(core.type, 'core', 'core.type should equal core') + t.end() +}) test('translation', function (t) { - const russianDict = require('../src/locale/ru_RU.json'); - const core = new Core({locale: russianDict}); + const russianDict = require('../src/locale/ru_RU.json') + const core = new Core({locale: russianDict}) - t.equal(core.translate('Choose a file'), 'Выберите файл', 'should return translated string'); - t.end(); -}); + t.equal(core.translate('Choose a file'), 'Выберите файл', 'should return translated string') + t.end() +}) diff --git a/test/index.js b/test/index.js index 47d62126c..218edcef2 100644 --- a/test/index.js +++ b/test/index.js @@ -1,4 +1,4 @@ require('babel/register')({ stage: 0 -}); -require('./translate.spec.js'); +}) +require('./translate.spec.js') diff --git a/test/spec/fakeBlob.js b/test/spec/fakeBlob.js index 790228829..b964dd8ce 100644 --- a/test/spec/fakeBlob.js +++ b/test/spec/fakeBlob.js @@ -3,15 +3,15 @@ * * @param {Array} blob */ -function FakeBlob(blob) { +function FakeBlob (blob) { this._blob = blob this.size = blob.length } -FakeBlob.prototype.slice = function(start, end) { +FakeBlob.prototype.slice = function (start, end) { return new FakeBlob(this._blob.slice(start, end)) } -FakeBlob.prototype.stringify = function() { - return this._blob.join("") -} \ No newline at end of file +FakeBlob.prototype.stringify = function () { + return this._blob.join('') +} diff --git a/test/spec/uppy.js b/test/spec/uppy.js index a15a7f122..c35f93c42 100644 --- a/test/spec/uppy.js +++ b/test/spec/uppy.js @@ -1,7 +1,7 @@ -if (typeof require == "function") { - require("../lib/mock-ajax.js") +if (typeof require === 'function') { + require('../lib/mock-ajax.js') } -describe("transloadit-client-js", function() { - -}) +// describe('transloadit-client-js', function () { +// +// }) diff --git a/test/translator.spec.js b/test/translator.spec.js index 11835ac9e..16f23d14c 100644 --- a/test/translator.spec.js +++ b/test/translator.spec.js @@ -1,41 +1,41 @@ -var test = require('tape'); -var Core = require('../src/core/index.js'); +var test = require('tape') +var Core = require('../src/core/index.js') test('russian translation', function (t) { - const russian = require('../src/locale/ru.js'); - const core = new Core({locale: russian}); + const russian = require('../src/locale/ru.js') + const core = new Core({locale: russian}) t.equal( core.translator.t('choose_file'), 'Выберите файл', 'should return translated string' - ); + ) - t.end(); -}); + t.end() +}) test('interpolation', function (t) { - const english = require('../src/locale/en_US.js'); - const core = new Core({locale: english}); + const english = require('../src/locale/en_US.js') + const core = new Core({locale: english}) t.equal( core.translator.t('you_have_chosen', {'file_name': 'img.jpg'}), 'You have chosen: img.jpg', 'should return interpolated string' - ); + ) - t.end(); -}); + t.end() +}) test('pluralization', function (t) { - const russian = require('../src/locale/ru.js'); - const core = new Core({locale: russian}); + const russian = require('../src/locale/ru.js') + const core = new Core({locale: russian}) t.equal( core.translator.t('files_chosen', {'smart_count': '18'}), 'Выбрано 18 файлов', 'should return interpolated & pluralized string' - ); + ) - t.end(); -}); + t.end() +})