Skip to content

Commit 5d980a1

Browse files
Fix environments tests randomness (#1394)
* Fix environments tests randomness * Use `have members`
1 parent bf0ab80 commit 5d980a1

1 file changed

Lines changed: 8 additions & 21 deletions

File tree

test/lib/usecases/environment/GetAllEnvironmentsUseCase.test.js

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ module.exports = () => {
4444

4545
expect(environments).to.be.an('array');
4646
expect(environments.length).to.be.equal(3);
47-
expect(environments[0].id).to.be.equal('SomeId');
48-
expect(environments[1].id).to.be.equal('newId');
49-
expect(environments[2].id).to.be.equal('CmCvjNbg');
47+
expect(environments.map(({ id }) => id)).to.have.members(['SomeId', 'newId', 'CmCvjNbg']);
5048
});
5149

5250
it('should successfully filter environments on a list of ids with a non existing id', async () => {
@@ -55,8 +53,7 @@ module.exports = () => {
5553

5654
expect(environments).to.be.an('array');
5755
expect(environments.length).to.be.equal(2);
58-
expect(environments[0].id).to.be.equal('SomeId');
59-
expect(environments[1].id).to.be.equal('newId');
56+
expect(environments.map(({ id }) => id)).to.have.members(['SomeId', 'newId']);
6057
});
6158

6259
it('should successfully filter environments on one current status', async () => {
@@ -65,8 +62,7 @@ module.exports = () => {
6562

6663
expect(environments).to.be.an('array');
6764
expect(environments.length).to.be.equal(2);
68-
expect(environments[0].id).to.be.equal('CmCvjNbg');
69-
expect(environments[1].id).to.be.equal('Dxi029djX');
65+
expect(environments.map(({ id }) => id)).to.have.members(['CmCvjNbg', 'Dxi029djX']);
7066
});
7167

7268
it('should successfully filter environments on multiple current statusses', async () => {
@@ -75,12 +71,7 @@ module.exports = () => {
7571

7672
expect(environments).to.be.an('array');
7773
expect(environments.length).to.be.equal(6);
78-
expect(environments[0].id).to.be.equal('SomeId');
79-
expect(environments[1].id).to.be.equal('newId');
80-
expect(environments[2].id).to.be.equal('CmCvjNbg');
81-
expect(environments[3].id).to.be.equal('EIDO13i3D');
82-
expect(environments[4].id).to.be.equal('8E4aZTjY');
83-
expect(environments[5].id).to.be.equal('Dxi029djX');
74+
expect(environments.map(({ id }) => id)).to.have.members(['SomeId', 'newId', 'CmCvjNbg', 'EIDO13i3D', '8E4aZTjY', 'Dxi029djX']);
8475
});
8576

8677
it('should successfully filter environments on status history with - input', async () => {
@@ -89,8 +80,7 @@ module.exports = () => {
8980

9081
expect(environments).to.be.an('array');
9182
expect(environments.length).to.be.equal(2);
92-
expect(environments[0].id).to.be.equal('EIDO13i3D');
93-
expect(environments[1].id).to.be.equal('8E4aZTjY');
83+
expect(environments.map(({ id }) => id)).to.have.members(['EIDO13i3D', '8E4aZTjY']);
9484
});
9585

9686
it('should successfully filter environments on status history without - input', async () => {
@@ -99,8 +89,7 @@ module.exports = () => {
9989

10090
expect(environments).to.be.an('array');
10191
expect(environments.length).to.be.equal(2);
102-
expect(environments[0].id).to.be.equal('EIDO13i3D');
103-
expect(environments[1].id).to.be.equal('8E4aZTjY');
92+
expect(environments.map(({ id }) => id)).to.have.members(['EIDO13i3D', '8E4aZTjY']);
10493
});
10594

10695
it('should successfully filter environments on status history with equal input with -', async () => {
@@ -142,8 +131,7 @@ module.exports = () => {
142131

143132
expect(environments).to.be.an('array');
144133
expect(environments.length).to.be.equal(2);
145-
expect(environments[0].id).to.be.equal('TDI59So3d');
146-
expect(environments[1].id).to.be.equal('EIDO13i3D');
134+
expect(environments.map(({ id }) => id)).to.have.members(['EIDO13i3D', 'TDI59So3d']);
147135
});
148136

149137
it('should successfully filter environments run numbers with limit', async () => {
@@ -171,7 +159,6 @@ module.exports = () => {
171159
expect(environments).to.be.an('array');
172160
expect(environments.length).to.be.equal(2);
173161
// Should include all environments with run numbers containing the substring 10
174-
expect(environments[0].id).to.be.equal('TDI59So3d');
175-
expect(environments[1].id).to.be.equal('Dxi029djX');
162+
expect(environments.map(({ id }) => id)).to.have.members(['TDI59So3d', 'Dxi029djX']);
176163
});
177164
};

0 commit comments

Comments
 (0)