Skip to content

Commit 7569434

Browse files
committed
Stable Version 2.1.3
1 parent d35807f commit 7569434

19 files changed

+92
-508
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ bower_components/
88
coverage/
99

1010
npm-debug.log
11-
junit/
11+
junit/
12+
dist/karma.start.js

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
##### 2.1.3 - 10 November 2015
2+
3+
###### Other
4+
- Rebuilt with Babel v6
5+
- CI tests now run on Browserstack
6+
17
##### 2.1.2 - 30 October 2015
28

39
###### Other

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
localStorage adapter for [js-data](http://www.js-data.io/).
66

7+
Tested on IE9, Chrome 46, Firefox 41 & Safari 7.1 using
8+
<img src="https://raw.githubusercontent.com/js-data/js-data-localstorage/master/bs.jpg" alt="bs logo" title="browserstack" width="150" height="35" style="vertical-align: middle" />
9+
710
### API Documentation
811
[DSLocalStorageAdapter](http://www.js-data.io/docs/dslocalstorageadapter)
912

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
"karma.start.js"
3030
],
3131
"dependencies": {
32-
"js-data": ">=2.0.0"
32+
"js-data": "~2.x"
3333
}
3434
}

bs.jpg

-1003 Bytes
Loading

dist/js-data-localstorage.js

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* js-data-localstorage
3-
* @version 2.1.2 - Homepage <http://www.js-data.io/docs/dslocalstorageadapter>
3+
* @version 2.1.3 - Homepage <http://www.js-data.io/docs/dslocalstorageadapter>
44
* @author Jason Dobry <[email protected]>
55
* @copyright (c) 2014-2015 Jason Dobry
66
* @license MIT <https://github.com/js-data/js-data-localstorage/blob/master/LICENSE>
@@ -63,11 +63,13 @@ return /******/ (function(modules) { // webpackBootstrap
6363
/* 0 */
6464
/***/ function(module, exports, __webpack_require__) {
6565

66-
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
66+
'use strict';
67+
68+
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
6769

6870
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6971

70-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
72+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7173

7274
/* global: localStorage */
7375
var JSData = __webpack_require__(1);
@@ -210,7 +212,7 @@ return /******/ (function(modules) { // webpackBootstrap
210212

211213
var instance = undefined;
212214
options = options || {};
213-
options['with'] = options['with'] || [];
215+
options.with = options.with || [];
214216
return new DSUtils.Promise(function (resolve, reject) {
215217
_this.GET(_this.getIdPath(resourceConfig, options || {}, id)).then(function (item) {
216218
return !item ? reject(new Error('Not Found!')) : item;
@@ -222,22 +224,22 @@ return /******/ (function(modules) { // webpackBootstrap
222224
var relationName = def.relation;
223225
var relationDef = resourceConfig.getResource(relationName);
224226
var containedName = null;
225-
if (DSUtils.contains(options['with'], relationName)) {
227+
if (DSUtils.contains(options.with, relationName)) {
226228
containedName = relationName;
227-
} else if (DSUtils.contains(options['with'], def.localField)) {
229+
} else if (DSUtils.contains(options.with, def.localField)) {
228230
containedName = def.localField;
229231
}
230232
if (containedName) {
231233
(function () {
232234
var __options = DSUtils.deepMixIn({}, options.orig ? options.orig() : options);
233-
__options['with'] = options['with'].slice();
235+
__options.with = options.with.slice();
234236
__options = DSUtils._(relationDef, __options);
235-
DSUtils.remove(__options['with'], containedName);
236-
DSUtils.forEach(__options['with'], function (relation, i) {
237+
DSUtils.remove(__options.with, containedName);
238+
DSUtils.forEach(__options.with, function (relation, i) {
237239
if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') {
238-
__options['with'][i] = relation.substr(containedName.length + 1);
240+
__options.with[i] = relation.substr(containedName.length + 1);
239241
} else {
240-
__options['with'][i] = '';
242+
__options.with[i] = '';
241243
}
242244
});
243245

@@ -288,7 +290,7 @@ return /******/ (function(modules) { // webpackBootstrap
288290
return DSUtils.Promise.all(tasks);
289291
}).then(function () {
290292
return resolve(instance);
291-
})['catch'](reject);
293+
}).catch(reject);
292294
});
293295
}
294296
}, {
@@ -298,7 +300,7 @@ return /******/ (function(modules) { // webpackBootstrap
298300

299301
var items = null;
300302
options = options || {};
301-
options['with'] = options['with'] || [];
303+
options.with = options.with || [];
302304
return new DSUtils.Promise(function (resolve, reject) {
303305
try {
304306
(function () {
@@ -326,22 +328,22 @@ return /******/ (function(modules) { // webpackBootstrap
326328
var relationName = def.relation;
327329
var relationDef = resourceConfig.getResource(relationName);
328330
var containedName = null;
329-
if (DSUtils.contains(options['with'], relationName)) {
331+
if (DSUtils.contains(options.with, relationName)) {
330332
containedName = relationName;
331-
} else if (DSUtils.contains(options['with'], def.localField)) {
333+
} else if (DSUtils.contains(options.with, def.localField)) {
332334
containedName = def.localField;
333335
}
334336
if (containedName) {
335337
(function () {
336338
var __options = DSUtils.deepMixIn({}, options.orig ? options.orig() : options);
337-
__options['with'] = options['with'].slice();
339+
__options.with = options.with.slice();
338340
__options = DSUtils._(relationDef, __options);
339-
DSUtils.remove(__options['with'], containedName);
340-
DSUtils.forEach(__options['with'], function (relation, i) {
341+
DSUtils.remove(__options.with, containedName);
342+
DSUtils.forEach(__options.with, function (relation, i) {
341343
if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') {
342-
__options['with'][i] = relation.substr(containedName.length + 1);
344+
__options.with[i] = relation.substr(containedName.length + 1);
343345
} else {
344-
__options['with'][i] = '';
346+
__options.with[i] = '';
345347
}
346348
});
347349

@@ -445,7 +447,7 @@ return /******/ (function(modules) { // webpackBootstrap
445447
_this3.PUT(DSUtils.makePath(_this3.getIdPath(resourceConfig, options, attrs[resourceConfig.idAttribute])), DSUtils.omit(attrs, resourceConfig.relationFields || [])).then(function (item) {
446448
_this3.ensureId(item[resourceConfig.idAttribute], resourceConfig, options);
447449
resolve(item);
448-
})['catch'](reject);
450+
}).catch(reject);
449451
});
450452
});
451453
}
@@ -460,7 +462,7 @@ return /******/ (function(modules) { // webpackBootstrap
460462
_this4.PUT(_this4.getIdPath(resourceConfig, options, id), DSUtils.omit(attrs, resourceConfig.relationFields || [])).then(function (item) {
461463
_this4.ensureId(item[resourceConfig.idAttribute], resourceConfig, options);
462464
resolve(item);
463-
})['catch'](reject);
465+
}).catch(reject);
464466
});
465467
});
466468
}
@@ -512,10 +514,10 @@ return /******/ (function(modules) { // webpackBootstrap
512514
})();
513515

514516
DSLocalStorageAdapter.version = {
515-
full: '2.1.2',
517+
full: '2.1.3',
516518
major: parseInt('2', 10),
517519
minor: parseInt('1', 10),
518-
patch: parseInt('2', 10),
520+
patch: parseInt('3', 10),
519521
alpha: true ? 'false' : false,
520522
beta: true ? 'false' : false
521523
};

dist/js-data-localstorage.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js-data-localstorage.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

karma.conf.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@ var customLaunchers = {
55
browser_version: '9.0',
66
os: 'Windows',
77
os_version: '7'
8+
},
9+
bs_safari7_osxmavericks: {
10+
base: 'BrowserStack',
11+
browser: 'safari',
12+
browser_version: '7.1',
13+
os: 'OS X',
14+
os_version: 'Mavericks'
15+
},
16+
bs_firefox41_windows7: {
17+
base: 'BrowserStack',
18+
browser: 'firefox',
19+
browser_version: '41.0',
20+
os: 'Windows',
21+
os_version: '7'
22+
},
23+
bs_chrome46_windows7: {
24+
base: 'BrowserStack',
25+
browser: 'chrome',
26+
browser_version: '46.0',
27+
os: 'Windows',
28+
os_version: '7'
829
}
930
};
1031

@@ -20,15 +41,11 @@ module.exports = function (config) {
2041
config.set({
2142
// base path, that will be used to resolve files and exclude
2243
basePath: './',
23-
frameworks: ['sinon', 'chai', 'mocha'],
44+
frameworks: ['mocha'],
2445
plugins: [
2546
// these plugins will be require() by Karma
26-
'karma-sinon',
2747
'karma-mocha',
28-
'karma-chai',
29-
'karma-chrome-launcher',
3048
'karma-phantomjs-launcher',
31-
'karma-firefox-launcher',
3249
'karma-coverage',
3350
'karma-browserstack-launcher',
3451
'karma-junit-reporter'
@@ -42,8 +59,8 @@ module.exports = function (config) {
4259
'node_modules/es6-promise/dist/es6-promise.js',
4360
'node_modules/js-data/dist/js-data.js',
4461
'dist/js-data-localstorage.js',
45-
'karma.start.js',
46-
'test/**/*.js'
62+
'node_modules/js-data-adapter-tests/dist/js-data-adapter-tests.js',
63+
'karma.start.js'
4764
],
4865

4966
reporters: ['dots', 'coverage', 'junit'],
@@ -73,7 +90,7 @@ module.exports = function (config) {
7390

7491
customLaunchers: customLaunchers,
7592

76-
browserNoActivityTimeout: 30000,
93+
browserNoActivityTimeout: 90000,
7794

7895
// web server port
7996
port: 9876,
@@ -88,7 +105,7 @@ module.exports = function (config) {
88105
logLevel: config.LOG_INFO,
89106

90107
// If browser does not capture in given timeout [ms], kill it
91-
captureTimeout: 30000,
108+
captureTimeout: 90000,
92109

93110
// Continuous Integration mode
94111
// if true, it capture browsers, run tests and exit

karma.start.js

Lines changed: 7 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,11 @@
1-
// Setup global test variables
2-
var dsLocalStorageAdapter, Profile, User, Post, Comment, datastore;
3-
4-
assert.equalObjects = function (a, b, m) {
5-
assert.deepEqual(JSON.parse(JSON.stringify(a)), JSON.parse(JSON.stringify(b)), m || 'Objects should be equal!');
6-
};
7-
8-
// Helper globals
9-
var fail = function (msg) {
10-
if (msg instanceof Error) {
11-
console.log(msg.stack);
12-
} else {
13-
assert.equal('should not reach this!: ' + msg, 'failure');
14-
}
15-
};
16-
var TYPES_EXCEPT_STRING = [123, 123.123, null, undefined, {}, [], true, false, function () {
17-
}];
18-
var TYPES_EXCEPT_STRING_OR_ARRAY = [123, 123.123, null, undefined, {}, true, false, function () {
19-
}];
20-
var TYPES_EXCEPT_STRING_OR_OBJECT = [123, 123.123, null, undefined, [], true, false, function () {
21-
}];
22-
var TYPES_EXCEPT_STRING_OR_NUMBER_OBJECT = [null, undefined, [], true, false, function () {
23-
}];
24-
var TYPES_EXCEPT_ARRAY = ['string', 123, 123.123, null, undefined, {}, true, false, function () {
25-
}];
26-
var TYPES_EXCEPT_STRING_OR_NUMBER = [null, undefined, {}, [], true, false, function () {
27-
}];
28-
var TYPES_EXCEPT_STRING_OR_ARRAY_OR_NUMBER = [null, undefined, {}, true, false, function () {
29-
}];
30-
var TYPES_EXCEPT_NUMBER = ['string', null, undefined, {}, [], true, false, function () {
31-
}];
32-
var TYPES_EXCEPT_OBJECT = ['string', 123, 123.123, null, undefined, true, false, function () {
33-
}];
34-
var TYPES_EXCEPT_BOOLEAN = ['string', 123, 123.123, null, undefined, {}, [], function () {
35-
}];
36-
var TYPES_EXCEPT_FUNCTION = ['string', 123, 123.123, null, undefined, {}, [], true, false];
37-
38-
// Setup before each test
391
beforeEach(function () {
402
localStorage.clear();
41-
var JSData;
42-
if (!window && typeof module !== 'undefined' && module.exports) {
43-
JSData = require('js-data');
44-
} else {
45-
JSData = window.JSData;
46-
}
3+
});
474

48-
datastore = new JSData.DS();
5+
window.assert = TestRunner.assert;
496

50-
Profile = datastore.defineResource({
51-
name: 'profile'
52-
});
53-
User = datastore.defineResource({
54-
name: 'user',
55-
relations: {
56-
hasMany: {
57-
post: {
58-
localField: 'posts',
59-
foreignKey: 'post'
60-
}
61-
},
62-
hasOne: {
63-
profile: {
64-
localField: 'profile',
65-
localKey: 'profileId'
66-
}
67-
}
68-
}
69-
});
70-
Post = datastore.defineResource({
71-
name: 'post',
72-
relations: {
73-
belongsTo: {
74-
user: {
75-
localField: 'user',
76-
localKey: 'userId'
77-
}
78-
},
79-
hasMany: {
80-
comment: {
81-
localField: 'comments',
82-
foreignKey: 'postId'
83-
}
84-
}
85-
}
86-
});
87-
Comment = datastore.defineResource({
88-
name: 'comment',
89-
relations: {
90-
belongsTo: {
91-
post: {
92-
localField: 'post',
93-
localKey: 'postId'
94-
},
95-
user: {
96-
localField: 'user',
97-
localKey: 'userId'
98-
}
99-
}
100-
}
101-
});
102-
dsLocalStorageAdapter = new DSLocalStorageAdapter();
103-
});
7+
TestRunner.init({
8+
features: [],
9+
DS: JSData.DS,
10+
Adapter: DSLocalStorageAdapter
11+
});

0 commit comments

Comments
 (0)