Created
December 7, 2016 18:36
-
-
Save rogeliog/f234187043666b8b52d20621ecf7883a to your computer and use it in GitHub Desktop.
files not having a JS extension + files with no extension at all
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const r = new RegExp('^(?!.*\.js$).*$'); | |
it('Does not matches .js files', () => { | |
expect(r.test('dir/myFile.js')).toBeFalsy(); | |
expect(r.test('dir.ext/myFile.js')).toBeFalsy(); | |
expect(r.test('myFile.js')).toBeFalsy(); | |
}) | |
it('Matchs other extensions', () => { | |
expect(r.test('dir.something/myFile.other')).toBeTruthy(); | |
expect(r.test('myFile.other')).toBeTruthy(); | |
expect(r.test('myFile.jspy')).toBeTruthy(); | |
expect(r.test('myFile.jsx')).toBeTruthy(); | |
expect(r.test('myFile.py')).toBeTruthy(); | |
// It fails for this case | |
// expect(r.test('myFile.foojs')).toBeTruthy(); | |
}) | |
it('Matches files with no extension', () => { | |
expect(r.test('dir/myFile')).toBeTruthy(); | |
expect(r.test('myFile')).toBeTruthy(); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment