Run formatter

This commit is contained in:
Nito Buendia
2022-03-16 23:01:20 +08:00
parent faf210ab4c
commit 1660015c12
2 changed files with 33 additions and 24 deletions

View File

@@ -1,8 +1,9 @@
describe('toHaveSpyInteractions', function () { describe('toHaveSpyInteractions', function() {
it('detects spy interactions', function() {
it('detects spy interactions', function () {
let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions();
let spyObj = jasmineUnderTest.getEnv().createSpyObj('NewClass', ['spyA', 'spyB']); let spyObj = jasmineUnderTest
.getEnv()
.createSpyObj('NewClass', ['spyA', 'spyB']);
spyObj.spyA(); spyObj.spyA();
@@ -13,9 +14,11 @@ describe('toHaveSpyInteractions', function () {
); );
}); });
it('detects multiple spy interactions', function () { it('detects multiple spy interactions', function() {
let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions();
let spyObj = jasmineUnderTest.getEnv().createSpyObj('NewClass', ['spyA', 'spyB']); let spyObj = jasmineUnderTest
.getEnv()
.createSpyObj('NewClass', ['spyA', 'spyB']);
spyObj.spyA(); spyObj.spyA();
spyObj.spyB(); spyObj.spyB();
@@ -28,9 +31,11 @@ describe('toHaveSpyInteractions', function () {
); );
}); });
it('detects no spy interactions', function () { it('detects no spy interactions', function() {
let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions();
let spyObj = jasmineUnderTest.getEnv().createSpyObj('NewClass', ['spyA', 'spyB']); let spyObj = jasmineUnderTest
.getEnv()
.createSpyObj('NewClass', ['spyA', 'spyB']);
let result = matcher.compare(spyObj); let result = matcher.compare(spyObj);
expect(result.pass).toBe(false); expect(result.pass).toBe(false);
@@ -39,10 +44,12 @@ describe('toHaveSpyInteractions', function () {
); );
}); });
it('ignores non-observed spy object interactions', function () { it('ignores non-observed spy object interactions', function() {
let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions();
let spyObj = jasmineUnderTest.getEnv().createSpyObj('NewClass', ['spyA', 'spyB']); let spyObj = jasmineUnderTest
spyObj.otherMethod = function () { }; .getEnv()
.createSpyObj('NewClass', ['spyA', 'spyB']);
spyObj.otherMethod = function() {};
spyObj.otherMethod(); spyObj.otherMethod();
@@ -53,32 +60,36 @@ describe('toHaveSpyInteractions', function () {
); );
}); });
[true, 123, 'string'].forEach(function (testValue) { [true, 123, 'string'].forEach(function(testValue) {
it(`throws error if a non-object (${testValue}) is passed`, function () { it(`throws error if a non-object (${testValue}) is passed`, function() {
let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions();
expect(function () { expect(function() {
matcher.compare(testValue); matcher.compare(testValue);
}).toThrowError(Error, /Expected a spy object, but got/); }).toThrowError(Error, /Expected a spy object, but got/);
}); });
}); });
it('throws error if arguments are passed', function () { it('throws error if arguments are passed', function() {
let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions();
let spyObj = jasmineUnderTest.getEnv().createSpyObj('NewClass', ['spyA', 'spyB']); let spyObj = jasmineUnderTest
.getEnv()
.createSpyObj('NewClass', ['spyA', 'spyB']);
expect(function () { expect(function() {
matcher.compare(spyObj, 'an argument'); matcher.compare(spyObj, 'an argument');
}).toThrowError(Error, /Does not take arguments/); }).toThrowError(Error, /Does not take arguments/);
}); });
it('throws error if spy object has no spies', function () { it('throws error if spy object has no spies', function() {
let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions(); let matcher = jasmineUnderTest.matchers.toHaveSpyInteractions();
const spyObj = jasmineUnderTest.getEnv().createSpyObj('NewClass', ['notSpy']); const spyObj = jasmineUnderTest
.getEnv()
.createSpyObj('NewClass', ['notSpy']);
// Removing spy since spy objects cannot be created without spies. // Removing spy since spy objects cannot be created without spies.
spyObj.notSpy = function () { }; spyObj.notSpy = function() {};
expect(function () { expect(function() {
matcher.compare(spyObj); matcher.compare(spyObj);
}).toThrowError( }).toThrowError(
Error, Error,

View File

@@ -19,9 +19,7 @@ getJasmineRequireObj().toHaveSpyInteractions = function(j$) {
if (!j$.isObject_(actual)) { if (!j$.isObject_(actual)) {
throw new Error( throw new Error(
getErrorMsg( getErrorMsg('Expected a spy object, but got ' + typeof actual + '.')
'Expected a spy object, but got ' + typeof actual + '.'
)
); );
} }