Skip to content

Commit

Permalink
Merge pull request #4 from deshiknaves/bug/offset-tests
Browse files Browse the repository at this point in the history
Bug/offset tests
  • Loading branch information
deshiknaves authored Aug 28, 2018
2 parents b12373e + 1d3f9b7 commit eaf98c9
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 89 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
language: node_js
node_js:
- 8
before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
25 changes: 20 additions & 5 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/* global module, require */
/* global module, require, process */
// Karma configuration
// Generated on Sun Feb 04 2018 22:34:05 GMT+1100 (AEDT)
const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath();

module.exports = function(config) {
config.set({
const configuration = {

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
Expand All @@ -16,7 +18,8 @@ module.exports = function(config) {

// list of files / patterns to load in the browser
files: [
{ pattern: 'src/**/*.spec.js', watched: false }
{ pattern: 'src/**/*.spec.js', watched: false },
'src/reset.css'
],


Expand All @@ -40,6 +43,12 @@ module.exports = function(config) {
}
},

customLaunchers: {
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},

// test results reporter to use
// possible values: 'dots', 'progress'
Expand All @@ -66,7 +75,7 @@ module.exports = function(config) {

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
browsers: ['ChromeHeadless'],


// Continuous Integration mode
Expand All @@ -76,5 +85,11 @@ module.exports = function(config) {
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
};

if (process.env.TRAVIS) {
configuration.browsers = ['Chrome_travis_ci'];
}

config.set(configuration);
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"postbuild": "gulp compress",
"prepare": "npm run build",
"start": "rollup -c rollup.dev.config.js --watch",
"test": "karma start --single-run --browsers PhantomJS",
"test": "karma start --single-run",
"test:dev": "karma start"
},
"keywords": [
Expand Down Expand Up @@ -53,8 +53,8 @@
"karma-babel-preprocessor": "^7.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-jasmine": "^1.1.1",
"karma-phantomjs-launcher": "^1.0.4",
"karma-rollup-preprocessor": "^5.1.1",
"puppeteer": "^1.7.0",
"rimraf": "^2.6.2",
"rollup": "^0.54.0",
"rollup-plugin-babel": "^3.0.3",
Expand Down
20 changes: 10 additions & 10 deletions src/caret.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ describe('caret-pos', () => {

it('should correctly get the caret offset with a custom position', () => {
position(editor, 3);
const off = offset(editor, {customPos: 2});
expect(off.height).toBe(19);
expect(off.left).toBe(22);
expect(off.top).toBe(12);
const off = offset(editor, { customPos: 2 });
expect(off.height).toBe(16);
expect(off.left).toBe(27);
expect(off.top).toBe(9);
});
});

Expand Down Expand Up @@ -166,9 +166,9 @@ describe('caret-offset', () => {
it('should correctly get the caret offset', () => {
position(editor, 3);
const off = offset(editor);
expect(off.height).toBe(19);
expect(off.left).toBe(37);
expect(off.top).toBe(8);
expect(off.height).toBe(16);
expect(off.left).toBe(33);
expect(off.top).toBe(7);
});

it('should respect noShadowCaret', () => {
Expand All @@ -180,9 +180,9 @@ describe('caret-offset', () => {
it('should correctly get the caret offset with a custom position', () => {
position(editor, 3);
const off = offset(editor, { customPos: 2 });
expect(off.height).toBe(19);
expect(off.left).toBe(31);
expect(off.top).toBe(8);
expect(off.height).toBe(16);
expect(off.left).toBe(25);
expect(off.top).toBe(7);
});
});
});
6 changes: 6 additions & 0 deletions src/reset.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* {
font-size: 14px;
line-height: 14px;
font-family: Courier;
border: 0;
}
101 changes: 29 additions & 72 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@ extglob@^2.0.4:
snapdragon "^0.8.1"
to-regex "^3.0.1"

extract-zip@^1.6.5:
extract-zip@^1.6.6:
version "1.6.7"
resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9"
dependencies:
Expand Down Expand Up @@ -2047,14 +2047,6 @@ fs-access@^1.0.0:
dependencies:
null-check "^1.0.0"

fs-extra@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^2.1.0"
klaw "^1.0.0"

fs-minipass@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d"
Expand Down Expand Up @@ -2255,7 +2247,7 @@ glogg@^1.0.0:
dependencies:
sparkles "^1.0.0"

[email protected], graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9:
[email protected], graceful-fs@^4.1.2:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"

Expand Down Expand Up @@ -2426,13 +2418,6 @@ has-values@^1.0.0:
is-number "^3.0.0"
kind-of "^4.0.0"

hasha@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/hasha/-/hasha-2.2.0.tgz#78d7cbfc1e6d66303fe79837365984517b2f6ee1"
dependencies:
is-stream "^1.0.1"
pinkie-promise "^2.0.0"

hawk@~3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4"
Expand Down Expand Up @@ -2823,7 +2808,7 @@ is-resolvable@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88"

is-stream@^1.0.1, is-stream@^1.1.0:
is-stream@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"

Expand Down Expand Up @@ -2940,12 +2925,6 @@ json5@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"

jsonfile@^2.1.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
optionalDependencies:
graceful-fs "^4.1.6"

jsonpointer@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9"
Expand Down Expand Up @@ -2974,13 +2953,6 @@ karma-jasmine@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-1.1.2.tgz#394f2b25ffb4a644b9ada6f22d443e2fd08886c3"

karma-phantomjs-launcher@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz#d23ca34801bda9863ad318e3bb4bd4062b13acd2"
dependencies:
lodash "^4.0.1"
phantomjs-prebuilt "^2.1.7"

karma-rollup-preprocessor@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/karma-rollup-preprocessor/-/karma-rollup-preprocessor-5.1.1.tgz#0b15cd061eaf600b1f28332a2bcc9585623a1505"
Expand Down Expand Up @@ -3020,10 +2992,6 @@ karma@^2.0.0:
tmp "0.0.33"
useragent "2.2.1"

kew@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/kew/-/kew-0.7.0.tgz#79d93d2d33363d6fdd2970b335d9141ad591d79b"

kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0:
version "3.2.2"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
Expand All @@ -3044,12 +3012,6 @@ kind-of@^6.0.0, kind-of@^6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051"

klaw@^1.0.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439"
optionalDependencies:
graceful-fs "^4.1.9"

levn@^0.3.0, levn@~0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee"
Expand Down Expand Up @@ -3181,7 +3143,7 @@ lodash.templatesettings@^3.0.0:
lodash._reinterpolate "^3.0.0"
lodash.escape "^3.0.0"

lodash@^4.0.0, lodash@^4.0.1, lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.5.0:
lodash@^4.0.0, lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.5.0:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"

Expand Down Expand Up @@ -3367,6 +3329,10 @@ mime@^1.3.4, mime@^1.3.6:
version "1.6.0"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"

mime@^2.0.3:
version "2.3.1"
resolved "https://registry.yarnpkg.com/mime/-/mime-2.3.1.tgz#b1621c54d63b97c47d3cfe7f7215f7d64517c369"

mimic-fn@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
Expand Down Expand Up @@ -3847,20 +3813,6 @@ performance-now@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"

phantomjs-prebuilt@^2.1.7:
version "2.1.16"
resolved "https://registry.yarnpkg.com/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz#efd212a4a3966d3647684ea8ba788549be2aefef"
dependencies:
es6-promise "^4.0.3"
extract-zip "^1.6.5"
fs-extra "^1.0.0"
hasha "^2.2.0"
kew "^0.7.0"
progress "^1.1.8"
request "^2.81.0"
request-progress "^2.0.1"
which "^1.2.10"

pify@^2.0.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
Expand Down Expand Up @@ -3907,10 +3859,6 @@ process-nextick-args@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa"

progress@^1.1.8:
version "1.1.8"
resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be"

progress@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"
Expand Down Expand Up @@ -3950,6 +3898,19 @@ [email protected], punycode@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"

puppeteer@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.7.0.tgz#edcba2300a50847202c0f19fd15e7a96171ff3bd"
dependencies:
debug "^3.1.0"
extract-zip "^1.6.6"
https-proxy-agent "^2.2.1"
mime "^2.0.3"
progress "^2.0.0"
proxy-from-env "^1.0.0"
rimraf "^2.6.1"
ws "^5.1.1"

qjobs@^1.1.4:
version "1.2.0"
resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071"
Expand Down Expand Up @@ -4141,12 +4102,6 @@ [email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-0.0.1.tgz#29bbd92078a739f0bcce2b4ee41e837953522924"

request-progress@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/request-progress/-/request-progress-2.0.1.tgz#5d36bb57961c673aa5b788dbc8141fdf23b44e08"
dependencies:
throttleit "^1.0.0"

[email protected]:
version "2.75.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.75.0.tgz#d2b8268a286da13eaa5d01adf5d18cc90f657d93"
Expand All @@ -4173,7 +4128,7 @@ [email protected]:
tough-cookie "~2.3.0"
tunnel-agent "~0.4.1"

request@^2.0.0, request@^2.74.0, request@^2.81.0:
request@^2.0.0, request@^2.74.0:
version "2.88.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef"
dependencies:
Expand Down Expand Up @@ -4748,10 +4703,6 @@ text-table@~0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"

throttleit@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c"

[email protected], through2@^2.0.0, through2@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be"
Expand Down Expand Up @@ -5029,7 +4980,7 @@ when@^3.7.7:
version "3.7.8"
resolved "https://registry.yarnpkg.com/when/-/when-3.7.8.tgz#c7130b6a7ea04693e842cdc9e7a1f2aa39a39f82"

which@^1.2.1, which@^1.2.10, which@^1.2.14, which@^1.2.9:
which@^1.2.1, which@^1.2.14, which@^1.2.9:
version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
dependencies:
Expand Down Expand Up @@ -5070,6 +5021,12 @@ ws@^1.1.1:
options ">=0.0.5"
ultron "1.0.x"

ws@^5.1.1:
version "5.2.2"
resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.2.tgz#dffef14866b8e8dc9133582514d1befaf96e980f"
dependencies:
async-limiter "~1.0.0"

ws@~3.3.1:
version "3.3.3"
resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2"
Expand Down

0 comments on commit eaf98c9

Please sign in to comment.