Skip to content

Commit 59ddbb2

Browse files
Change toBe to toEqual when ref equals not needed
1 parent 9e90364 commit 59ddbb2

File tree

4 files changed

+34
-34
lines changed

4 files changed

+34
-34
lines changed

angular-reactive-validation/src/get-control-path.spec.ts

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

23-
expect(getControlPath(firstName)).toBe('name.firstName');
23+
expect(getControlPath(firstName)).toEqual('name.firstName');
2424
}));
2525

2626
it(`emits numeric paths for form arrays`, inject([FormBuilder], (fb: FormBuilder) => {
@@ -38,22 +38,22 @@ describe('getControlPath', () => {
3838
])
3939
});
4040

41-
expect(getControlPath(firstName)).toBe('persons.0.firstName');
42-
expect(getControlPath(firstName2)).toBe('persons.1.firstName');
41+
expect(getControlPath(firstName)).toEqual('persons.0.firstName');
42+
expect(getControlPath(firstName2)).toEqual('persons.1.firstName');
4343
}));
4444

4545
it(`emits an empty string for a control without parents`, inject([FormBuilder], (fb: FormBuilder) => {
4646
const control = fb.control('');
4747

48-
expect(getControlPath(control)).toBe('');
48+
expect(getControlPath(control)).toEqual('');
4949
}));
5050

5151
it(`emits an index string for a control with only a form array as parent`, inject([FormBuilder], (fb: FormBuilder) => {
5252
const control = fb.control('');
5353

5454
fb.array([control]);
5555

56-
expect(getControlPath(control)).toBe('0');
56+
expect(getControlPath(control)).toEqual('0');
5757
}));
5858

5959
it(`emits a single identifier for a control with only a single form group as parent`, inject([FormBuilder], (fb: FormBuilder) => {
@@ -63,6 +63,6 @@ describe('getControlPath', () => {
6363
control: control
6464
});
6565

66-
expect(getControlPath(control)).toBe('control');
66+
expect(getControlPath(control)).toEqual('control');
6767
}));
6868
});

angular-reactive-validation/src/observable-container.spec.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,71 +12,71 @@ describe('ObservableContainer', () => {
1212
const container = new ObservableContainer(() => called = true);
1313

1414
container.subscribe({}, () => subject);
15-
expect(called).toBe(false);
15+
expect(called).toEqual(false);
1616
subject.next();
17-
expect(called).toBe(true);
17+
expect(called).toEqual(true);
1818
});
1919

2020
it(`calls the function on subscribe`, () => {
2121
let called = false;
2222
const container = new ObservableContainer(() => called = true);
2323

2424
container.subscribe({}, () => subject, true);
25-
expect(called).toBe(true);
25+
expect(called).toEqual(true);
2626
});
2727

2828
it(`calls the function multiple times when the observable emits multiple times`, () => {
2929
let calls = 0;
3030
const container = new ObservableContainer(() => calls++);
3131

3232
container.subscribe({}, () => subject);
33-
expect(calls).toBe(0);
33+
expect(calls).toEqual(0);
3434
subject.next();
3535
subject.next();
36-
expect(calls).toBe(2);
36+
expect(calls).toEqual(2);
3737
});
3838

3939
it(`calls the function once per subscribing object`, () => {
4040
let calls = 0;
41-
const objA = {};
42-
const objB = {};
41+
const objA = { x: 1 };
42+
const objB = { x: 2 };
4343
const container = new ObservableContainer(obj => {
4444
if (calls === 0) {
45-
expect(obj).toEqual(objA);
45+
expect(obj).toBe(objA);
4646
} else {
47-
expect(obj).toEqual(objB);
47+
expect(obj).toBe(objB);
4848
}
4949
calls++;
5050
});
5151

52-
container.subscribe([objA, {}], () => subject);
53-
expect(calls).toBe(0);
52+
container.subscribe([objA, objB], () => subject);
53+
expect(calls).toEqual(0);
5454
subject.next();
55-
expect(calls).toBe(2);
55+
expect(calls).toEqual(2);
5656
});
5757

5858
it(`unsubscribes and no longer calls the function when the observable emits`, () => {
5959
let calls = 0;
6060
const container = new ObservableContainer(() => calls++);
6161

6262
container.subscribe([{}, {}], () => subject);
63-
expect(subject.observers.length).toBe(2);
63+
expect(subject.observers.length).toEqual(2);
6464

6565
container.unsubscribeAll();
66-
expect(subject.observers.length).toBe(0);
66+
expect(subject.observers.length).toEqual(0);
6767

6868
subject.next();
69-
expect(calls).toBe(0);
69+
expect(calls).toEqual(0);
7070
});
7171

7272
it(`doesn't subscribe or call the function when no objects are provided`, () => {
7373
let called = false;
7474
const container = new ObservableContainer(() => called = true);
7575

7676
container.subscribe([], () => subject);
77-
expect(subject.observers.length).toBe(0);
78-
expect(called).toBe(false);
77+
expect(subject.observers.length).toEqual(0);
78+
expect(called).toEqual(false);
7979
subject.next();
80-
expect(called).toBe(false);
80+
expect(called).toEqual(false);
8181
});
8282
});

angular-reactive-validation/src/validation-error.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('ValidationError', () => {
1212
const error = ValidationError.fromFirstError(control);
1313

1414
expect(error.control).toEqual(control);
15-
expect(error.key).toBe('required');
15+
expect(error.key).toEqual('required');
1616
expect(error.errorObject).toEqual(requiredErrorObject);
1717
});
1818

@@ -22,7 +22,7 @@ describe('ValidationError', () => {
2222
};
2323
const error = ValidationError.fromFirstError(control);
2424

25-
expect(error).toBe(undefined);
25+
expect(error).toEqual(undefined);
2626
});
2727

2828
it(`hasMessage returns true when the errorObject contains a message`, () => {
@@ -34,7 +34,7 @@ describe('ValidationError', () => {
3434
}
3535
};
3636
const error = ValidationError.fromFirstError(control);
37-
expect(error.hasMessage()).toBe(true);
37+
expect(error.hasMessage()).toEqual(true);
3838
});
3939

4040
it(`hasMessage returns false when the errorObject doesn't contain a message`, () => {
@@ -44,7 +44,7 @@ describe('ValidationError', () => {
4444
}
4545
};
4646
const error = ValidationError.fromFirstError(control);
47-
expect(error.hasMessage()).toBe(false);
47+
expect(error.hasMessage()).toEqual(false);
4848
});
4949

5050
it(`getMessage returns the message from the errorObject`, () => {
@@ -57,6 +57,6 @@ describe('ValidationError', () => {
5757
}
5858
};
5959
const error = ValidationError.fromFirstError(control);
60-
expect(error.getMessage()).toBe(expected);
60+
expect(error.getMessage()).toEqual(expected);
6161
});
6262
});

angular-reactive-validation/src/validation-message/validation-message.component.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('ValidationMessageComponent', () => {
2424

2525
const result = component.canHandle(error);
2626

27-
expect(result).toBe(true);
27+
expect(result).toEqual(true);
2828
});
2929

3030
it(`canHandle returns true when the error key and component key are equal (with for)`, () => {
@@ -34,7 +34,7 @@ describe('ValidationMessageComponent', () => {
3434

3535
const result = component.canHandle(error);
3636

37-
expect(result).toBe(true);
37+
expect(result).toEqual(true);
3838
});
3939

4040
it(`canHandle returns false when the component 'for' doesn't equal the error's control`, () => {
@@ -44,7 +44,7 @@ describe('ValidationMessageComponent', () => {
4444

4545
const result = component.canHandle(error);
4646

47-
expect(result).toBe(false);
47+
expect(result).toEqual(false);
4848
});
4949

5050
it(`canHandle returns false when the error key doesn't equal the component key`, () => {
@@ -53,7 +53,7 @@ describe('ValidationMessageComponent', () => {
5353

5454
const result = component.canHandle(error);
5555

56-
expect(result).toBe(false);
56+
expect(result).toEqual(false);
5757
});
5858

5959
function setupErrorMessageTests(): {
@@ -81,7 +81,7 @@ describe('ValidationMessageComponent', () => {
8181
fixture.detectChanges();
8282
expect(fixture.nativeElement.querySelector('.message')).not.toBeFalsy();
8383
expect(fixture.nativeElement.querySelector('.message').textContent)
84-
.toBe(`The message is shown. requiredLength: ${error.errorObject.requiredLength}`);
84+
.toEqual(`The message is shown. requiredLength: ${error.errorObject.requiredLength}`);
8585
});
8686

8787
it(`reset hides the error message`, () => {

0 commit comments

Comments
 (0)