mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
Use ES6 linting rules in the project root
Update all tests for `no-var` and `prefer-arrow-callback` (using `--fix`)
This commit is contained in:
parent
5f59d1e7e5
commit
bafdf8d9f2
36 changed files with 666 additions and 666 deletions
|
@ -1,22 +1,22 @@
|
|||
var test = require('tap').test;
|
||||
var adapter = require('../../src/engine/adapter');
|
||||
var events = require('../fixtures/events.json');
|
||||
const test = require('tap').test;
|
||||
const adapter = require('../../src/engine/adapter');
|
||||
const events = require('../fixtures/events.json');
|
||||
|
||||
test('spec', function (t) {
|
||||
test('spec', t => {
|
||||
t.type(adapter, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('invalid inputs', function (t) {
|
||||
var nothing = adapter('not an object');
|
||||
test('invalid inputs', t => {
|
||||
let nothing = adapter('not an object');
|
||||
t.type(nothing, 'undefined');
|
||||
nothing = adapter({noxmlproperty: true});
|
||||
t.type(nothing, 'undefined');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('create event', function (t) {
|
||||
var result = adapter(events.create);
|
||||
test('create event', t => {
|
||||
const result = adapter(events.create);
|
||||
|
||||
t.ok(Array.isArray(result));
|
||||
t.equal(result.length, 2);
|
||||
|
@ -43,8 +43,8 @@ test('create event', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('create with branch', function (t) {
|
||||
var result = adapter(events.createbranch);
|
||||
test('create with branch', t => {
|
||||
const result = adapter(events.createbranch);
|
||||
// Outer block
|
||||
t.type(result[0].id, 'string');
|
||||
t.type(result[0].opcode, 'string');
|
||||
|
@ -54,13 +54,13 @@ test('create with branch', function (t) {
|
|||
t.type(result[0].topLevel, 'boolean');
|
||||
t.equal(result[0].topLevel, true);
|
||||
// In branch
|
||||
var branchBlockId = result[0].inputs.SUBSTACK.block;
|
||||
var branchShadowId = result[0].inputs.SUBSTACK.shadow;
|
||||
const branchBlockId = result[0].inputs.SUBSTACK.block;
|
||||
const branchShadowId = result[0].inputs.SUBSTACK.shadow;
|
||||
t.type(branchBlockId, 'string');
|
||||
t.equal(branchShadowId, null);
|
||||
// Find actual branch block
|
||||
var branchBlock = null;
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
let branchBlock = null;
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
if (result[i].id === branchBlockId) {
|
||||
branchBlock = result[i];
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ test('create with branch', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('create with two branches', function (t) {
|
||||
var result = adapter(events.createtwobranches);
|
||||
test('create with two branches', t => {
|
||||
const result = adapter(events.createtwobranches);
|
||||
// Outer block
|
||||
t.type(result[0].id, 'string');
|
||||
t.type(result[0].opcode, 'string');
|
||||
|
@ -81,18 +81,18 @@ test('create with two branches', function (t) {
|
|||
t.type(result[0].topLevel, 'boolean');
|
||||
t.equal(result[0].topLevel, true);
|
||||
// In branchs
|
||||
var firstBranchBlockId = result[0].inputs.SUBSTACK.block;
|
||||
var secondBranchBlockId = result[0].inputs.SUBSTACK2.block;
|
||||
const firstBranchBlockId = result[0].inputs.SUBSTACK.block;
|
||||
const secondBranchBlockId = result[0].inputs.SUBSTACK2.block;
|
||||
t.type(firstBranchBlockId, 'string');
|
||||
t.type(secondBranchBlockId, 'string');
|
||||
var firstBranchShadowBlockId = result[0].inputs.SUBSTACK.shadow;
|
||||
var secondBranchShadowBlockId = result[0].inputs.SUBSTACK2.shadow;
|
||||
const firstBranchShadowBlockId = result[0].inputs.SUBSTACK.shadow;
|
||||
const secondBranchShadowBlockId = result[0].inputs.SUBSTACK2.shadow;
|
||||
t.equal(firstBranchShadowBlockId, null);
|
||||
t.equal(secondBranchShadowBlockId, null);
|
||||
// Find actual branch blocks
|
||||
var firstBranchBlock = null;
|
||||
var secondBranchBlock = null;
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
let firstBranchBlock = null;
|
||||
let secondBranchBlock = null;
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
if (result[i].id === firstBranchBlockId) {
|
||||
firstBranchBlock = result[i];
|
||||
}
|
||||
|
@ -105,8 +105,8 @@ test('create with two branches', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('create with top-level shadow', function (t) {
|
||||
var result = adapter(events.createtoplevelshadow);
|
||||
test('create with top-level shadow', t => {
|
||||
const result = adapter(events.createtoplevelshadow);
|
||||
t.ok(Array.isArray(result));
|
||||
t.equal(result.length, 1);
|
||||
|
||||
|
@ -120,8 +120,8 @@ test('create with top-level shadow', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('create with next connection', function (t) {
|
||||
var result = adapter(events.createwithnext);
|
||||
test('create with next connection', t => {
|
||||
const result = adapter(events.createwithnext);
|
||||
|
||||
t.ok(Array.isArray(result));
|
||||
t.equal(result.length, 2);
|
||||
|
@ -148,21 +148,21 @@ test('create with next connection', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('create with obscured shadow', function (t) {
|
||||
var result = adapter(events.createobscuredshadow);
|
||||
test('create with obscured shadow', t => {
|
||||
const result = adapter(events.createobscuredshadow);
|
||||
t.ok(Array.isArray(result));
|
||||
t.equal(result.length, 4);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('create with invalid block xml', function (t) {
|
||||
test('create with invalid block xml', t => {
|
||||
// Entirely invalid block XML
|
||||
var result = adapter(events.createinvalid);
|
||||
const result = adapter(events.createinvalid);
|
||||
t.ok(Array.isArray(result));
|
||||
t.equal(result.length, 0);
|
||||
|
||||
// Invalid grandchild tag
|
||||
var result2 = adapter(events.createinvalidgrandchild);
|
||||
const result2 = adapter(events.createinvalidgrandchild);
|
||||
t.ok(Array.isArray(result2));
|
||||
t.equal(result2.length, 1);
|
||||
t.type(result2[0].id, 'string');
|
||||
|
@ -172,15 +172,15 @@ test('create with invalid block xml', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('create with invalid xml', function (t) {
|
||||
var result = adapter(events.createbadxml);
|
||||
test('create with invalid xml', t => {
|
||||
const result = adapter(events.createbadxml);
|
||||
t.ok(Array.isArray(result));
|
||||
t.equal(result.length, 0);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('create with empty field', function (t) {
|
||||
var result = adapter(events.createemptyfield);
|
||||
test('create with empty field', t => {
|
||||
const result = adapter(events.createemptyfield);
|
||||
t.ok(Array.isArray(result));
|
||||
t.equal(result.length, 3);
|
||||
t.end();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue