This repository has been archived by the owner on Jun 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
201 additions
and
159 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
dist | ||
karma.conf.js | ||
lib | ||
powered-test | ||
src/doc |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ dist | |
lib | ||
node_modules | ||
npm-debug.log | ||
powered-test | ||
textcomplete | ||
/textcomplete-* | ||
npm-debug.log.* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ coverage | |
doc | ||
lib/main.js | ||
npm-debug.log | ||
powered-test | ||
src | ||
test | ||
textcomplete | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module.exports = function(config) { | ||
config.set({ | ||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: '', | ||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: ['mocha', 'browserify'], | ||
browserify: { | ||
transform: [ | ||
['babelify', {plugins: ['babel-plugin-espower']}] | ||
] | ||
}, | ||
client: { | ||
mocha: { | ||
// change Karma's debug.html to the mocha web reporter | ||
reporter: 'html' | ||
} | ||
}, | ||
// list of files / patterns to load in the browser | ||
files: [ | ||
'src/*.js', | ||
'test/unit/*_spec.js' | ||
], | ||
// list of files to exclude | ||
exclude: [ | ||
'src/doc/*.js' | ||
], | ||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
'src/*.js': 'browserify', | ||
'test/**/*_spec.js': 'browserify' | ||
}, | ||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['mocha'], | ||
// web server port | ||
port: 9876, | ||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: true, | ||
// start these browsers | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['Chrome'], | ||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: false, | ||
// Concurrency level | ||
// how many browser should be started simultaneous | ||
concurrency: Infinity | ||
}) | ||
} |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,17 @@ | ||
import Dropdown from '../src/dropdown'; | ||
import DropdownItem from '../src/dropdown_item'; | ||
import Query from '../src/query'; | ||
import SearchResult from '../src/search_result'; | ||
import Strategy from '../src/strategy'; | ||
import Textarea from '../src/textarea'; | ||
import extend from 'lodash.assignin'; | ||
const sinon = require('sinon'); | ||
|
||
/** | ||
* @returns {HTMLTextAreaElement} | ||
*/ | ||
export function getHTMLTextAreaElement() { | ||
return document.createElement('textarea'); | ||
} | ||
beforeEach(function () { | ||
this.sinon = sinon.sandbox.create(); | ||
}); | ||
|
||
/** | ||
* @param {object} [props] | ||
* @returns {Strategy} | ||
*/ | ||
export function createStrategy(props) { | ||
return new Strategy(extend({ | ||
match: /(^|\s)(\w*)$/, | ||
search: function (term, callback) { | ||
callback([term]); | ||
}, | ||
replace: function (value) { | ||
return `$1${value.toUpperCase()} `; | ||
}, | ||
}, props)); | ||
} | ||
afterEach(function () { | ||
this.sinon.restore(); | ||
|
||
/** | ||
* @param {object} [data] | ||
* @param {string} [term] | ||
* @param {object} [strategyProps] | ||
* @returns {Strategy} | ||
*/ | ||
export function createSearchResult(data='hello', term='he', strategyProps) { | ||
return new SearchResult(data, term, createStrategy(strategyProps)); | ||
} | ||
|
||
/** | ||
* @returns {Textarea} | ||
*/ | ||
export function createTextarea() { | ||
return new Textarea(getHTMLTextAreaElement()); | ||
} | ||
|
||
/** | ||
* @param {Strategy} [strategy] | ||
* @param {string} [term] | ||
* @param {string[]} [match] | ||
* @returns {Query} | ||
*/ | ||
export function createQuery(strategy=createStrategy(), term='he', match=['he', '', 'he']) { | ||
return new Query(strategy, term, match); | ||
} | ||
|
||
/** | ||
* @param {Dropdown} dropdown | ||
* @param {SearchResult} [searchResult] | ||
* @returns {DropdownItem} | ||
*/ | ||
export function createDropdownItem(dropdown=new Dropdown(), searchResult=createSearchResult()) { | ||
var dropdownItem = new DropdownItem(searchResult); | ||
dropdown.append([dropdownItem]); | ||
return dropdownItem; | ||
} | ||
const elements = document.getElementsByClassName('textcomplete-dropdown'); | ||
for (let i = 0, l = elements.length; i < l; i++) { | ||
const element = elements[i]; | ||
if (element) { | ||
element.parentNode.removeChild(element); | ||
} | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.