Skip to content

Commit

Permalink
A huge improvement in package build-system
Browse files Browse the repository at this point in the history
* several files renames (to make the sources more understandable)
* add `builtin` package for babel (see babel/babel/issues/3083 )
* switch testing to the DIST version of package (not sources)
* probably fix the problems in browser testing (`instance of` now works), see #49
  • Loading branch information
maxkoryukov committed Mar 11, 2017
1 parent 89a14b8 commit 56493b6
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 26 deletions.
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
presets: ["es2015"]
"presets": ["es2015"],
"plugins": [
["babel-plugin-transform-builtin-extend", {
globals: ["Error"]
}]
]
}
1 change: 1 addition & 0 deletions examples/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports = module.exports = {
"globals": {
"expect": true,
"Route4Me": true,
"packageRoot": true,
},

"rules": {
Expand Down
3 changes: 2 additions & 1 deletion examples/init-examples-suite.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict"

global.Route4Me = require("..")
// eslint-disable-next-line import/no-dynamic-require
global.Route4Me = require(`${packageRoot}`)
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"ajv": "^4.11.2",
"babel-core": "^6.23.1",
"babel-loader": "^6.3.2",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-preset-es2015": "^6.22.0",
"bluebird": "^3.4.7",
"chai": "^3.5.0",
Expand Down
3 changes: 2 additions & 1 deletion test/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ exports = module.exports = {
"mocha": true,
},
"globals": {
"expect": true
"expect": true,
"packageRoot": true,
},

"rules": {
Expand Down
2 changes: 2 additions & 0 deletions test/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"use strict"

const path = require("path")
const chai = require("chai")
const chai_jsonschema = require("chai-json-schema")

chai.use(chai_jsonschema)
// Validate multiple errors for one assert
chai.tv4.multiple = true

global.packageRoot = path.resolve(path.join(__dirname, "..", "dist"))
global.expect = chai.expect
6 changes: 2 additions & 4 deletions test/package.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
const pkg = require("../")
const helper = require("./helper")

const pkgRoute4Me = require("../src/route4me")

const testApiKey = "11111111111111111111111111111111"

describe(helper.toSuiteName(__filename), () => {
Expand Down Expand Up @@ -36,7 +34,7 @@ describe(helper.toSuiteName(__filename), () => {
const route4me = new Route4Me(testApiKey)

expect(route4me).to.be.an("object")
expect(route4me).to.be.an.instanceof(pkgRoute4Me)
expect(route4me).to.be.an.instanceof(pkg.Route4Me)

// expect(route4me.url_base).to.equal("http://route4me.com")
})
Expand All @@ -45,7 +43,7 @@ describe(helper.toSuiteName(__filename), () => {
const route4me = pkg(testApiKey)

expect(route4me).to.be.an("object")
expect(route4me).to.be.an.instanceof(pkgRoute4Me)
expect(route4me).to.be.an.instanceof(pkg.Route4Me)

// expect(route4me.url_base).to.equal("http://route4me.com")
})
Expand Down
3 changes: 2 additions & 1 deletion test/resources/activity-feed.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const saMock = require("superagent-mocker")(request)

const helper = require("./../helper")

const Route4Me = require("../../src/route4me")
// eslint-disable-next-line import/no-dynamic-require
const Route4Me = require(`${packageRoot}/route4me`)

const testApiKey = "11111111111111111111111111111111"

Expand Down
3 changes: 2 additions & 1 deletion test/resources/address-book.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const saMock = require("superagent-mocker")(request)

const helper = require("./../helper")

const Route4Me = require("../../src/route4me")
// eslint-disable-next-line import/no-dynamic-require
const Route4Me = require(`${packageRoot}/route4me`)

const testApiKey = "11111111111111111111111111111111"

Expand Down
3 changes: 2 additions & 1 deletion test/resources/addresses.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const saMock = require("superagent-mocker")(request)

const helper = require("./../helper")

const Route4Me = require("../../src/route4me")
// eslint-disable-next-line import/no-dynamic-require
const Route4Me = require(`${packageRoot}/route4me`)

const testApiKey = "11111111111111111111111111111111"

Expand Down
3 changes: 2 additions & 1 deletion test/resources/avoidance-zones.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const saMock = require("superagent-mocker")(request)

const helper = require("./../helper")

const Route4Me = require("../../src/route4me")
// eslint-disable-next-line import/no-dynamic-require
const Route4Me = require(`${packageRoot}/route4me`)

const testApiKey = "11111111111111111111111111111111"

Expand Down
3 changes: 2 additions & 1 deletion test/resources/geocoding.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const saMock = require("superagent-mocker")(request)

const helper = require("../helper")

const Route4Me = require("../../src/route4me")
// eslint-disable-next-line import/no-dynamic-require
const Route4Me = require(`${packageRoot}/route4me`)

const testApiKey = "11111111111111111111111111111111"

Expand Down
3 changes: 2 additions & 1 deletion test/resources/members.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const saMock = require("superagent-mocker")(request)

const helper = require("./../helper")

const Route4Me = require("../../src/route4me")
// eslint-disable-next-line import/no-dynamic-require
const Route4Me = require(`${packageRoot}/route4me`)

const testApiKey = "11111111111111111111111111111111"

Expand Down
3 changes: 2 additions & 1 deletion test/resources/notes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const saMock = require("superagent-mocker")(request)

const helper = require("./../helper")

const Route4Me = require("../../src/route4me")
// eslint-disable-next-line import/no-dynamic-require
const Route4Me = require(`${packageRoot}/route4me`)

const testApiKey = "11111111111111111111111111111111"

Expand Down
3 changes: 2 additions & 1 deletion test/resources/optimizations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const saMock = require("superagent-mocker")(request)

const helper = require("./../helper")

const Route4Me = require("../../src/route4me")
// eslint-disable-next-line import/no-dynamic-require
const Route4Me = require(`${packageRoot}/route4me`)

const testApiKey = "11111111111111111111111111111111"

Expand Down
3 changes: 2 additions & 1 deletion test/resources/orders.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const saMock = require("superagent-mocker")(request)

const helper = require("./../helper")

const Route4Me = require("../../src/route4me")
// eslint-disable-next-line import/no-dynamic-require
const Route4Me = require(`${packageRoot}/route4me`)

const testApiKey = "11111111111111111111111111111111"

Expand Down
3 changes: 2 additions & 1 deletion test/resources/routes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const saMock = require("superagent-mocker")(request)

const helper = require("./../helper")

const Route4Me = require("../../src/route4me")
// eslint-disable-next-line import/no-dynamic-require
const Route4Me = require(`${packageRoot}/route4me`)

const testApiKey = "11111111111111111111111111111111"

Expand Down
14 changes: 7 additions & 7 deletions test/resources/territories.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ const saMock = require("superagent-mocker")(request)

const helper = require("./../helper")

const Route4Me = require("../../src/route4me")
const errors = require("../../src/errors")
// eslint-disable-next-line import/no-dynamic-require
const route4me = require(`${packageRoot}`)

const testApiKey = "11111111111111111111111111111111"


describe(helper.toSuiteName(__filename), () => {
describe("SDK methods", () => {
const route4me = new Route4Me(testApiKey)
const resource = route4me.Territories
const route4meClient = new route4me.Route4Me(testApiKey)
const resource = route4meClient.Territories
let req

beforeEach(() => {
Expand Down Expand Up @@ -155,10 +154,11 @@ describe(helper.toSuiteName(__filename), () => {
{ "territory_id": "AAAAAAAAAAAAAAA9D5CA2EA375E08B97" },
null
)

expect(err).is.instanceof(errors.Route4MeValidationError)
console.log(route4me.Route4MeValidationError)
console.log(err)
expect(err).has.property("message")
.that.match(/valid/i)
expect(err).is.instanceof(route4me.Route4MeValidationError)
done()
})
})
Expand Down
3 changes: 2 additions & 1 deletion test/resources/tracking.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const saMock = require("superagent-mocker")(request)

const helper = require("./../helper")

const Route4Me = require("../../src/route4me")
// eslint-disable-next-line import/no-dynamic-require
const Route4Me = require(`${packageRoot}/route4me`)

const testApiKey = "11111111111111111111111111111111"

Expand Down
3 changes: 2 additions & 1 deletion test/resources/vehicles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const saMock = require("superagent-mocker")(request)

const helper = require("../helper")

const Route4Me = require("../../src/route4me")
// eslint-disable-next-line import/no-dynamic-require
const Route4Me = require(`${packageRoot}/route4me`)

const testApiKey = "11111111111111111111111111111111"

Expand Down

0 comments on commit 56493b6

Please sign in to comment.