Skip to content

Commit cc10a98

Browse files
Merge pull request #197 from UmiKami/140-modulo
added test to check if user is using modulo operator to get the remainder
2 parents 3caa087 + 18472ac commit cc10a98

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

exercises/140-modulo/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const fs = require('fs');
2+
const path = require('path');
13
const rewire = require('rewire');
24
const modulo = rewire('./app.js').__get__('modulo');
35

@@ -32,3 +34,11 @@ test('The module always returns the sign of the first number. Testing with (-25,
3234
test('If any of the operators is different from a number, then the result is NaN', () => {
3335
expect(modulo(25, 'hey')).toBe(NaN);
3436
});
37+
38+
test('You should not use the modulo operator (%) at all', () => {
39+
const file = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8');
40+
const regex = /\s*%\s*/gm
41+
expect(regex.test(file.toString())).toBeFalsy();
42+
});
43+
44+

0 commit comments

Comments
 (0)