Skip to content

Instantly share code, notes, and snippets.

@ann-kilzer
Created July 10, 2020 06:20
Show Gist options
  • Save ann-kilzer/03ef15da4601ffc6dcc318c9455d5192 to your computer and use it in GitHub Desktop.
Save ann-kilzer/03ef15da4601ffc6dcc318c9455d5192 to your computer and use it in GitHub Desktop.
Japanese Validator Unit Test
import { expect } from 'chai';
import japanese from '@/validators/japanese';
describe('japanese.js', () => {
it('accepts Hiragana', () => {
expect(japanese('すごいですね!わたしはねこです。')).to.be.true;
});
it('accepts Katakana', () => {
expect(japanese('チーズバーガートネコ!')).to.be.true;
});
it('accepts Kanji', () => {
expect(japanese('鼠色大学')).to.be.true;
});
it('rejects Rōmaji', () => {
expect(japanese('This is Romaji')).to.be.false;
expect(japanese('すごいsurprise')).to.be.false;
});
it('rejects Emoji', () => {
expect(japanese('🧐')).to.be.false;
expect(japanese('すごい🧐')).to.be.false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment