-
Notifications
You must be signed in to change notification settings - Fork 3
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
16 changed files
with
494 additions
and
80 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* init.js | ||
* Date: 26.05.15 | ||
* Vitaliy V. Makeev ([email protected]) | ||
*/ | ||
|
||
var chai = require('chai'); | ||
|
||
//global.chai = require('chai'); | ||
global._ = require('lodash'); | ||
global.expect = chai.expect; | ||
global.assert = chai.assert; | ||
|
||
global.moysklad = require('../src/moysklad-client/index.js'); | ||
|
||
chai.should(); |
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,3 @@ | ||
--reporter spec | ||
test/init.js | ||
test/specs/*.js |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,171 @@ | ||
/** | ||
* client | ||
* Date: 26.05.15 | ||
* Vitaliy V. Makeev ([email protected]) | ||
*/ | ||
|
||
var clientStamp = require('../../src/moysklad-client/client'); | ||
|
||
describe('client', function () { | ||
|
||
beforeEach(function () { | ||
this.client = clientStamp(); | ||
}); | ||
|
||
it('should have properties', function () { | ||
|
||
_.forEach([ | ||
// client | ||
'from', | ||
'load', | ||
'chain', | ||
'first', | ||
'total', | ||
'save', | ||
|
||
// json service | ||
'stock', | ||
'stockForGood', | ||
'slot', | ||
'mutualSettlement', | ||
'mutualSettlementForCustomer', | ||
|
||
// operators | ||
'anyOf', | ||
'$in', | ||
'between', | ||
'$bt', | ||
'greaterThen', | ||
'$gt', | ||
'greaterThanOrEqualTo', | ||
'$gte', | ||
'lessThan', | ||
'$lt', | ||
'lessThanOrEqualTo', | ||
'$lte', | ||
|
||
// other | ||
'createQuery', | ||
'createLazyLoader', | ||
'loadMetadata', | ||
'options', | ||
'sortMode' | ||
|
||
], function (prop) { | ||
assert.ok(this.client[prop], 'client must have property [' + prop + ']'); | ||
}, this); | ||
|
||
}); | ||
|
||
it('should have auth provider behavior', function () { | ||
|
||
expect(this.client).to.contain.all.keys( | ||
'setAuth', | ||
'getAuth', | ||
'getBasicAuthHeader', | ||
'isAuth' | ||
); | ||
|
||
}); | ||
|
||
it('should have provider accessor behavior', function () { | ||
|
||
expect(this.client).to.contain.all.keys( | ||
'getProvider', | ||
'setProvider' | ||
); | ||
|
||
}); | ||
|
||
it('should have classes constructor properties', function () { | ||
|
||
expect(this.client).to.contain.all.keys( | ||
'context', | ||
'AccountEntity', | ||
'CustomerOrder' | ||
); | ||
|
||
}); | ||
|
||
describe('entities', function () { | ||
|
||
describe('constructors properties', function () { | ||
|
||
it('should to be defined', function () { | ||
var client = this.client; | ||
|
||
var CustomerOrder = | ||
client.context.typeInfos['moysklad.customerOrder'].instanceFactory; | ||
|
||
expect(client.CustomerOrder) | ||
.to.be.ok | ||
.and.equal(CustomerOrder); | ||
|
||
assert.ok(client.AccountEntity, 'AccountEntity to be ok'); | ||
}); | ||
|
||
it('should create entities instances', function () { | ||
var client = this.client; | ||
|
||
var customerOrder = client.CustomerOrder({ | ||
name: 'foo-order' | ||
}); | ||
|
||
assert.ok(customerOrder, 'Instance of CustomerOrder to be ok'); | ||
|
||
expect(customerOrder.TYPE_NAME) | ||
.equal('moysklad.customerOrder'); | ||
|
||
expect(customerOrder.name) | ||
.equal('foo-order'); | ||
|
||
expect(customerOrder.getType) | ||
.to.be.a('function'); | ||
|
||
expect(customerOrder.getType()).to.equal(customerOrder.TYPE_NAME); | ||
}); | ||
|
||
}); | ||
|
||
describe('instances', function () { | ||
|
||
it('should have extended properties', function () { | ||
var client = this.client; | ||
|
||
var accountEntity = client.AccountEntity(); | ||
var customerOrder = client.CustomerOrder(); | ||
|
||
// AccountEntity properties | ||
expect(accountEntity).to.have.property('getType'); | ||
expect(customerOrder).to.have.property('getType'); | ||
|
||
// Aggregate only properties | ||
expect(accountEntity).to.have.not.property('save'); | ||
expect(customerOrder).to.have.property('save'); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
describe('methods', function () { | ||
|
||
beforeEach(function () { | ||
//this.client | ||
// .setProvider('ms-xml', msXmlClient) | ||
// .setProvider('json-services', jsonServices); | ||
}); | ||
|
||
describe('load', function () { | ||
|
||
it('should load entity by uuid', function () { | ||
//var order = this.client.load('customerOrder', 'uuid'); | ||
|
||
}) | ||
|
||
}) | ||
|
||
}) | ||
|
||
}); |
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,121 @@ | ||
/** | ||
* model | ||
* Date: 28.05.15 | ||
* Vitaliy V. Makeev ([email protected]) | ||
*/ | ||
|
||
describe('model', function () { | ||
|
||
beforeEach(function () { | ||
this.client = moysklad.createClient(); | ||
}); | ||
|
||
|
||
describe('customs', function () { | ||
|
||
beforeEach(function () { | ||
this.customerOrder = this.client.CustomerOrder(); | ||
}); | ||
|
||
it('should have methods', function () { | ||
expect(this.customerOrder).to.have.property('save'); | ||
expect(this.customerOrder).to.have.property('getAttr'); | ||
expect(this.customerOrder).to.have.property('hasAttr'); | ||
}); | ||
|
||
}); | ||
|
||
describe('accountEntity', function () { | ||
|
||
beforeEach(function () { | ||
this.accountEntity = this.client.AccountEntity(); | ||
}); | ||
|
||
it('should have methods', function () { | ||
|
||
var accountEntity = this.accountEntity; | ||
|
||
expect(accountEntity).to.have.property('getType'); | ||
expect(accountEntity).to.have.property('instanceOf'); | ||
expect(accountEntity).to.have.property('clone'); | ||
expect(accountEntity).to.have.property('getProperty'); | ||
|
||
}); | ||
|
||
describe('instanceOf', function () { | ||
|
||
it('should test instance of entity', function () { | ||
var customerOrder = this.client.CustomerOrder(); | ||
var test = customerOrder.instanceOf('order'); | ||
assert.ok( | ||
customerOrder.instanceOf('order'), | ||
'customerOrder must be instance of order'); | ||
|
||
assert.ok( | ||
customerOrder.instanceOf('moysklad.entity'), | ||
'customerOrder must be instance of entity'); | ||
}); | ||
|
||
}); | ||
|
||
describe('getProperty', function () { | ||
|
||
it('should return property value for path', function () { | ||
var customerOrder = this.client.CustomerOrder({ | ||
foo: { | ||
bar: 'order' | ||
} | ||
}); | ||
expect(customerOrder.getProperty('foo.bar')).to.be.equal('order'); | ||
}) | ||
|
||
}); | ||
|
||
}); | ||
|
||
describe('order', function () { | ||
|
||
it('should have "reserve" method', function () { | ||
var customerOrder = this.client.CustomerOrder(); | ||
expect(customerOrder).to.have.property('reserve'); | ||
}); | ||
|
||
//TODO test | ||
}); | ||
|
||
describe('operationWithPositions', function () { | ||
|
||
it('should have "getPositions" method', function () { | ||
var customerOrder = this.client.CustomerOrder(); | ||
expect(customerOrder).to.have.property('getPositions'); | ||
}); | ||
|
||
//TODO test | ||
}); | ||
|
||
describe('abstractGood', function () { | ||
|
||
it('should have "getPrice" method', function () { | ||
var good = this.client.Good(); | ||
expect(good).to.have.property('getPrice'); | ||
}); | ||
|
||
it('should have "hasPrice" method', function () { | ||
var good = this.client.Good(); | ||
expect(good).to.have.property('hasPrice'); | ||
}); | ||
|
||
//TODO test | ||
}); | ||
|
||
describe('attributeValue', function () { | ||
|
||
it('should have "getValue" method', function () { | ||
var attr = this.client.AttributeValue(); | ||
expect(attr).to.have.property('getValue'); | ||
}); | ||
|
||
//TODO test | ||
}) | ||
|
||
}); |
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,20 @@ | ||
/** | ||
* moysklad-client | ||
* Date: 16.07.14 | ||
* Vitaliy V. Makeev ([email protected]) | ||
*/ | ||
|
||
describe('moysklad', function () { | ||
|
||
it('should have properties', function () { | ||
expect(moysklad).to.have.all.keys( | ||
'createClient', | ||
'createQuery', | ||
'tools', | ||
'logger', | ||
'version' | ||
); | ||
}); | ||
|
||
}); | ||
|
Oops, something went wrong.