Download spectrum/shared/test/get-mentions.test.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.78 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/shared/test/get-mentions.test.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/shared/test/get-mentions.test.js
-
curl -L -o get-mentions.test.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/shared/test/get-mentions.test.js
2.78 kB
| // @flow | |
| import getMentions from '../get-mentions'; | |
| it('should return a mention', () => { | |
| expect(getMentions('Hey @mxstbr whassup')).toEqual(['mxstbr']); | |
| }); | |
| it('should return multiple mentions', () => { | |
| expect(getMentions('Hey @mxstbr @bryn whassup')).toEqual(['mxstbr', 'bryn']); | |
| }); | |
| it('should remove duplicate mentions', () => { | |
| expect(getMentions('Hey @mxstbr @bryn @mxstbr whassup')).toEqual([ | |
| 'mxstbr', | |
| 'bryn', | |
| ]); | |
| }); | |
| it('should work at the beginning of a string', () => { | |
| expect(getMentions('@mxstbr whassup')).toEqual(['mxstbr']); | |
| }); | |
| it('should work at the end of a string', () => { | |
| expect(getMentions('Hey @bryn')).toEqual(['bryn']); | |
| }); | |
| it('should ignore commas after mentions', () => { | |
| expect(getMentions('Hey @bryn, whassup?')).toEqual(['bryn']); | |
| }); | |
| it('should match underscores', () => { | |
| expect(getMentions('Hey @brian_lovin whassup')).toEqual(['brian_lovin']); | |
| }); | |
| it('should match minusses', () => { | |
| expect(getMentions('Hey @brian-lovin whassup')).toEqual(['brian-lovin']); | |
| }); | |
| it('should ignore parenthesis before mentions', () => { | |
| expect(getMentions('It is Bryn! (@bryn look)')).toEqual(['bryn']); | |
| }); | |
| it('should match mention in Japanese', () => { | |
| expect(getMentions('の@mxstbrに到着を待っている')).toEqual(['mxstbr']); | |
| }); | |
| it('should extract mention before newline', () => { | |
| expect(getMentions('@mxstbr\n@bryn')).toEqual(['mxstbr', 'bryn']); | |
| }); | |
| it('should not extract username from medium link with @', () => { | |
| expect( | |
| getMentions( | |
| 'https://medium.com/@probablyup/introducing-buttermilk-fc0b8c6d92af' | |
| ) | |
| ).toEqual([]); | |
| }); | |
| it('should extract username after link ending in /', () => { | |
| expect( | |
| getMentions( | |
| 'https://medium.com/@probablyup/introducing-buttermilk-fc0b8c6d92af/ @bryn' | |
| ) | |
| ).toEqual(['bryn']); | |
| }); | |
| describe.skip('failing tests', () => { | |
| it('should not extract username preceded by !', () => { | |
| expect(getMentions('f!@kn')).toEqual([]); | |
| }); | |
| it('should not extract username preceded by @', () => { | |
| expect(getMentions('f@@kn')).toEqual([]); | |
| }); | |
| it('should not extract username preceded by #', () => { | |
| expect(getMentions('f#@kn')).toEqual([]); | |
| }); | |
| it('should not extract username preceded by $', () => { | |
| expect(getMentions('f$@kn')).toEqual([]); | |
| }); | |
| it('should not extract username preceded by %', () => { | |
| expect(getMentions('f%@kn')).toEqual([]); | |
| }); | |
| it('should not extract username preceded by &', () => { | |
| expect(getMentions('f&@kn')).toEqual([]); | |
| }); | |
| it('should not extract username preceded by *', () => { | |
| expect(getMentions('f*@kn')).toEqual([]); | |
| }); | |
| it('should not extract username ending in @', () => { | |
| expect(getMentions('Current Status: @_@ (cc: @bryn)')).toEqual(['bryn']); | |
| }); | |
| }); | |