Skip to content

Commit

Permalink
Run lebab on test folder: convert let/const and arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Aug 28, 2019
1 parent 531ddc5 commit e67fa19
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 123 deletions.
74 changes: 37 additions & 37 deletions test/Node.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
var assert = require('assert')
var setUpTestEnvironment = require('./setup')
const assert = require('assert')
const setUpTestEnvironment = require('./setup')
setUpTestEnvironment()

var Node = require('../src/js/Node')
const Node = require('../src/js/Node')

describe('Node', function () {
describe('_findSchema', function () {
it('should find schema', function () {
var schema = {
describe('Node', () => {
describe('_findSchema', () => {
it('should find schema', () => {
const schema = {
type: 'object',
properties: {
child: {
type: 'string'
}
}
}
var path = ['child']
const path = ['child']
assert.strictEqual(Node._findSchema(schema, {}, path), schema.properties.child)
})

it('should find schema inside an array item', function () {
var schema = {
it('should find schema inside an array item', () => {
const schema = {
properties: {
job: {
type: 'array',
Expand All @@ -47,8 +47,8 @@ describe('Node', function () {
schema.properties.job.items.properties.company)
})

it('should find schema within multi-level object properties', function () {
var schema = {
it('should find schema within multi-level object properties', () => {
const schema = {
type: 'object',
properties: {
levelTwo: {
Expand All @@ -66,7 +66,7 @@ describe('Node', function () {
}
}
}
var path = []
let path = []
assert.strictEqual(Node._findSchema(schema, {}, path), schema)
path = ['levelTwo']
assert.strictEqual(Node._findSchema(schema, {}, path), schema.properties.levelTwo)
Expand All @@ -79,8 +79,8 @@ describe('Node', function () {
)
})

it('should return null for path that has no schema', function () {
var schema = {
it('should return null for path that has no schema', () => {
const schema = {
type: 'object',
properties: {
foo: {
Expand All @@ -93,34 +93,34 @@ describe('Node', function () {
}
}
}
var path = ['bar']
let path = ['bar']
assert.strictEqual(Node._findSchema(schema, {}, path), null)
path = ['foo', 'bar']
assert.strictEqual(Node._findSchema(schema, {}, path), null)
})

describe('with $ref', function () {
it('should find a referenced schema', function () {
var schema = {
describe('with $ref', () => {
it('should find a referenced schema', () => {
const schema = {
type: 'object',
properties: {
foo: {
$ref: 'foo'
}
}
}
var fooSchema = {
const fooSchema = {
type: 'number',
title: 'Foo'
}
var path = ['foo']
const path = ['foo']
assert.strictEqual(Node._findSchema(schema, { foo: fooSchema }, path), fooSchema)
})
})

describe('with pattern properties', function () {
it('should find schema', function () {
var schema = {
describe('with pattern properties', () => {
it('should find schema', () => {
const schema = {
type: 'object',
properties: {
str: {
Expand All @@ -135,14 +135,14 @@ describe('Node', function () {
}
}
}
var path = []
let path = []
assert.strictEqual(Node._findSchema(schema, {}, path), schema, 'top level')
path = ['str']
assert.strictEqual(Node._findSchema(schema, {}, path), schema.properties.str, 'normal property')
})

it('should find schema within multi-level object properties', function () {
var schema = {
it('should find schema within multi-level object properties', () => {
const schema = {
type: 'object',
properties: {
levelTwo: {
Expand All @@ -167,7 +167,7 @@ describe('Node', function () {
}
}
}
var path = []
let path = []
assert.strictEqual(Node._findSchema(schema, {}, path), schema, 'top level')
path = ['levelTwo']
assert.strictEqual(Node._findSchema(schema, {}, path), schema.properties.levelTwo, 'level two')
Expand All @@ -181,8 +181,8 @@ describe('Node', function () {
)
})

it('should find schema for pattern properties', function () {
var schema = {
it('should find schema for pattern properties', () => {
const schema = {
type: 'object',
patternProperties: {
'^foo[0-9]': {
Expand All @@ -195,7 +195,7 @@ describe('Node', function () {
}
}
}
var path = ['foo1']
let path = ['foo1']
assert.strictEqual(
Node._findSchema(schema, {}, path),
schema.patternProperties['^foo[0-9]'],
Expand All @@ -209,8 +209,8 @@ describe('Node', function () {
)
})

it('should find schema for multi-level pattern properties', function () {
var schema = {
it('should find schema for multi-level pattern properties', () => {
const schema = {
type: 'object',
patternProperties: {
'^foo[0-9]': {
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('Node', function () {
}
}
}
var path = ['foo1', 'fooChild', 'fooChild2']
let path = ['foo1', 'fooChild', 'fooChild2']
assert.strictEqual(
Node._findSchema(schema, {}, path),
schema.patternProperties['^foo[0-9]'].properties.fooChild.properties.fooChild2,
Expand All @@ -253,8 +253,8 @@ describe('Node', function () {
)
})

it('should return null for path that has no schema', function () {
var schema = {
it('should return null for path that has no schema', () => {
const schema = {
type: 'object',
properties: {
levelTwo: {
Expand All @@ -277,7 +277,7 @@ describe('Node', function () {
}
}
}
var path = ['not-in-schema']
let path = ['not-in-schema']
assert.strictEqual(Node._findSchema(schema, {}, path), null)
path = ['levelOne', 'not-in-schema']
assert.strictEqual(Node._findSchema(schema, {}, path), null)
Expand Down
26 changes: 13 additions & 13 deletions test/jsonUtils.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var assert = require('assert')
var stringifyPartial = require('../src/js/jsonUtils').stringifyPartial
var containsArray = require('../src/js/jsonUtils').containsArray
const assert = require('assert')
const stringifyPartial = require('../src/js/jsonUtils').stringifyPartial
const containsArray = require('../src/js/jsonUtils').containsArray

describe('jsonUtils', function () {
it('should stringify a small object', function () {
var json = {
describe('jsonUtils', () => {
it('should stringify a small object', () => {
const json = {
a: 2,
b: 'foo',
c: null,
Expand All @@ -16,8 +16,8 @@ describe('jsonUtils', function () {
assert.strictEqual(stringifyPartial(json), '{"a":2,"b":"foo","c":null,"d":false,"e":[1,2,3],"f":{"g":"h"}}')
})

it('should stringify a small object with formatting', function () {
var json = {
it('should stringify a small object with formatting', () => {
const json = {
a: 2,
b: 'foo',
c: null,
Expand Down Expand Up @@ -58,8 +58,8 @@ describe('jsonUtils', function () {
'}')
})

it('should limit stringified output', function () {
var json = {
it('should limit stringified output', () => {
const json = {
a: 2,
b: 'foo',
c: null,
Expand All @@ -68,8 +68,8 @@ describe('jsonUtils', function () {
f: { g: 'h' }
}

var all = '{"a":2,"b":"foo","c":null,"d":false,"e":[1,2,3],"f":{"g":"h"}}'
var limit = 20
const all = '{"a":2,"b":"foo","c":null,"d":false,"e":[1,2,3],"f":{"g":"h"}}'
const limit = 20

assert.strictEqual(stringifyPartial(json, undefined, limit),
all.slice(0, limit) + '...')
Expand All @@ -82,7 +82,7 @@ describe('jsonUtils', function () {
assert.strictEqual(stringifyPartial(12345678, undefined, 4), '1234...')
})

it('should count array items', function () {
it('should count array items', () => {
// assert.strictEqual(countArrayItems('[1,2,3]'), 3)
assert.strictEqual(containsArray('[]'), true)
assert.strictEqual(containsArray(' []'), true)
Expand Down
4 changes: 2 additions & 2 deletions test/setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var JSDOM = require('jsdom').JSDOM
const JSDOM = require('jsdom').JSDOM

/**
* Set up the test environment by simulating browser globals.
Expand All @@ -10,7 +10,7 @@ module.exports = function setUpTestEnvironment (locale) {
locale = 'en'
}

var dom = new JSDOM('...')
const dom = new JSDOM('...')
global.window = dom.window
global.document = dom.window.document
global.navigator = dom.window.navigator
Expand Down
Loading

0 comments on commit e67fa19

Please sign in to comment.