Skip to content

Commit

Permalink
#572 added changelog.
Browse files Browse the repository at this point in the history
updated build tools.
updated qunit to latest 2.x version.
added code coverage reporting.
unit testing uses source files instead of distributable.
refactor unit tests to be more modular.
  • Loading branch information
bpatram committed Apr 2, 2017
1 parent d917a22 commit 15a8d57
Show file tree
Hide file tree
Showing 28 changed files with 1,829 additions and 1,548 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ insert_final_newline = true
indent_style = space
indent_size = 2

[*.json]
[*.{json,yml}]
indent_style = space
indent_size = 2

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules

.DS_Store
coverage
12 changes: 8 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
language: node_js
node_js:
- "4"
before_install:
- npm install -g npm
- npm install -g karma-cli
- "7"
addons:
apt:
packages:
- xvfb
install:
- export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
script:
- npm run test
sudo: false
Expand Down
121 changes: 121 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- New linter rules (ESLint, editorConfig)
- New test runner (Karma and TravisCI)
- New build tasks
- Code coverage reporting on unit tests
- Change log
### Removed
- `relatedModel` can no longer be defined as a function when defining `Relational.Model` relations
### Changed
- ES6 Refactor
- Updated QUnit from 1.x to 2.x

## [0.10.0] - 2015-08-19
### Changed
- Fix ordering problems in relations
- `Backbone` 1.2.1 compatible (add `_removeModels` override)

## [0.9.0] - 2014-11-03
### Added
- Add `getIdsToFetch` to `Backbone.RelationalModel`
### Removed
- Removed `fetchRelated` in favor of `getAsync`
### Changed
- `getAsync` (the successor of `fetchRelated`) now return a single promise, instead of an array of request objects.
- [#467](https://github.com/PaulUithol/Backbone-relational/issues/467): Improve lazy loading implementation.

## [0.8.8] - 2014-04-01
### Added
- `Backbone.Relational.store.unregister` now also accepts a collection or a model type
- [#215](https://github.com/PaulUithol/Backbone-relational/issues/215) Add direct support for AMD, CommonJS, require, etc.
### Changed
- [#419](https://github.com/PaulUithol/Backbone-relational/issues/419): Proper return values for single models on collection methods for `Backbone` 1.1.0
- [#427](https://github.com/PaulUithol/Backbone-relational/issues/427): Fix firing explicit `change` events
- [#411](https://github.com/PaulUithol/Backbone-relational/issues/411): Don't add models without an `id` to the store

## [0.8.7] - 2014-01-16
### Added
- Add `findModel`
- [#376](https://github.com/PaulUithol/Backbone-relational/pull/376): Include ids of unregistered models (not fetched or otherwise) in `toJSON`
### Changed
- Change return types for `Collection` methods to match `Backbone` 1.1.0

## [0.8.6] - 2013-08-16
### Added
- [#345](https://github.com/PaulUithol/Backbone-relational/pull/345): Add `find`, a shortcut to `findOrCreate` with `create: false`
- [#345](https://github.com/PaulUithol/Backbone-relational/pull/345): Add lodash compatibility (doesn't have an explicit `findWhere`)
- [#362](https://github.com/PaulUithol/Backbone-relational/pull/362): Add support for deep `subModelType` hierarchies.
- [#370](https://github.com/PaulUithol/Backbone-relational/pull/370): Relations can now be a property or a function.
- `relatedModel` and `collectionType` can now be defined as a function as well.
### Changed
- [#322](https://github.com/PaulUithol/Backbone-relational/pull/322): Remove keySource value after a `set`
- [#349](https://github.com/PaulUithol/Backbone-relational/pull/349): Event ordering: maintain the originally intended order when process gets called more than once.
- [#380](https://github.com/PaulUithol/Backbone-relational/pull/380): Fix pop on an empty collection.

## [0.8.5] - 2013-04-10
### Added
- [#201](https://github.com/PaulUithol/Backbone-relational/issues/201): Added `Backbone.Store.removeModelScope` method
- [#295](https://github.com/PaulUithol/Backbone-relational/issues/295): Check (and error on) duplicate ids when explicitly setting the `idAttribute`
### Changed
- Supports `Backbone` >= 1.0.0
- [#320](https://github.com/PaulUithol/Backbone-relational/issues/320): Use `merge: true` by default on `Collection.reset`
- [#191](https://github.com/PaulUithol/Backbone-relational/issues/191): if `includeInJSON` is equal to the model's `idAttribute`, "missing" models will be included in the JSON to avoid data loss
- [#273](https://github.com/PaulUithol/Backbone-relational/issues/273): Improve merging of relations between super/subModels

## [0.8.0] - 2013-03-06
### Added
- Implemented the `add`, `merge` and `remove` options on `Collection.add` when working with RelationalModels. This also works when using set to change the key on nested relations.
- Added a `parse` option to `relations`
### Removed
- The `update:<key>` event has been removed, in favor of handling everything using "standard" `change:<key>` events.
### Changed
- The update option on `findOrCreate` has been renamed to `merge`, since its behavior corresponds with merge on `Collection.add` (and not with update on `Collection.reset`).
- General performance improvements, refactored `HasMany.onChange` to eliminate unnecessary events.
- `findOrCreate` now takes a `parse` option, analogous to the `Backbone.Model` constructor. It defaults to `false`

## [0.7.1] - 2013-01-17
### Added
- Added the `update` option to `findOrCreate`
- Implemented the `autoFetch` property for `relations`
### Changed
- Compatible with `Backbone` >= 0.9.10

## [0.7.0] - 2012-12-18
### Changed
- Compatible with `Backbone` >= 0.9.9
- [#180](https://github.com/PaulUithol/Backbone-relational/issues/180): no longer allow multiple instances of `RelationalModel` with the same type, and the same `id`

## [0.6.1] - 2012-12-04
### Changed
- [#215](https://github.com/PaulUithol/Backbone-relational/pull/215) Fix export issue with require.js

## [0.6.0] - 2012-08-02
### Added
- `keyDestination` option added to relations
- `collectionOptions` option added to relations
- Added support for super/sub models
- Added `Backbone.Store.addModelScope`
- [#60](https://github.com/PaulUithol/Backbone-relational/issues/60): `keySource` option added to relations

## [0.5.0] - 2012-02-17
### Added
- Support new Backbone syntax for `set` (with separate key, value - arguments)
### Changed
- Update nested models properly on `Collection.add`
- `collectionKey` options added to relations
- Initialize `reverseRelation`s on definition, instead of on creation of the first model

## [0.4.0] - 2011-07-11
### Added
- Added the Backbone.RelationalModel.updateRelations method
### Changed
- update<key> event added
- Override `Backbone.Collection._add` and `Backbone.Collection._remove` so relations update properly
- Queue change and `change:<key>` events, so they won't fire before relations are updated
12 changes: 6 additions & 6 deletions dist/backbone-relational.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/backbone-relational.js.map

Large diffs are not rendered by default.

44 changes: 30 additions & 14 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,53 @@ module.exports = function( config ) {
'browserify',
'qunit'
],
plugins: [
'karma-browserify',
'karma-phantomjs-launcher',
'karma-qunit'
],

files: [
'test/setup/environment.js',
files: [
require.resolve( 'babel-polyfill' ),
// 'test/setup/environment.js',
'test/*.js'
],

preprocessors: {
'test/**/*.js': [ 'browserify' ]
[ require.resolve( 'babel-polyfill' ) ]: [ 'browserify' ],
'test/*.js': [ 'browserify', 'coverage' ],
'**/*.js': [ 'electron' ]
},

browserify: {
client: {
useIframe: false
},

browserify: {
debug: true,
transform: [
[ 'babelify', {
presets: [ 'es2015' ],
plugins: [
[ 'module-resolver', {
alias: {
'backbone-relational': './src/backbone-relational'
}
}],
[ 'istanbul', {
exclude: [ 'node_modules/**', 'test/**' ]
}]
],
sourceMap: true
}]
]
},

browsers: [
'PhantomJS'
],
reporters: [ 'dots', 'coverage' ],

coverageReporter: {
dir: './coverage',
reporters: [
{ type: 'text-summary' },
{ type: 'lcovonly', subdir: '.' }
]
},

singleRun: false,
autoWatch: false,
port: 9877,
colors: true
});
Expand Down
31 changes: 18 additions & 13 deletions package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"url": "https://github.com/PaulUithol/Backbone-relational.git"
},
"scripts": {
"test": "karma start --single-run",
"test": "karma start --single-run --browsers Electron",
"test-debug": "karma start --single-run",
"build": "rollup -c",
"prepublish": "rollup -c",
"watch": "karma start --auto-watch & rollup -c --watch && fg"
},
"author": "Paul Uithol <https://github.com/PaulUithol>",
Expand All @@ -29,22 +31,25 @@
"license": "MIT",
"version": "0.10.0",
"devDependencies": {
"babel-plugin-external-helpers": "^6.8.0",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.16.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-istanbul": "^4.1.1",
"babel-plugin-module-resolver": "^2.7.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.0",
"babelify": "^7.3.0",
"backbone": "1.2.3",
"browserify": "^13.0.0",
"browserify": "^14.1.0",
"electron": "^1.6.2",
"jquery": "^2.2.1",
"karma": "^1.3.0",
"karma-browserify": "^5.0.2",
"karma-phantomjs-launcher": "^1.0.2",
"karma": "^1.5.0",
"karma-browserify": "^5.1.1",
"karma-coverage": "^1.1.1",
"karma-electron": "^5.1.1",
"karma-qunit": "^1.2.1",
"phantomjs-prebuilt": "^2.1.5",
"qunitjs": "^1.14.0",
"rollup": "^0.36.3",
"rollup-plugin-babel": "^2.6.1",
"rollup-watch": "^2.5.0"
"qunitjs": "^2.3.0",
"rollup": "^0.41.6",
"rollup-plugin-babel": "^2.7.1",
"rollup-watch": "^3.2.2"
},
"dependencies": {}
}
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
/* eslint-env node */
import babel from 'rollup-plugin-babel';

const babel = require( 'rollup-plugin-babel' );
const pkg = require( './package.json' );
const external = Object.keys( pkg.dependencies );
const now = new Date();
Expand All @@ -16,7 +16,7 @@ const banner = `/**!
* ${pkg.homepage}
*/\n`;

module.exports = {
export default {
entry: 'src/backbone-relational.js',
plugins: [
babel({
Expand Down
33 changes: 14 additions & 19 deletions src/backbone-relational.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import Backbone from 'backbone';
import { Collection as BBCollection, Model as BBModel } from 'backbone';
import _ from 'underscore';
import Semaphore from './utils/semaphore';
import BlockingQueue from './utils/blocking-queue';
import eventQueue from './event-queue';
Expand All @@ -15,24 +12,22 @@ import Store from './utils/store';
import store from './store';
import Model from './model';

const module = config;
export { Collection };
export { Semaphore };
export { BlockingQueue };
export { eventQueue };

module.Collection = Collection;
module.Semaphore = Semaphore;
module.BlockingQueue = BlockingQueue;
module.eventQueue = eventQueue;
module.relationTypeStore = relationTypeStore;
export { Store };
export { store };

module.Store = Store;
module.store = store;
export { relationTypeStore };
export { Relation };
export { HasOne };
export { HasMany };

module.Relation = Relation;
module.HasOne = HasOne;
module.HasMany = HasMany;
relationTypeStore.registerType( 'HasOne', HasOne );
relationTypeStore.registerType( 'HasMany', HasMany );

relationTypeStore.registerType( 'HasOne', module.HasOne );
relationTypeStore.registerType( 'HasMany', module.HasMany );
export { Model };

module.Model = Model;

export default module;
export { config };
4 changes: 2 additions & 2 deletions src/utils/events.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Backbone from 'backbone';
import { Events } from 'backbone';

export default Backbone.Events;
export default Events;
2 changes: 1 addition & 1 deletion src/utils/extend.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {Model} from 'backbone';
import { Model } from 'backbone';

export default Model.extend;
Loading

0 comments on commit 15a8d57

Please sign in to comment.