Change arrow functions with anonymous functions

This commit is contained in:
Nito Buendia
2022-03-16 21:14:43 +08:00
parent b2c2e08641
commit 2e8b477489

View File

@@ -1,53 +1,53 @@
describe('toHaveSpyInteractions', () => { describe('toHaveSpyInteractions', function() {
let spyObj; let spyObj;
beforeEach(() => { beforeEach(function() {
spyObj = jasmineUnderTest.createSpyObj('NewClass', ['spyA', 'spyB']); spyObj = jasmine.createSpyObj('NewClass', ['spyA', 'spyB']);
spyObj.otherMethod = function() {}; spyObj.otherMethod = function() {};
}); });
it('detects spy interactions', () => { it('detects spy interactions', function() {
spyObj.spyA(); spyObj.spyA();
expect(spyObj).toHaveSpyInteractions(); expect(spyObj).toHaveSpyInteractions();
}); });
it('detects multiple spy interactions', () => { it('detects multiple spy interactions', function() {
spyObj.spyA(); spyObj.spyA();
spyObj.spyB(); spyObj.spyB();
spyObj.spyA(); spyObj.spyA();
expect(spyObj).toHaveSpyInteractions(); expect(spyObj).toHaveSpyInteractions();
}); });
it('detects no spy interactions', () => { it('detects no spy interactions', function() {
expect(spyObj).not.toHaveSpyInteractions(); expect(spyObj).not.toHaveSpyInteractions();
}); });
it('ignores non-observed spy object interactions', () => { it('ignores non-observed spy object interactions', function() {
spyObj.otherMethod(); spyObj.otherMethod();
expect(spyObj).not.toHaveSpyInteractions(); expect(spyObj).not.toHaveSpyInteractions();
}); });
[true, 123, 'string'].forEach(testValue => { [true, 123, 'string'].forEach(function(testValue) {
it(`throws error if a non-object (${testValue}) is passed`, () => { it(`throws error if a non-object (${testValue}) is passed`, function() {
expect(() => { expect(function() {
expect(true).toHaveSpyInteractions(); expect(true).toHaveSpyInteractions();
}).toThrowError(Error, /Expected a spy object, but got/); }).toThrowError(Error, /Expected a spy object, but got/);
}); });
}); });
[['argument'], [false, 0]].forEach(testValue => { [['argument'], [false, 0]].forEach(function(testValue) {
it(`throws error if arguments (${testValue}) are passed`, () => { it(`throws error if arguments (${testValue}) are passed`, function() {
expect(() => { expect(function() {
expect(spyObj).toHaveSpyInteractions(...testValue); expect(spyObj).toHaveSpyInteractions(...testValue);
}).toThrowError(Error, /Does not take arguments/); }).toThrowError(Error, /Does not take arguments/);
}); });
}); });
it('throws error if spy object has no spies', () => { it('throws error if spy object has no spies', function() {
const newSpyObj = jasmine.createSpyObj('OtherClass', ['method']); const newSpyObj = jasmine.createSpyObj('OtherClass', ['method']);
// Removing spy since spy objects cannot be created without spies. // Removing spy since spy objects cannot be created without spies.
newSpyObj.method = function() {}; newSpyObj.method = function() {};
expect(() => { expect(function() {
expect(newSpyObj).toHaveSpyInteractions(); expect(newSpyObj).toHaveSpyInteractions();
}).toThrowError( }).toThrowError(
Error, Error,