Permalink
Cannot retrieve contributors at this time
48 lines (38 sloc)
1.45 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/eslint-plugin-jsx-a11y/__tests__/src/util/getSuggestion-test.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
import expect from 'expect'; | |
import getSuggestion from '../../../src/util/getSuggestion'; | |
describe('spell check suggestion API', () => { | |
it('should return no suggestions given empty word and no dictionary', () => { | |
const word = ''; | |
const expected = []; | |
const actual = getSuggestion(word); | |
expect(expected).toEqual(actual); | |
}); | |
it('should return no suggestions given real word and no dictionary', () => { | |
const word = 'foo'; | |
const expected = []; | |
const actual = getSuggestion(word); | |
expect(expected).toEqual(actual); | |
}); | |
it('should return correct suggestion given real word and a dictionary', () => { | |
const word = 'fo'; | |
const dictionary = ['foo', 'bar', 'baz']; | |
const expected = ['foo']; | |
const actual = getSuggestion(word, dictionary); | |
expect(expected).toEqual(actual); | |
}); | |
it('should return multiple correct suggestions given real word and a dictionary', () => { | |
const word = 'theer'; | |
const dictionary = ['there', 'their', 'foo', 'bar']; | |
const expected = ['there', 'their']; | |
const actual = getSuggestion(word, dictionary); | |
expect(expected).toEqual(actual); | |
}); | |
it('should return correct # of suggestions given the limit argument', () => { | |
const word = 'theer'; | |
const dictionary = ['there', 'their', 'foo', 'bar']; | |
const limit = 1; | |
const expected = 1; | |
const actual = getSuggestion(word, dictionary, limit).length; | |
expect(expected).toEqual(actual); | |
}); | |
}); |