Skip to content

Commit 279094b

Browse files
committed
test(predicates): Corrected the assertions around error handling
1 parent 46d69ff commit 279094b

16 files changed

+21
-19
lines changed

spec/predicates/and.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('predicates', () => {
2323
}
2424

2525
it('ensures that all the predicates are met', () => {
26-
expect(new InvestmentLengthInYears(10)).to.not.throw; // tslint:disable-line:no-unused-expression
26+
expect(() => new InvestmentLengthInYears(10)).to.not.throw; // tslint:disable-line:no-unused-expression
2727
});
2828

2929
given(

spec/predicates/hasLengthOf.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('predicates', () => {
2020
}
2121

2222
it('ensures that the value has a correct length', () => {
23-
expect(new Password('P@ssw0rd')).to.not.throw; // tslint:disable-line:no-unused-expression
23+
expect(() => new Password('P@ssw0rd')).to.not.throw; // tslint:disable-line:no-unused-expression
2424
});
2525

2626
given(
@@ -43,7 +43,7 @@ describe('predicates', () => {
4343
}
4444

4545
it('ensures that the value has a correct length', () => {
46-
expect(new Collection(['a', 'b'])).to.not.throw; // tslint:disable-line:no-unused-expression
46+
expect(() => new Collection(['a', 'b'])).to.not.throw; // tslint:disable-line:no-unused-expression
4747
});
4848

4949
given(

spec/predicates/isArray.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('predicates', () => {
1818
}
1919

2020
it('ensures that the argument is an array', () => {
21-
expect(new Strings(['lorem', 'ipsum'])).to.not.throw; // tslint:disable-line:no-unused-expression
21+
expect(() => new Strings(['lorem', 'ipsum'])).to.not.throw; // tslint:disable-line:no-unused-expression
2222
});
2323

2424
given(

spec/predicates/isBoolean.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('predicates', () => {
1818
}
1919

2020
it('ensures that the argument is a boolean value', () => {
21-
expect(new MarketingOptIn(false)).to.not.throw; // tslint:disable-line:no-unused-expression
21+
expect(() => new MarketingOptIn(false)).to.not.throw; // tslint:disable-line:no-unused-expression
2222
});
2323

2424
given(

spec/predicates/isDefined.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('predicates', () => {
1717
}
1818

1919
it('ensures that the value is defined', () => {
20-
expect(() => new UserName('Jan')).to.not.throw; // tslint:disable-line:no-unused-expression
20+
expect(() => new UserName('Jan')).to.not.throw; // tslint:disable-line:no-unused-expression
2121
});
2222

2323
given<any>(
@@ -26,7 +26,7 @@ describe('predicates', () => {
2626
true,
2727
false,
2828
).it('works for any defined value, even the "falsy" ones', (value: any) => {
29-
expect(new UserName(value)).to.not.throw; // tslint:disable-line:no-unused-expression
29+
expect(() => new UserName(value)).to.not.throw; // tslint:disable-line:no-unused-expression
3030
});
3131
});
3232
});

spec/predicates/isEqualTo.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ describe('predicates', () => {
2929

3030
const upgradeOwnAccount = new UpgradeAccount(loggedInUser);
3131

32-
expect(accounts.handle(upgradeOwnAccount)).to.not.throw; // tslint:disable-line:no-unused-expression
32+
// tslint:disable-next-line:no-unused-expression
33+
expect(() => accounts.handle(upgradeOwnAccount)).to.not.throw;
3334
});
3435

3536
it('complains if the objects are not identical by value', () => {
@@ -58,7 +59,8 @@ describe('predicates', () => {
5859
[],
5960
).
6061
it('ensures they are equal', (value: any) => {
61-
expect(ensure('Val', value, isEqualTo(value))).to.not.throw; // tslint:disable-line:no-unused-expression
62+
// tslint:disable-next-line:no-unused-expression
63+
expect(() => ensure('Val', value, isEqualTo(value))).to.not.throw;
6264
});
6365

6466
given(

spec/predicates/isGreaterThan.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('predicates', () => {
1717
}
1818

1919
it('ensures that the argument is greater than a specified number', () => {
20-
expect(new InvestmentLength(5)).to.not.throw; // tslint:disable-line:no-unused-expression
20+
expect(() => new InvestmentLength(5)).to.not.throw; // tslint:disable-line:no-unused-expression
2121
});
2222

2323
it('complains if the argument is more than a specified number', () => {

spec/predicates/isGreaterThanOrEqualTo.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('predicates', () => {
1818

1919
given(0, 1).
2020
it('ensures that the argument is greater than or equal to a specified number', (value: number) => {
21-
expect(new InvestmentLength(value)).to.not.throw; // tslint:disable-line:no-unused-expression
21+
expect(() => new InvestmentLength(value)).to.not.throw; // tslint:disable-line:no-unused-expression
2222
});
2323

2424
it('complains if the argument is less than the lower bound', () => {

spec/predicates/isInRange.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('predicates', () => {
1919

2020
given(1, 2, 3, 4, 5).
2121
it('ensures that the value is within the range specified', (value: number) => {
22-
expect(new InvestmentLength(value)).to.not.throw; // tslint:disable-line:no-unused-expression
22+
expect(() => new InvestmentLength(value)).to.not.throw; // tslint:disable-line:no-unused-expression
2323
});
2424

2525
it('complains if the value is lower than the lower bound', () => {

spec/predicates/isInteger.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('predicates', () => {
1717
}
1818

1919
it('ensures that the argument in an integer', () => {
20-
expect(new AgeInYears(42)).to.not.throw; // tslint:disable-line:no-unused-expression
20+
expect(() => new AgeInYears(42)).to.not.throw; // tslint:disable-line:no-unused-expression
2121
});
2222

2323
given(

spec/predicates/isLessThan.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('predicates', () => {
1717
}
1818

1919
it('ensures that the argument is less than a specified number', () => {
20-
expect(new InvestmentLength(5)).to.not.throw; // tslint:disable-line:no-unused-expression
20+
expect(() => new InvestmentLength(5)).to.not.throw; // tslint:disable-line:no-unused-expression
2121
});
2222

2323
it('complains if the argument is more than a specified number', () => {

spec/predicates/isLessThanOrEqual.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('predicates', () => {
1818

1919
given(49, 50).
2020
it('ensures that the argument is less than or equal to the upper bound', (value: number) => {
21-
expect(new InvestmentLength(value)).to.not.throw; // tslint:disable-line:no-unused-expression
21+
expect(() => new InvestmentLength(value)).to.not.throw; // tslint:disable-line:no-unused-expression
2222
});
2323

2424
it('complains if the argument is greater than the upper bound', () => {

spec/predicates/isNumber.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('predicates', () => {
1717
}
1818

1919
it('ensures that the argument in a number', () => {
20-
expect(new Percentage(42)).to.not.throw; // tslint:disable-line:no-unused-expression
20+
expect(() => new Percentage(42)).to.not.throw; // tslint:disable-line:no-unused-expression
2121
});
2222

2323
given(

spec/predicates/isOneOf.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('predicates', () => {
1919

2020
given('red', 'yellow', 'green').
2121
it('ensures that the value is equal to one of the allowed values', (value: string) => {
22-
expect(new StreetLight(value)).to.not.throw; // tslint:disable-line:no-unused-expression
22+
expect(() => new StreetLight(value)).to.not.throw; // tslint:disable-line:no-unused-expression
2323
});
2424

2525
it('complains if the value not one the allowed ones', () => {

spec/predicates/isString.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('predicates', () => {
1717
}
1818

1919
it('ensures that the argument in a string', () => {
20-
expect(new FirstName('Jan')).to.not.throw; // tslint:disable-line:no-unused-expression
20+
expect(() => new FirstName('Jan')).to.not.throw; // tslint:disable-line:no-unused-expression
2121
});
2222

2323
given(

spec/predicates/or.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('predicates', () => {
2323

2424
given(0, 1, 99, 100).
2525
it('ensures that at least one of the `or` predicates is met', (value: number) => {
26-
expect(new Percentage(value)).to.not.throw; // tslint:disable-line:no-unused-expression
26+
expect(() => new Percentage(value)).to.not.throw; // tslint:disable-line:no-unused-expression
2727
});
2828

2929
given(

0 commit comments

Comments
 (0)