From cc0e2c6d074c379a7e7bff30a2f57e1fffd44a74 Mon Sep 17 00:00:00 2001 From: Ryan Mahler Date: Fri, 21 Aug 2026 09:35:04 -0700 Subject: [PATCH] DELTA-1710 Remove config override Only added this initially to avoid the noise during the dependency update, but no need for it to exist. Used `eslint --fix` to update to arrow functions. https://desire2learn.atlassian.net/browse/DELTA-1710 --- eslint.config.js | 3 - test/action.js | 110 ++++++++++++------------- test/chaiPlugin.js | 30 +++---- test/entity.js | 198 ++++++++++++++++++++++----------------------- test/field.js | 80 +++++++++--------- test/link.js | 56 ++++++------- test/superagent.js | 34 ++++---- 7 files changed, 254 insertions(+), 257 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index c32db6c..8079b54 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -15,9 +15,6 @@ const sirenParserTestingConfig = [ languageOptions: { sourceType: 'module', }, - rules: { - 'prefer-arrow-callback': 'off', - }, } ] diff --git a/test/action.js b/test/action.js index 45a7e4f..c477bff 100644 --- a/test/action.js +++ b/test/action.js @@ -5,13 +5,13 @@ import sinonChai from 'sinon-chai'; use(sinonChai); -describe('Action', function() { +describe('Action', () => { let resource, sandbox, siren; - beforeEach(function() { + beforeEach(() => { resource = { name: 'foo', href: 'bar' @@ -22,7 +22,7 @@ describe('Action', function() { sandbox.stub(console, 'warn'); }); - afterEach(function() { + afterEach(() => { sandbox.restore(); }); @@ -30,124 +30,124 @@ describe('Action', function() { return new Action(resource); } - it('should auto-instantiate', function() { + it('should auto-instantiate', () => { expect(Action(resource)).to.be.an.instanceof(Action); }); - it('should require the action be an object', function() { + it('should require the action be an object', () => { resource = 1; expect(buildAction.bind()).to.throw('action must be an object, got 1'); }); - describe('name', function() { - it('should require a name', function() { + describe('name', () => { + it('should require a name', () => { resource.name = undefined; expect(buildAction.bind()).to.throw('action.name must be a string, got undefined'); }); - it('should require name be a string', function() { + it('should require name be a string', () => { resource.name = 1; expect(buildAction.bind()).to.throw('action.name must be a string, got 1'); }); - it('should parse name', function() { + it('should parse name', () => { siren = buildAction(); expect(siren.name).to.equal('foo'); }); }); - describe('href', function() { - it('should require a href', function() { + describe('href', () => { + it('should require a href', () => { resource.href = undefined; expect(buildAction.bind()).to.throw('action.href must be a string, got undefined'); }); - it('should require href be a string', function() { + it('should require href be a string', () => { resource.href = 1; expect(buildAction.bind()).to.throw('action.href must be a string, got 1'); }); - it('should parse href', function() { + it('should parse href', () => { siren = buildAction(); expect(siren.href).to.equal('bar'); }); }); - describe('class', function() { - it('should parse class', function() { + describe('class', () => { + it('should parse class', () => { resource.class = []; siren = buildAction(); expect(siren.class).to.be.an.instanceof(Array); }); - it('should require class be an array, if supplied', function() { + it('should require class be an array, if supplied', () => { resource.class = 1; expect(buildAction.bind()).to.throw('action.class must be an array or undefined, got 1'); }); }); - describe('method', function() { - it('should parse method', function() { + describe('method', () => { + it('should parse method', () => { resource.method = 'baz'; siren = buildAction(); expect(siren.method).to.equal('baz'); }); - it('should default to GET', function() { + it('should default to GET', () => { siren = buildAction(); expect(siren.method).to.equal('GET'); }); - it('should require method be a string, if supplied', function() { + it('should require method be a string, if supplied', () => { resource.method = 1; expect(buildAction.bind(undefined, resource)).to.throw('action.method must be a string or undefined, got 1'); }); }); - describe('title', function() { - it('should parse title', function() { + describe('title', () => { + it('should parse title', () => { resource.title = 'baz'; siren = buildAction(); expect(siren.title).to.equal('baz'); }); - it('should require title be a string, if supplied', function() { + it('should require title be a string, if supplied', () => { resource.title = 1; expect(buildAction.bind(undefined, resource)).to.throw('action.title must be a string or undefined, got 1'); }); }); - describe('type', function() { - it('should parse type', function() { + describe('type', () => { + it('should parse type', () => { resource.type = 'baz'; siren = buildAction(); expect(siren.type).to.equal('baz'); }); - it('should default to application/x-www-form-urlencoded', function() { + it('should default to application/x-www-form-urlencoded', () => { siren = buildAction(); expect(siren.type).to.equal('application/x-www-form-urlencoded'); }); - it('should require type be a string, if supplied', function() { + it('should require type be a string, if supplied', () => { resource.type = 1; expect(buildAction.bind(undefined, resource)).to.throw('action.type must be a string or undefined, got 1'); }); }); - describe('fields', function() { - it('should parse fields', function() { + describe('fields', () => { + it('should parse fields', () => { resource.fields = []; siren = buildAction(); expect(siren.fields).to.be.an.instanceof(Array); }); - it('should require fields be an array, if supplied', function() { + it('should require fields be an array, if supplied', () => { resource.fields = 1; expect(buildAction.bind(undefined, resource)).to.throw('action.fields must be an array or undefined, got 1'); }); - it('should be able to determine if an Action has a given Field', function() { + it('should be able to determine if an Action has a given Field', () => { resource.fields = [{ name: 'foo' }]; @@ -155,7 +155,7 @@ describe('Action', function() { expect(siren.hasField('foo')).to.be.true; }); - it('should be able to retrieve fields based off their name', function() { + it('should be able to retrieve fields based off their name', () => { resource.fields = [{ name: 'foo', title: 'bar' @@ -164,7 +164,7 @@ describe('Action', function() { expect(siren.getField('foo')).to.have.property('title', 'bar'); }); - it('should be able to use field helper methods', function() { + it('should be able to use field helper methods', () => { resource.fields = [{ class: ['abc'], name: 'foo', @@ -175,25 +175,25 @@ describe('Action', function() { }); }); - describe('toJSON', function() { + describe('toJSON', () => { function toJSON() { return JSON.stringify(buildAction()); } - it('should stringify name and href', function() { + it('should stringify name and href', () => { expect(toJSON()).to.equal( '{"name":"foo","href":"bar","method":"GET","type":"application/x-www-form-urlencoded"}' ); }); - it('should stringify class', function() { + it('should stringify class', () => { resource.class = ['abc']; expect(toJSON()).to.equal( '{"name":"foo","href":"bar","class":["abc"],"method":"GET","type":"application/x-www-form-urlencoded"}' ); }); - it('should stringify fields', function() { + it('should stringify fields', () => { resource.fields = [{ name: 'foo', title: 'bar' @@ -204,10 +204,10 @@ describe('Action', function() { }); }); - describe('Helper functions', function() { - describe('has...', function() { - describe('Class', function() { - it('should be able to determine if an action has a given class', function() { + describe('Helper functions', () => { + describe('has...', () => { + describe('Class', () => { + it('should be able to determine if an action has a given class', () => { resource.class = ['foo']; siren = buildAction(); expect(siren.hasClass('foo')).to.be.true; @@ -224,8 +224,8 @@ describe('Action', function() { }); }); - describe('Field', function() { - it('hasFieldByName (hasField)', function() { + describe('Field', () => { + it('hasFieldByName (hasField)', () => { resource.fields = [{ name: 'foo' }]; @@ -243,7 +243,7 @@ describe('Action', function() { expect(siren.hasField('foo')).to.be.false; }); - it('hasFieldByClass', function() { + it('hasFieldByClass', () => { resource.fields = [{ name: 'foo', class: ['bar'] @@ -262,7 +262,7 @@ describe('Action', function() { expect(siren.hasFieldByClass('bar')).to.be.false; }); - it('hasFieldByType', function() { + it('hasFieldByType', () => { resource.fields = [{ name: 'foo', type: 'text' @@ -283,9 +283,9 @@ describe('Action', function() { }); }); - describe('get...', function() { - describe('Field', function() { - beforeEach(function() { + describe('get...', () => { + describe('Field', () => { + beforeEach(() => { resource.fields = [{ name: 'foo', title: 'bar', @@ -310,7 +310,7 @@ describe('Action', function() { siren = buildAction(); }); - it('getFieldByName (getField)', function() { + it('getFieldByName (getField)', () => { expect(siren.getField('foo')).to.have.property('title', 'bar'); expect(siren.getField('nope')).to.be.undefined; expect(siren.getField(undefined)).to.be.undefined; @@ -321,7 +321,7 @@ describe('Action', function() { expect(siren.getField(/bar/)).to.be.undefined; }); - it('getFieldByClass', function() { + it('getFieldByClass', () => { expect(siren.getFieldByClass('baz')).to.have.property('title', 'bar'); expect(siren.getFieldByClass('nope')).to.be.undefined; expect(siren.getFieldByClass(undefined)).to.be.undefined; @@ -332,7 +332,7 @@ describe('Action', function() { expect(siren.getFieldByClass(/foo/)).to.be.undefined; }); - it('getFieldsByClass', function() { + it('getFieldsByClass', () => { expect(siren.getFieldsByClass('baz')).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getFieldsByClass('nope')).to.be.an.instanceof(Array).and.to.be.empty; expect(siren.getFieldsByClass(undefined)).to.be.an.instanceof(Array).and.to.be.empty; @@ -343,7 +343,7 @@ describe('Action', function() { expect(siren.getFieldsByClass(/foo/)).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getFieldByClasses', function() { + it('getFieldByClasses', () => { expect(siren.getFieldByClasses(['bonk', 'bork'])).to.have.property('name', 'foo3'); expect(siren.getFieldByClasses([/bonk/, /bork/])).to.have.property('name', 'foo3'); expect(siren.getFieldByClasses(['bonk', /bork/])).to.have.property('name', 'foo3'); @@ -355,7 +355,7 @@ describe('Action', function() { expect(siren.getFieldByClasses([null])).to.be.undefined; }); - it('getFieldsByClasses', function() { + it('getFieldsByClasses', () => { expect(siren.getFieldsByClasses(['bonk', 'bork'])).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getFieldsByClasses([/bonk/, /bork/])).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getFieldsByClasses(['bonk', /bork/])).to.be.an.instanceof(Array).with.lengthOf(2); @@ -367,7 +367,7 @@ describe('Action', function() { expect(siren.getFieldsByClasses([null])).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getFieldByType', function() { + it('getFieldByType', () => { expect(siren.getFieldByType('text')).to.have.property('title', 'bar'); expect(siren.getFieldByType('nope')).to.be.undefined; expect(siren.getFieldByType(undefined)).to.be.undefined; @@ -378,7 +378,7 @@ describe('Action', function() { expect(siren.getFieldByType(/nope/)).to.be.undefined; }); - it('getFieldsByType', function() { + it('getFieldsByType', () => { expect(siren.getFieldsByType('text')).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getFieldsByType('nope')).to.be.an.instanceof(Array).and.to.be.empty; expect(siren.getFieldsByType(undefined)).to.be.an.instanceof(Array).and.to.be.empty; diff --git a/test/chaiPlugin.js b/test/chaiPlugin.js index 0ee0d0f..34c2609 100644 --- a/test/chaiPlugin.js +++ b/test/chaiPlugin.js @@ -7,7 +7,7 @@ import sirenChai from '../src/chaiPlugin.js'; use(sirenChai); -describe('Chai Plugin v2', function() { +describe('Chai Plugin v2', () => { let action, entity, @@ -16,7 +16,7 @@ describe('Chai Plugin v2', function() { subEntity, subEntitySparse; - beforeEach(function() { + beforeEach(() => { field = new Field({ name: 'name', class: ['class1', 'class2'], @@ -69,7 +69,7 @@ describe('Chai Plugin v2', function() { }); }); - it('.classes(c1, c2, ...)', function() { + it('.classes(c1, c2, ...)', () => { expect(entity).to.have.classes('class1'); expect(entity).to.not.have.classes('foo'); expect(() => { @@ -112,7 +112,7 @@ describe('Chai Plugin v2', function() { }).to.throw(); }); - it('.rels(r1, r2, ...)', function() { + it('.rels(r1, r2, ...)', () => { // Uses same code as .classes(), so don't really need to test extensively expect(entity).to.not.have.rels('rel1'); expect(subEntity).to.have.rels('rel1'); @@ -126,7 +126,7 @@ describe('Chai Plugin v2', function() { }).to.throw(); }); - it('.title(desiredTitle)', function() { + it('.title(desiredTitle)', () => { expect(entity).to.have.title('title'); expect(entity).to.not.have.title('foo'); expect(() => { @@ -155,7 +155,7 @@ describe('Chai Plugin v2', function() { }).to.throw(); }); - it('.href(desiredHref)', function() { + it('.href(desiredHref)', () => { expect(action).to.have.href('http://example.com'); expect(link).to.have.href('http://example.com'); expect(() => { @@ -166,7 +166,7 @@ describe('Chai Plugin v2', function() { }).to.throw(); }); - it('.name(desiredName)', function() { + it('.name(desiredName)', () => { expect(action).to.have.name('name'); expect(field).to.have.name('name'); expect(() => { @@ -177,7 +177,7 @@ describe('Chai Plugin v2', function() { }).to.throw(); }); - it('.method(desiredMethod)', function() { + it('.method(desiredMethod)', () => { expect(action).to.have.method('GET'); expect(() => { expect(entity).to.have.method('GET'); @@ -190,7 +190,7 @@ describe('Chai Plugin v2', function() { }).to.throw(); }); - it('.type(desiredType)', function() { + it('.type(desiredType)', () => { expect(action).to.have.type('application/x-www-form-urlencoded'); expect(field).to.have.type('text'); expect(link).to.have.type('type'); @@ -199,7 +199,7 @@ describe('Chai Plugin v2', function() { }).to.throw(); }); - it('.value(desiredValue)', function() { + it('.value(desiredValue)', () => { expect(field).to.have.value('value'); expect(() => { expect(action).to.have.value('value'); @@ -212,7 +212,7 @@ describe('Chai Plugin v2', function() { }).to.throw(); }); - it('.sirenActions', function() { + it('.sirenActions', () => { expect(entity).to.have.sirenAction; expect(entity).to.have.sirenActions; expect(subEntitySparse).to.not.have.sirenActions; @@ -224,12 +224,12 @@ describe('Chai Plugin v2', function() { }).to.throw(); }); - it('.sirenEntities', function() { + it('.sirenEntities', () => { expect(entity).to.have.sirenEntity; expect(entity).to.have.sirenEntities; }); - it('.sirenFields', function() { + it('.sirenFields', () => { expect(action).to.have.sirenField; expect(action).to.have.sirenFields; expect(() => { @@ -237,12 +237,12 @@ describe('Chai Plugin v2', function() { }).to.throw(); }); - it('.sirenLinks', function() { + it('.sirenLinks', () => { expect(entity).to.have.sirenLink; expect(entity).to.have.sirenLinks; }); - it('.sirenProperties', function() { + it('.sirenProperties', () => { expect(entity).to.have.sirenProperty; expect(entity).to.have.sirenProperties; expect(subEntitySparse).to.not.have.sirenProperties; diff --git a/test/entity.js b/test/entity.js index cd0ebb8..6e1d5ba 100644 --- a/test/entity.js +++ b/test/entity.js @@ -7,13 +7,13 @@ import sinonChai from 'sinon-chai'; use(sinonChai); -describe('Entity', function() { +describe('Entity', () => { let resource, sandbox, siren; - beforeEach(function() { + beforeEach(() => { resource = {}; siren = undefined; sandbox = sinon.createSandbox(); @@ -21,7 +21,7 @@ describe('Entity', function() { sandbox.stub(console, 'warn'); }); - afterEach(function() { + afterEach(() => { sandbox.restore(); }); @@ -29,59 +29,59 @@ describe('Entity', function() { return new Entity(resource); } - it('should auto-instantiate', function() { + it('should auto-instantiate', () => { expect(Entity(resource)).to.be.an.instanceof(Entity); }); - it('should work with stringified entity', function() { + it('should work with stringified entity', () => { resource = '{}'; expect(buildEntity()).to.be.an('object'); }); - it('should return an empty entity if nothing is passed', function() { + it('should return an empty entity if nothing is passed', () => { resource = undefined; expect(buildEntity()).to.be.an('object'); }); - describe('title', function() { - it('should parse title', function() { + describe('title', () => { + it('should parse title', () => { resource.title = 'A title!'; siren = buildEntity(); expect(siren.title).to.equal('A title!'); }); - it('should require title be a string, if supplied', function() { + it('should require title be a string, if supplied', () => { resource.title = 1; expect(buildEntity.bind()).to.throw('entity.title must be a string or undefined, got 1'); }); }); - describe('type', function() { - it('should parse type', function() { + describe('type', () => { + it('should parse type', () => { resource.type = 'foo'; siren = buildEntity(); expect(siren.type).to.equal('foo'); }); - it('should require type be a string, if supplied', function() { + it('should require type be a string, if supplied', () => { resource.type = 1; expect(buildEntity.bind()).to.throw('entity.type must be a string or undefined, got 1'); }); }); - describe('properties', function() { - it('should parse properties', function() { + describe('properties', () => { + it('should parse properties', () => { resource.properties = {}; siren = buildEntity(); expect(siren.properties).to.be.an('object'); }); - it('should require properties be an object, if supplied', function() { + it('should require properties be an object, if supplied', () => { resource.properties = 1; expect(buildEntity.bind()).to.throw('entity.properties must be an object or undefined, got 1'); }); - it('should be able to determine if an entity has a given property', function() { + it('should be able to determine if an entity has a given property', () => { resource.properties = { foo: 'bar' }; @@ -90,65 +90,65 @@ describe('Entity', function() { }); }); - describe('class', function() { - it('should parse class', function() { + describe('class', () => { + it('should parse class', () => { resource.class = []; siren = buildEntity(); expect(siren.class).to.be.an.instanceof(Array); }); - it('should require class be an array, if supplied', function() { + it('should require class be an array, if supplied', () => { resource.class = 1; expect(buildEntity.bind()).to.throw('entity.class must be an array or undefined, got 1'); }); }); - describe('actions', function() { - it('should parse actions', function() { + describe('actions', () => { + it('should parse actions', () => { resource.actions = [], siren = buildEntity(); expect(siren.actions).to.be.an.instanceof(Array); }); - it('should require actions be an array, if supplied', function() { + it('should require actions be an array, if supplied', () => { resource.actions = 1; expect(buildEntity.bind()).to.throw('entity.actions must be an array or undefined, got 1'); }); }); - describe('links', function() { - it('should parse links', function() { + describe('links', () => { + it('should parse links', () => { resource.links = [], siren = buildEntity(); expect(siren.links).to.be.an.instanceof(Array); }); - it('should require links be an array, if supplied', function() { + it('should require links be an array, if supplied', () => { resource.links = 1; expect(buildEntity.bind()).to.throw('entity.links must be an array or undefined, got 1'); }); }); - describe('(sub)entities', function() { - it('should parse (sub)entities', function() { + describe('(sub)entities', () => { + it('should parse (sub)entities', () => { resource.entities = []; siren = buildEntity(); expect(siren.entities).to.be.an.instanceof(Array); }); - it('should require (sub)entities be an array, if supplied', function() { + it('should require (sub)entities be an array, if supplied', () => { resource.entities = 1; expect(buildEntity.bind()).to.throw('entity.entities must be an array or undefined, got 1'); }); - it('should require (sub)entities have a rel', function() { + it('should require (sub)entities have a rel', () => { resource.entities = [{ foo: 'bar' }]; expect(buildEntity.bind()).to.throw('sub-entities must have a rel array, got undefined'); }); - it('should work with chained Entity/Action/Links', function() { + it('should work with chained Entity/Action/Links', () => { resource.entities = [{ rel: ['foo'], actions: [{ @@ -162,7 +162,7 @@ describe('Entity', function() { .with.property('href', 'baz'); }); - it('should correctly identify entity sub-entities', function() { + it('should correctly identify entity sub-entities', () => { resource.entities = [{ rel: ['foo'], title: 'bar' @@ -171,7 +171,7 @@ describe('Entity', function() { expect(siren.getSubEntity('foo')).to.be.an.instanceof(Entity); }); - it('should correctly identify link sub-entities', function() { + it('should correctly identify link sub-entities', () => { resource.entities = [{ rel: ['foo'], href: 'bar' @@ -180,7 +180,7 @@ describe('Entity', function() { expect(siren.getSubEntity('foo')).to.be.an.instanceof(Link); }); - it('should not duplicate sub-entities with the same rel', function() { + it('should not duplicate sub-entities with the same rel', () => { resource.entities = [{ rel: ['foo', 'bar'] }]; @@ -189,67 +189,67 @@ describe('Entity', function() { }); }); - describe('toJSON', function() { + describe('toJSON', () => { function toJSON() { return JSON.stringify(buildEntity()); } - it('should stringify (empty)', function() { + it('should stringify (empty)', () => { expect(toJSON()).to.equal( '{}' ); }); - it('should stringify title', function() { + it('should stringify title', () => { resource.title = 'A title!'; expect(toJSON()).to.equal( '{"title":"A title!"}' ); }); - it('should stringify type', function() { + it('should stringify type', () => { resource.type = 'foo'; expect(toJSON()).to.equal( '{"type":"foo"}' ); }); - it('should stringify properties', function() { + it('should stringify properties', () => { resource.properties = {}; expect(toJSON()).to.equal( '{"properties":{}}' ); }); - it('should stringify class', function() { + it('should stringify class', () => { resource.class = []; expect(toJSON()).to.equal( '{"class":[]}' ); }); - it('should stringify actions', function() { + it('should stringify actions', () => { resource.actions = [], expect(toJSON()).to.equal( '{"actions":[]}' ); }); - it('should stringify links', function() { + it('should stringify links', () => { resource.links = [], expect(toJSON()).to.equal( '{"links":[]}' ); }); - it('should stringify entities', function() { + it('should stringify entities', () => { resource.entities = []; expect(toJSON()).to.equal( '{"entities":[]}' ); }); - it('should stringify sub entities', function() { + it('should stringify sub entities', () => { resource.entities = [{ rel: ['foo'], actions: [{ @@ -263,10 +263,10 @@ describe('Entity', function() { }); }); - describe('helper functions', function() { - describe('has...', function() { - describe('Action', function() { - it('hasActionByName (hasAction)', function() { + describe('helper functions', () => { + describe('has...', () => { + describe('Action', () => { + it('hasActionByName (hasAction)', () => { resource.actions = [{ name: 'foo', href: 'bar' @@ -285,7 +285,7 @@ describe('Entity', function() { expect(siren.hasAction('foo')).to.be.false; }); - it('hasActionByClass', function() { + it('hasActionByClass', () => { resource.actions = [{ name: 'foo', href: 'bar', @@ -305,7 +305,7 @@ describe('Entity', function() { expect(siren.hasActionByClass('baz')).to.be.false; }); - it('hasActionByMethod', function() { + it('hasActionByMethod', () => { resource.actions = [{ name: 'foo', href: 'bar', @@ -325,7 +325,7 @@ describe('Entity', function() { expect(siren.hasActionByMethod('GET')).to.be.false; }); - it('hasActionByType', function() { + it('hasActionByType', () => { resource.actions = [{ name: 'foo', href: 'bar', @@ -346,8 +346,8 @@ describe('Entity', function() { }); }); - describe('Class', function() { - it('hasClass', function() { + describe('Class', () => { + it('hasClass', () => { resource.class = ['foo']; siren = buildEntity(); expect(siren.hasClass('foo')).to.be.true; @@ -364,8 +364,8 @@ describe('Entity', function() { }); }); - describe('Entity', function() { - it('hasSubEntityByRel (hasEntityByRel, hasEntity)', function() { + describe('Entity', () => { + it('hasSubEntityByRel (hasEntityByRel, hasEntity)', () => { resource.entities = [{ rel: ['foo'] }]; @@ -398,7 +398,7 @@ describe('Entity', function() { expect(siren.hasSubEntityByRel('foo')).to.be.false; }); - it('hasSubEntityByClass (hasEntityByClass)', function() { + it('hasSubEntityByClass (hasEntityByClass)', () => { resource.entities = [{ rel: ['foo'], class: ['bar'] @@ -425,7 +425,7 @@ describe('Entity', function() { expect(siren.hasSubEntityByClass('bar')).to.be.false; }); - it('hasSubEntityByType (hasSubEntityByType)', function() { + it('hasSubEntityByType (hasSubEntityByType)', () => { resource.entities = [{ rel: ['foo'], type: 'bar' @@ -453,8 +453,8 @@ describe('Entity', function() { }); }); - describe('Link', function() { - it('hasLinkByRel (hasLink)', function() { + describe('Link', () => { + it('hasLinkByRel (hasLink)', () => { resource.links = [{ rel: ['foo'], href: 'bar' @@ -473,7 +473,7 @@ describe('Entity', function() { expect(siren.hasLink('foo')).to.be.false; }); - it('hasLinkByClass', function() { + it('hasLinkByClass', () => { resource.links = [{ rel: ['foo'], href: 'bar', @@ -493,7 +493,7 @@ describe('Entity', function() { expect(siren.hasLinkByClass('baz')).to.be.false; }); - it('hasLinkByType', function() { + it('hasLinkByType', () => { resource.links = [{ rel: ['foo'], href: 'bar', @@ -514,8 +514,8 @@ describe('Entity', function() { }); }); - describe('Property', function() { - it('hasProperty', function() { + describe('Property', () => { + it('hasProperty', () => { resource.properties = { foo: 'bar' }; siren = buildEntity(); expect(siren.hasProperty('foo')).to.be.true; @@ -533,9 +533,9 @@ describe('Entity', function() { }); }); - describe('get...', function() { - describe('Action', function() { - it('getActionByName (getAction)', function() { + describe('get...', () => { + describe('Action', () => { + it('getActionByName (getAction)', () => { resource.actions = [{ name: 'foo', href: 'bar' @@ -548,7 +548,7 @@ describe('Entity', function() { expect(siren.getAction(null)).to.be.undefined; }); - it('getActionByClass', function() { + it('getActionByClass', () => { resource.actions = [{ name: 'foo', href: 'bar', @@ -564,7 +564,7 @@ describe('Entity', function() { expect(siren.getActionByClass(null)).to.be.undefined; }); - it('getActionsByClass', function() { + it('getActionsByClass', () => { resource.actions = [{ name: 'foo', href: 'bar', @@ -584,7 +584,7 @@ describe('Entity', function() { expect(siren.getActionsByClass(null)).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getActionByClasses', function() { + it('getActionByClasses', () => { resource.actions = [{ name: 'foo', href: 'bar', @@ -614,7 +614,7 @@ describe('Entity', function() { expect(siren.getActionByClasses([null])).to.be.undefined; }); - it('getActionsByClasses', function() { + it('getActionsByClasses', () => { resource.actions = [{ name: 'foo', href: 'bar', @@ -644,7 +644,7 @@ describe('Entity', function() { expect(siren.getActionsByClasses([null])).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getActionByMethod', function() { + it('getActionByMethod', () => { resource.actions = [{ name: 'foo', href: 'bar', @@ -660,7 +660,7 @@ describe('Entity', function() { expect(siren.getActionByMethod(null)).to.be.undefined; }); - it('getActionsByMethod', function() { + it('getActionsByMethod', () => { resource.actions = [{ name: 'foo', href: 'bar', @@ -680,7 +680,7 @@ describe('Entity', function() { expect(siren.getActionsByMethod(null)).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getActionByType', function() { + it('getActionByType', () => { resource.actions = [{ name: 'foo', href: 'bar', @@ -696,7 +696,7 @@ describe('Entity', function() { expect(siren.getActionByType(null)).to.be.undefined; }); - it('getActionsByType', function() { + it('getActionsByType', () => { resource.actions = [{ name: 'foo', href: 'bar', @@ -717,8 +717,8 @@ describe('Entity', function() { }); }); - describe('Link', function() { - beforeEach(function() { + describe('Link', () => { + beforeEach(() => { resource.links = [{ rel: ['foo'], href: 'bar', @@ -746,7 +746,7 @@ describe('Entity', function() { siren = buildEntity(); }); - it('getLinkByRel (getLink)', function() { + it('getLinkByRel (getLink)', () => { expect(siren.getLink('foo')).to.have.property('href', 'bar'); expect(siren.getLink(/foo/)).to.have.property('href', 'bar'); expect(siren.getLink('nope')).to.be.undefined; @@ -756,7 +756,7 @@ describe('Entity', function() { expect(siren.getLink(null)).to.be.undefined; }); - it('getLinksByRel (getLinks)', function() { + it('getLinksByRel (getLinks)', () => { expect(siren.getLinks('foo')).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getLinks(/foo/)).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getLinks('nope')).to.be.an.instanceof(Array).and.to.be.empty; @@ -766,7 +766,7 @@ describe('Entity', function() { expect(siren.getLinks(null)).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getLinkByRels)', function() { + it('getLinkByRels)', () => { expect(siren.getLinkByRels(['foo', 'foo2'])).to.have.property('href', 'bar2'); expect(siren.getLinkByRels([/foo/, /foo2/])).to.have.property('href', 'bar2'); expect(siren.getLinkByRels(['foo', /foo2/])).to.have.property('href', 'bar2'); @@ -778,7 +778,7 @@ describe('Entity', function() { expect(siren.getLinkByRels([null])).to.be.undefined; }); - it('getLinksByRels', function() { + it('getLinksByRels', () => { expect(siren.getLinksByRels(['foo', 'foo2'])).to.be.an.instanceof(Array).with.lengthOf(1); expect(siren.getLinksByRels([/foo/, /foo2/])).to.be.an.instanceof(Array).with.lengthOf(1); expect(siren.getLinksByRels(['foo', /foo2/])).to.be.an.instanceof(Array).with.lengthOf(1); @@ -790,12 +790,12 @@ describe('Entity', function() { expect(siren.getLinksByRels([null])).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getLinks should return a new array', function() { + it('getLinks should return a new array', () => { expect(siren.getLinks('foo')).to.not.equal(siren.getLinks('foo')); expect(siren.getLinks(/foo/)).to.not.equal(siren.getLinks('foo')); }); - it('getLinkByClass', function() { + it('getLinkByClass', () => { expect(siren.getLinkByClass('baz')).to.have.property('href', 'bar'); expect(siren.getLinkByClass(/baz/)).to.have.property('href', 'bar'); expect(siren.getLinkByClass('nope')).to.be.undefined; @@ -805,7 +805,7 @@ describe('Entity', function() { expect(siren.getLinkByClass(null)).to.be.undefined; }); - it('getLinksByClass', function() { + it('getLinksByClass', () => { expect(siren.getLinksByClass('baz')).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getLinksByClass(/baz/)).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getLinksByClass('nope')).to.be.an.instanceof(Array).and.to.be.empty; @@ -815,7 +815,7 @@ describe('Entity', function() { expect(siren.getLinksByClass(null)).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getLinkByClasses', function() { + it('getLinkByClasses', () => { expect(siren.getLinkByClasses(['bonk', 'bork'])).to.have.property('href', 'bar3'); expect(siren.getLinkByClasses([/bonk/, /bork/])).to.have.property('href', 'bar3'); expect(siren.getLinkByClasses(['bonk', /bork/])).to.have.property('href', 'bar3'); @@ -827,7 +827,7 @@ describe('Entity', function() { expect(siren.getLinkByClasses([null])).to.be.undefined; }); - it('getLinksByClasses', function() { + it('getLinksByClasses', () => { expect(siren.getLinksByClasses(['bonk', 'bork'])).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getLinksByClasses([/bonk/, /bork/])).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getLinksByClasses(['bonk', /bork/])).to.be.an.instanceof(Array).with.lengthOf(2); @@ -839,7 +839,7 @@ describe('Entity', function() { expect(siren.getLinksByClasses([null])).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getLinkByType', function() { + it('getLinkByType', () => { expect(siren.getLinkByType('quux')).to.have.property('href', 'bar'); expect(siren.getLinkByType(/quux/)).to.have.property('href', 'bar'); expect(siren.getLinkByType('nope')).to.be.undefined; @@ -849,7 +849,7 @@ describe('Entity', function() { expect(siren.getLinkByType(null)).to.be.undefined; }); - it('getLinksByType', function() { + it('getLinksByType', () => { expect(siren.getLinksByType('quux')).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getLinksByType(/quux/)).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getLinksByType('nope')).to.be.an.instanceof(Array).and.to.be.empty; @@ -860,8 +860,8 @@ describe('Entity', function() { }); }); - describe('Entity', function() { - beforeEach(function() { + describe('Entity', () => { + beforeEach(() => { resource.entities = [{ rel: ['foo'], title: 'bar', @@ -886,7 +886,7 @@ describe('Entity', function() { siren = buildEntity(); }); - it('getSubEntityByRel (getSubEntity)', function() { + it('getSubEntityByRel (getSubEntity)', () => { expect(siren.getSubEntity('foo')).to.have.property('title', 'bar'); expect(siren.getSubEntity(/foo/)).to.have.property('title', 'bar'); expect(siren.getSubEntity('nope')).to.be.undefined; @@ -896,7 +896,7 @@ describe('Entity', function() { expect(siren.getSubEntity(null)).to.be.undefined; }); - it('getSubEntitiesByRel (getSubEntities)', function() { + it('getSubEntitiesByRel (getSubEntities)', () => { expect(siren.getSubEntities('foo')).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getSubEntities(/foo/)).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getSubEntities('nope')).to.be.an.instanceof(Array).and.to.be.empty; @@ -906,7 +906,7 @@ describe('Entity', function() { expect(siren.getSubEntities(null)).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getSubEntityByRels', function() { + it('getSubEntityByRels', () => { expect(siren.getSubEntityByRels(['foo', 'foo2'])).to.have.property('title', 'bar2'); expect(siren.getSubEntityByRels([/foo/, /foo2/])).to.have.property('title', 'bar2'); expect(siren.getSubEntityByRels(['foo', /foo2/])).to.have.property('title', 'bar2'); @@ -918,7 +918,7 @@ describe('Entity', function() { expect(siren.getSubEntityByRels([null])).to.be.undefined; }); - it('getSubEntitiesByRels', function() { + it('getSubEntitiesByRels', () => { expect(siren.getSubEntitiesByRels(['foo', 'foo2'])).to.be.an.instanceof(Array).with.lengthOf(1); expect(siren.getSubEntitiesByRels([/foo/, /foo2/])).to.be.an.instanceof(Array).with.lengthOf(1); expect(siren.getSubEntitiesByRels(['foo', /foo2/])).to.be.an.instanceof(Array).with.lengthOf(1); @@ -930,12 +930,12 @@ describe('Entity', function() { expect(siren.getSubEntitiesByRels([null])).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getSubEntities should return a new array', function() { + it('getSubEntities should return a new array', () => { expect(siren.getSubEntities('foo')).to.not.equal(siren.getSubEntities('foo')); expect(siren.getSubEntities(/foo/)).to.not.equal(siren.getSubEntities('foo')); }); - it('getSubEntityByClass', function() { + it('getSubEntityByClass', () => { expect(siren.getSubEntityByClass('baz')).to.have.property('title', 'bar'); expect(siren.getSubEntityByClass(/baz/)).to.have.property('title', 'bar'); expect(siren.getSubEntityByClass('nope')).to.be.undefined; @@ -945,7 +945,7 @@ describe('Entity', function() { expect(siren.getSubEntityByClass(null)).to.be.undefined; }); - it('getSubEntitiesByClass', function() { + it('getSubEntitiesByClass', () => { expect(siren.getSubEntitiesByClass('baz')).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getSubEntitiesByClass(/baz/)).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getSubEntitiesByClass('nope')).to.be.an.instanceof(Array).and.to.be.empty; @@ -955,7 +955,7 @@ describe('Entity', function() { expect(siren.getSubEntitiesByClass(null)).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getSubEntityByClasses', function() { + it('getSubEntityByClasses', () => { expect(siren.getSubEntityByClasses(['bonk', 'bork'])).to.have.property('title', 'bar3'); expect(siren.getSubEntityByClasses([/bonk/, /bork/])).to.have.property('title', 'bar3'); expect(siren.getSubEntityByClasses(['bonk', /bork/])).to.have.property('title', 'bar3'); @@ -967,7 +967,7 @@ describe('Entity', function() { expect(siren.getSubEntityByClasses([null])).to.be.undefined; }); - it('getSubEntitiesByClasses', function() { + it('getSubEntitiesByClasses', () => { expect(siren.getSubEntitiesByClasses(['bonk', 'bork'])).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getSubEntitiesByClasses([/bonk/, /bork/])).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getSubEntitiesByClasses(['bonk', /bork/])).to.be.an.instanceof(Array).with.lengthOf(2); @@ -979,7 +979,7 @@ describe('Entity', function() { expect(siren.getSubEntitiesByClasses([null])).to.be.an.instanceof(Array).and.to.be.empty; }); - it('getSubEntityByType', function() { + it('getSubEntityByType', () => { expect(siren.getSubEntityByType('quux')).to.have.property('title', 'bar'); expect(siren.getSubEntityByType(/quux/)).to.have.property('title', 'bar'); expect(siren.getSubEntityByType('nope')).to.be.undefined; @@ -989,7 +989,7 @@ describe('Entity', function() { expect(siren.getSubEntityByType(null)).to.be.undefined; }); - it('getSubEntitiesByType', function() { + it('getSubEntitiesByType', () => { expect(siren.getSubEntitiesByType('quux')).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getSubEntitiesByType(/quux/)).to.be.an.instanceof(Array).with.lengthOf(2); expect(siren.getSubEntitiesByType('nope')).to.be.an.instanceof(Array).and.to.be.empty; diff --git a/test/field.js b/test/field.js index 78c925b..0292ee5 100644 --- a/test/field.js +++ b/test/field.js @@ -5,13 +5,13 @@ import sinonChai from 'sinon-chai'; use(sinonChai); -describe('Field', function() { +describe('Field', () => { let resource, sandbox, siren; - beforeEach(function() { + beforeEach(() => { resource = { name: 'foo' }; @@ -21,7 +21,7 @@ describe('Field', function() { sandbox.stub(console, 'warn'); }); - afterEach(function() { + afterEach(() => { sandbox.restore(); }); @@ -29,53 +29,53 @@ describe('Field', function() { return new Field(resource); } - it('should auto-instantiate', function() { + it('should auto-instantiate', () => { expect(Field(resource)).to.be.an.instanceof(Field); }); - it('should require the field be an object', function() { + it('should require the field be an object', () => { resource = 1; expect(buildField.bind()).to.throw('field must be an object, got 1'); }); - describe('name', function() { - it('should require a name', function() { + describe('name', () => { + it('should require a name', () => { resource.name = undefined; expect(buildField.bind()).to.throw('field.name must be a string, got undefined'); }); - it('should require name be a string', function() { + it('should require name be a string', () => { resource.name = 1; expect(buildField.bind()).to.throw('field.name must be a string, got 1'); }); - it('should parse name', function() { + it('should parse name', () => { siren = buildField(); expect(siren.name).to.equal('foo'); }); }); - describe('value', function() { - it('should parse value', function() { + describe('value', () => { + it('should parse value', () => { resource.value = 'foo'; siren = buildField(); expect(siren.value).to.equal('foo'); }); }); - describe('class', function() { - it('should parse class', function() { + describe('class', () => { + it('should parse class', () => { resource.class = []; siren = buildField(); expect(siren.class).to.be.an.instanceof(Array); }); - it('should require class be an array, if supplied', function() { + it('should require class be an array, if supplied', () => { resource.class = 1; expect(buildField.bind()).to.throw('field.class must be an array or undefined, got 1'); }); - it('should be able to determine if a field has a given class', function() { + it('should be able to determine if a field has a given class', () => { resource.class = ['foo']; siren = buildField(); expect(siren.hasClass('foo')).to.be.true; @@ -89,134 +89,134 @@ describe('Field', function() { }); }); - describe('title', function() { - it('should parse title', function() { + describe('title', () => { + it('should parse title', () => { resource.title = 'bar'; siren = buildField(); expect(siren.title).to.equal('bar'); }); - it('should require title be a string, if supplied', function() { + it('should require title be a string, if supplied', () => { resource.title = 1; expect(buildField.bind(undefined, resource)).to.throw('field.title must be a string or undefined, got 1'); }); }); - describe('type', function() { - it('should parse type', function() { + describe('type', () => { + it('should parse type', () => { resource.type = 'text'; siren = buildField(); expect(siren.type).to.equal('text'); }); - it('should require type be a string, if supplied', function() { + it('should require type be a string, if supplied', () => { resource.type = 1; expect(buildField.bind(undefined, resource)).to.throw('field.type must be a valid field type string or undefined, got 1'); }); - it('should require type be a valid HTML5 input type, if specified', function() { + it('should require type be a valid HTML5 input type, if specified', () => { resource.type = 'bar'; expect(buildField.bind()).to.throw('field.type must be a valid field type string or undefined, got "bar"'); }); }); - describe('min', function() { - it('should parse min of 0', function() { + describe('min', () => { + it('should parse min of 0', () => { resource.min = 0; siren = buildField(); expect(siren.min).to.equal(0); }); - it('should parse min of 1', function() { + it('should parse min of 1', () => { resource.min = 1; siren = buildField(); expect(siren.min).to.equal(1); }); - it ('should not have min if undefined', function() { + it ('should not have min if undefined', () => { resource.min = undefined; siren = buildField(); expect(siren.min).to.be.undefined; }); - it('should require min be a number, if supplied', function() { + it('should require min be a number, if supplied', () => { resource.min = '1'; expect(buildField.bind(undefined, resource)).to.throw('field.min must be a number or undefined, got "1"'); }); }); - describe('max', function() { - it('should parse max of 0', function() { + describe('max', () => { + it('should parse max of 0', () => { resource.max = 0; siren = buildField(); expect(siren.max).to.equal(0); }); - it('should parse max of 9999', function() { + it('should parse max of 9999', () => { resource.max = 9999; siren = buildField(); expect(siren.max).to.equal(9999); }); - it ('should not have max if undefined', function() { + it ('should not have max if undefined', () => { resource.max = undefined; siren = buildField(); expect(siren.max).to.be.undefined; }); - it('should require max be a number, if supplied', function() { + it('should require max be a number, if supplied', () => { resource.max = '9999'; expect(buildField.bind(undefined, resource)).to.throw('field.max must be a number or undefined, got "9999"'); }); }); - describe('toJSON', function() { + describe('toJSON', () => { function toJSON() { return JSON.stringify(buildField()); } - it('should stringify name', function() { + it('should stringify name', () => { expect(toJSON()).to.equal( '{"name":"foo"}' ); }); - it('should stringify value', function() { + it('should stringify value', () => { resource.value = 'bar'; expect(toJSON()).to.equal( '{"name":"foo","value":"bar"}' ); }); - it('should stringify class', function() { + it('should stringify class', () => { resource.class = ['abc']; expect(toJSON()).to.equal( '{"name":"foo","class":["abc"]}' ); }); - it('should stringify title', function() { + it('should stringify title', () => { resource.title = 'bar'; expect(toJSON()).to.equal( '{"name":"foo","title":"bar"}' ); }); - it('should stringify type', function() { + it('should stringify type', () => { resource.type = 'text'; expect(toJSON()).to.equal( '{"name":"foo","type":"text"}' ); }); - it('should stringify min', function() { + it('should stringify min', () => { resource.min = 1; expect(toJSON()).to.equal( '{"name":"foo","min":1}' ); }); - it('should stringify max', function() { + it('should stringify max', () => { resource.max = 9999; expect(toJSON()).to.equal( '{"name":"foo","max":9999}' diff --git a/test/link.js b/test/link.js index 92edfca..9c05164 100644 --- a/test/link.js +++ b/test/link.js @@ -5,13 +5,13 @@ import sinonChai from 'sinon-chai'; use(sinonChai); -describe('Link', function() { +describe('Link', () => { let resource, sandbox, siren; - beforeEach(function() { + beforeEach(() => { resource = { rel: [], href: 'foo' @@ -22,7 +22,7 @@ describe('Link', function() { sandbox.stub(console, 'warn'); }); - afterEach(function() { + afterEach(() => { sandbox.restore(); }); @@ -30,62 +30,62 @@ describe('Link', function() { return new Link(resource); } - it('should auto-instantiate', function() { + it('should auto-instantiate', () => { expect(Link(resource)).to.be.an.instanceof(Link); }); - it('should require the link be an object', function() { + it('should require the link be an object', () => { resource = 1; expect(buildLink.bind()).to.throw('link must be an object, got 1'); }); - describe('rel', function() { - it('should require a rel', function() { + describe('rel', () => { + it('should require a rel', () => { resource.rel = undefined; expect(buildLink.bind()).to.throw('link.rel must be an array, got undefined'); }); - it('should require rel be an array', function() { + it('should require rel be an array', () => { resource.rel = 1; expect(buildLink.bind()).to.throw('link.rel must be an array, got 1'); }); - it('should parse rel', function() { + it('should parse rel', () => { siren = buildLink(); expect(siren.rel).to.be.an.instanceof(Array); }); }); - describe('href', function() { - it('should require a href', function() { + describe('href', () => { + it('should require a href', () => { resource.href = undefined; expect(buildLink.bind()).to.throw('link.href must be a string, got undefined'); }); - it('should require href be a string', function() { + it('should require href be a string', () => { resource.href = 1; expect(buildLink.bind()).to.throw('link.href must be a string, got 1'); }); - it('should parse href', function() { + it('should parse href', () => { siren = buildLink(); expect(siren.href).to.equal('foo'); }); }); - describe('class', function() { - it('should parse class', function() { + describe('class', () => { + it('should parse class', () => { resource.class = []; siren = buildLink(); expect(siren.class).to.be.an.instanceof(Array); }); - it('should require class be an array, if supplied', function() { + it('should require class be an array, if supplied', () => { resource.class = 1; expect(buildLink.bind()).to.throw('link.class must be an array or undefined, got 1'); }); - it('should be able to determine if a link has a given class', function() { + it('should be able to determine if a link has a given class', () => { resource.class = ['foo']; siren = buildLink(); expect(siren.hasClass('foo')).to.be.true; @@ -99,58 +99,58 @@ describe('Link', function() { }); }); - describe('title', function() { - it('should parse title', function() { + describe('title', () => { + it('should parse title', () => { resource.title = 'baz'; siren = buildLink(); expect(siren.title).to.equal('baz'); }); - it('should require title be a string, if supplied', function() { + it('should require title be a string, if supplied', () => { resource.title = 1; expect(buildLink.bind(undefined, resource)).to.throw('link.title must be a string or undefined, got 1'); }); }); - describe('type', function() { - it('should parse type', function() { + describe('type', () => { + it('should parse type', () => { resource.type = 'baz'; siren = buildLink(); expect(siren.type).to.equal('baz'); }); - it('should require type be a string, if supplied', function() { + it('should require type be a string, if supplied', () => { resource.type = 1; expect(buildLink.bind(undefined, resource)).to.throw('link.type must be a string or undefined, got 1'); }); }); - describe('toJSON', function() { + describe('toJSON', () => { function toJSON() { return JSON.stringify(buildLink()); } - it('should stringify rel and href', function() { + it('should stringify rel and href', () => { expect(toJSON()).to.equal( '{"rel":[],"href":"foo"}' ); }); - it('should stringify class', function() { + it('should stringify class', () => { resource.class = ['abc']; expect(toJSON()).to.equal( '{"rel":[],"href":"foo","class":["abc"]}' ); }); - it('should stringify title', function() { + it('should stringify title', () => { resource.title = 'bar'; expect(toJSON()).to.equal( '{"rel":[],"href":"foo","title":"bar"}' ); }); - it('should stringify type', function() { + it('should stringify type', () => { resource.type = 'text/html'; expect(toJSON()).to.equal( '{"rel":[],"href":"foo","type":"text/html"}' diff --git a/test/superagent.js b/test/superagent.js index a58cbb8..484b3e5 100644 --- a/test/superagent.js +++ b/test/superagent.js @@ -10,22 +10,22 @@ import sirenChai from '../src/chaiPlugin.js'; use(sinonChai); use(sirenChai); -describe('Siren Superagent Plugin', function() { +describe('Siren Superagent Plugin', () => { let app, src; - beforeEach(function() { + beforeEach(() => { app = undefined; src = 'http://localhost'; }); - afterEach(function() { + afterEach(() => { if (app) { expect(app.isDone()).to.be.true; } }); - describe('parser', function() { - it('should parse a json body', function(done) { + describe('parser', () => { + it('should parse a json body', done => { app = nock(src) .get('/') .reply(200, {}); @@ -34,14 +34,14 @@ describe('Siren Superagent Plugin', function() { .get('/') .parse(parse) .expect(200) - .expect(function(res) { + .expect((res) => { expect(res.body).to.be.an.instanceof(Entity); }) .end(done); }); // Emits a "double callback!" warning due to https://github.com/visionmedia/superagent/issues/633 - it('should throw an error when parsing fails', function(done) { + it('should throw an error when parsing fails', done => { app = nock(src) .get('/') .reply(200, 'not json'); @@ -49,33 +49,33 @@ describe('Siren Superagent Plugin', function() { request(src) .get('/') .parse(parse) - .end(function(err, res) { + .end((err, res) => { expect(err).to.be.an.instanceof(SyntaxError); expect(res).to.be.undefined; done(); }); }); - it('should parse a string as a siren entity', function() { + it('should parse a string as a siren entity', () => { const entity = parse('{}'); expect(entity).to.be.an.instanceof(Entity); }); }); - describe('perform action', function() { + describe('perform action', () => { let resource; function buildAction() { return new Action(resource); } - beforeEach(function() { + beforeEach(() => { resource = { name: 'foo', href: '/' }; }); - it('should perform a basic action', function(done) { + it('should perform a basic action', done => { app = nock(src) .get('/') .reply(200); @@ -87,7 +87,7 @@ describe('Siren Superagent Plugin', function() { }); function testMethodWithQuery(method) { - it(`should perform a ${method} action with fields`, function(done) { + it(`should perform a ${method} action with fields`, done => { app = nock(src)[method.toLowerCase()]('/') .query({ query: 'parameter' }) .reply(200); @@ -107,7 +107,7 @@ describe('Siren Superagent Plugin', function() { } function testMethodWithBody(method) { - it(`should perform a ${method} action with fields`, function(done) { + it(`should perform a ${method} action with fields`, done => { app = nock(src)[method.toLowerCase()]('/', 'query=parameter') .reply(200); @@ -132,7 +132,7 @@ describe('Siren Superagent Plugin', function() { testMethodWithBody('PATCH'); testMethodWithBody('DELETE'); - it('should add list of fields on performed action', function(done) { + it('should add list of fields on performed action', done => { app = nock(src) .get('/') .query({ query: 'parameter' }) @@ -150,7 +150,7 @@ describe('Siren Superagent Plugin', function() { .end(done); }); - it('should add fields on performed action', function(done) { + it('should add fields on performed action', done => { app = nock(src) .get('/') .query({ query: 'parameter' }) @@ -163,7 +163,7 @@ describe('Siren Superagent Plugin', function() { .end(done); }); - it('should add fields string on performed action', function(done) { + it('should add fields string on performed action', done => { app = nock(src) .get('/') .query({ query: 'parameter' })