mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-11 05:24:05 -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
test/unit
|
@ -1,8 +1,8 @@
|
|||
var test = require('tap').test;
|
||||
var Blocks = require('../../src/engine/blocks');
|
||||
const test = require('tap').test;
|
||||
const Blocks = require('../../src/engine/blocks');
|
||||
|
||||
test('spec', function (t) {
|
||||
var b = new Blocks();
|
||||
test('spec', t => {
|
||||
const b = new Blocks();
|
||||
|
||||
t.type(Blocks, 'function');
|
||||
t.type(b, 'object');
|
||||
|
@ -27,8 +27,8 @@ test('spec', function (t) {
|
|||
});
|
||||
|
||||
// Getter tests
|
||||
test('getBlock', function (t) {
|
||||
var b = new Blocks();
|
||||
test('getBlock', t => {
|
||||
const b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
|
@ -37,16 +37,16 @@ test('getBlock', function (t) {
|
|||
inputs: {},
|
||||
topLevel: true
|
||||
});
|
||||
var block = b.getBlock('foo');
|
||||
const block = b.getBlock('foo');
|
||||
t.type(block, 'object');
|
||||
var notBlock = b.getBlock('?');
|
||||
const notBlock = b.getBlock('?');
|
||||
t.type(notBlock, 'undefined');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('getScripts', function (t) {
|
||||
var b = new Blocks();
|
||||
var scripts = b.getScripts();
|
||||
test('getScripts', t => {
|
||||
const b = new Blocks();
|
||||
let scripts = b.getScripts();
|
||||
t.type(scripts, 'object');
|
||||
t.equals(scripts.length, 0);
|
||||
// Create two top-level blocks and one not.
|
||||
|
@ -85,8 +85,8 @@ test('getScripts', function (t) {
|
|||
|
||||
});
|
||||
|
||||
test('getNextBlock', function (t) {
|
||||
var b = new Blocks();
|
||||
test('getNextBlock', t => {
|
||||
const b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
|
@ -96,7 +96,7 @@ test('getNextBlock', function (t) {
|
|||
topLevel: true
|
||||
});
|
||||
|
||||
var next = b.getNextBlock('foo');
|
||||
let next = b.getNextBlock('foo');
|
||||
t.equals(next, null);
|
||||
|
||||
// Add a block with "foo" as its next.
|
||||
|
@ -113,14 +113,14 @@ test('getNextBlock', function (t) {
|
|||
t.equals(next, 'foo');
|
||||
|
||||
// Block that doesn't exist.
|
||||
var noBlock = b.getNextBlock('?');
|
||||
const noBlock = b.getNextBlock('?');
|
||||
t.equals(noBlock, null);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('getBranch', function (t) {
|
||||
var b = new Blocks();
|
||||
test('getBranch', t => {
|
||||
const b = new Blocks();
|
||||
// Single branch
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
|
@ -145,17 +145,17 @@ test('getBranch', function (t) {
|
|||
topLevel: false
|
||||
});
|
||||
|
||||
var branch = b.getBranch('foo');
|
||||
const branch = b.getBranch('foo');
|
||||
t.equals(branch, 'foo2');
|
||||
|
||||
var notBranch = b.getBranch('?');
|
||||
const notBranch = b.getBranch('?');
|
||||
t.equals(notBranch, null);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('getBranch2', function (t) {
|
||||
var b = new Blocks();
|
||||
test('getBranch2', t => {
|
||||
const b = new Blocks();
|
||||
// Second branch
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
|
@ -193,16 +193,16 @@ test('getBranch2', function (t) {
|
|||
topLevel: false
|
||||
});
|
||||
|
||||
var branch1 = b.getBranch('foo', 1);
|
||||
var branch2 = b.getBranch('foo', 2);
|
||||
const branch1 = b.getBranch('foo', 1);
|
||||
const branch2 = b.getBranch('foo', 2);
|
||||
t.equals(branch1, 'foo2');
|
||||
t.equals(branch2, 'foo3');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('getBranch with none', function (t) {
|
||||
var b = new Blocks();
|
||||
test('getBranch with none', t => {
|
||||
const b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
|
@ -211,14 +211,14 @@ test('getBranch with none', function (t) {
|
|||
inputs: {},
|
||||
topLevel: true
|
||||
});
|
||||
var noBranch = b.getBranch('foo');
|
||||
const noBranch = b.getBranch('foo');
|
||||
t.equals(noBranch, null);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('getOpcode', function (t) {
|
||||
var b = new Blocks();
|
||||
var block = {
|
||||
test('getOpcode', t => {
|
||||
const b = new Blocks();
|
||||
const block = {
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
next: null,
|
||||
|
@ -227,17 +227,17 @@ test('getOpcode', function (t) {
|
|||
topLevel: true
|
||||
};
|
||||
b.createBlock(block);
|
||||
var opcode = b.getOpcode(block);
|
||||
const opcode = b.getOpcode(block);
|
||||
t.equals(opcode, 'TEST_BLOCK');
|
||||
var undefinedBlock = b.getBlock('?');
|
||||
var undefinedOpcode = b.getOpcode(undefinedBlock);
|
||||
const undefinedBlock = b.getBlock('?');
|
||||
const undefinedOpcode = b.getOpcode(undefinedBlock);
|
||||
t.equals(undefinedOpcode, null);
|
||||
t.end();
|
||||
});
|
||||
|
||||
// Block events tests
|
||||
test('create', function (t) {
|
||||
var b = new Blocks();
|
||||
test('create', t => {
|
||||
const b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
|
@ -253,8 +253,8 @@ test('create', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('move', function (t) {
|
||||
var b = new Blocks();
|
||||
test('move', t => {
|
||||
const b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
|
@ -293,8 +293,8 @@ test('move', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('move into empty', function (t) {
|
||||
var b = new Blocks();
|
||||
test('move into empty', t => {
|
||||
const b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
|
@ -320,8 +320,8 @@ test('move into empty', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('move no obscure shadow', function (t) {
|
||||
var b = new Blocks();
|
||||
test('move no obscure shadow', t => {
|
||||
const b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
|
@ -354,8 +354,8 @@ test('move no obscure shadow', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('change', function (t) {
|
||||
var b = new Blocks();
|
||||
test('change', t => {
|
||||
const b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
|
@ -411,8 +411,8 @@ test('change', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('delete', function (t) {
|
||||
var b = new Blocks();
|
||||
test('delete', t => {
|
||||
const b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
|
@ -430,10 +430,10 @@ test('delete', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('delete chain', function (t) {
|
||||
test('delete chain', t => {
|
||||
// Create a chain of connected blocks and delete the top one.
|
||||
// All of them should be deleted.
|
||||
var b = new Blocks();
|
||||
const b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
|
@ -470,10 +470,10 @@ test('delete chain', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('delete inputs', function (t) {
|
||||
test('delete inputs', t => {
|
||||
// Create a block with two inputs, one of which has its own input.
|
||||
// Delete the block - all of them should be deleted.
|
||||
var b = new Blocks();
|
||||
const b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue