Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"strict": "off",
"quotes": [
"error",
"single"
"single",
{
"allowTemplateLiterals": true
}
],
"no-unused-vars": [
"error",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
const PushStateTree = require('../src/push-state-tree');
import cleanHistoryAPI from './helper/cleanHistoryAPI';
const _ = require('underscore');
import PushStateTree from '../../src/push-state-tree';
import _ from 'underscore';

describe('PushStateTree beutifyLocation', function() {

cleanHistoryAPI();

let pstBeautify;
let pst;

Expand All @@ -18,6 +14,8 @@ describe('PushStateTree beutifyLocation', function() {
basePath: _.uniqueId('/beautify+path') + '/',
beautifyLocation: true
});
pst.hasPushState = true;
pstBeautify.hasPushState = true;
});

it('should be enabled by default', () => {
Expand Down
22 changes: 3 additions & 19 deletions test/route.js → ...led-tests/history/router-history-props.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
const PushStateTree = require('../src/push-state-tree');
import cleanHistoryAPI from './helper/cleanHistoryAPI';
import PushStateTree from '../../../src/push-state-tree';

describe('PushStateTree should', function() {
cleanHistoryAPI();

it('be available as UMD library', function() {
expect(PushStateTree).to.be.defined;
});

it('instances without "new" operator', function() {
/* jshint newcap: false*/
expect(PushStateTree()).to.be.instanceof(HTMLElement);
});

it('construct and became a HTMLElement instance', function(){
expect(new PushStateTree()).to.be.instanceof(HTMLElement);
expect(new PushStateTree({})).to.be.instanceof(HTMLElement);
});
//TODO: Add the browser adapter and history plugin

describe('PushStateTree should', function() {
it('auto enable push state if browser support it', function(){
var pst = new PushStateTree();
expect(pst.usePushState).to.be.true;
Expand Down Expand Up @@ -63,5 +48,4 @@ describe('PushStateTree should', function() {
var pst = new PushStateTree();
expect(pst.uri).to.equal(location.pathname.slice(1));
});

});
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const PushStateTree = require('../src/push-state-tree');
import cleanHistoryAPI from './helper/cleanHistoryAPI';
import PushStateTree from '../src/push-state-tree';
// import cleanHistoryAPI from './helper/cleanHistoryAPI';

describe('PushStateTree createRule', function() {
cleanHistoryAPI();
// cleanHistoryAPI();

describe('when rule /^servers(\/)?(.*)/', function() {
var pst;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const PushStateTree = require('../src/push-state-tree');
import cleanHistoryAPI from './helper/cleanHistoryAPI';
import PushStateTree from '../src/push-state-tree';
// import cleanHistoryAPI from './helper/cleanHistoryAPI';

describe('PushStateTree hash-navigation should', function() {
describe('PushStateTree hash-navigation', function() {

cleanHistoryAPI();
// cleanHistoryAPI();

let cacheVal;

Expand All @@ -17,7 +17,7 @@ describe('PushStateTree hash-navigation should', function() {
PushStateTree.hasPushState = cacheVal;
});

it('force hash navigation if browser doesn\'t support pushState', () => {
it(`should force hash navigation if browser doesn't support pushState`, () => {
var pst = new PushStateTree({
usePushState: true
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const PushStateTree = require('../src/push-state-tree');
import cleanHistoryAPI from './helper/cleanHistoryAPI';
const _ = require('underscore');
import PushStateTree from '../src/push-state-tree';
// import cleanHistoryAPI from './helper/cleanHistoryAPI';
import _ from 'underscore';

describe('PushStateTree hash-navigation', () => {
let pst;
Expand All @@ -10,7 +10,7 @@ describe('PushStateTree hash-navigation', () => {
'assign'
];

cleanHistoryAPI();
// cleanHistoryAPI();

beforeEach(() => {
pst = new PushStateTree({
Expand Down Expand Up @@ -113,8 +113,8 @@ describe('PushStateTree hash-navigation', () => {
pst[triggerMethod]('/');
expect(pst.uri).to.equal('');
expect(location.hash).to.equal('');
});
});

});
});
});
6 changes: 3 additions & 3 deletions test/route-methods.js → disabled-tests/route-methods.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const PushStateTree = require('../src/push-state-tree');
import cleanHistoryAPI from './helper/cleanHistoryAPI';
import PushStateTree from '../src/push-state-tree';
// import cleanHistoryAPI from './helper/cleanHistoryAPI';

describe('PushStateTree methods', function() {
let pst;

cleanHistoryAPI();
// cleanHistoryAPI();

beforeEach(() => {
pst = new PushStateTree();
Expand Down
8 changes: 4 additions & 4 deletions test/rule-events.js → disabled-tests/rule-events.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const PushStateTree = require('../src/push-state-tree');
import cleanHistoryAPI from './helper/cleanHistoryAPI';
const _ = require('underscore');
import PushStateTree from '../src/push-state-tree';
// import cleanHistoryAPI from './helper/cleanHistoryAPI';
import _ from 'underscore';

describe('PushStateTree-rule', function () {
let pst;
Expand All @@ -11,7 +11,7 @@ describe('PushStateTree-rule', function () {
'assign'
];

cleanHistoryAPI();
// cleanHistoryAPI();

beforeEach(function () {
pst = new PushStateTree();
Expand Down
6 changes: 3 additions & 3 deletions test/rule-properties.js → disabled-tests/rule-properties.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const PushStateTree = require('../src/push-state-tree');
import cleanHistoryAPI from './helper/cleanHistoryAPI';
import PushStateTree from '../src/push-state-tree';
// import cleanHistoryAPI from './helper/cleanHistoryAPI';

describe('PushStateTree properties', () => {

cleanHistoryAPI();
// cleanHistoryAPI();

var expectedParentGroup = 2;
var pst;
Expand Down
6 changes: 3 additions & 3 deletions test/rule.js → disabled-tests/rule.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const PushStateTree = require('../src/push-state-tree');
import cleanHistoryAPI from './helper/cleanHistoryAPI';
import PushStateTree from '../src/push-state-tree';
// import cleanHistoryAPI from './helper/cleanHistoryAPI';

describe('PushStateTree-rule', function () {
let pst;
let rule;

cleanHistoryAPI();
// cleanHistoryAPI();

beforeEach(function () {
pst = new PushStateTree();
Expand Down
28 changes: 15 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
if (location.hostname.indexOf('github') === -1){
basePath = '';
}

// If no internet found (programming on travels...)
// Load resources from offline folder
if (typeof $ !== 'function' || !$.when){

function loadOffline(src, callback) {
// Load a file and execute the callback, should be used to
// load files in the right order and then boot the system

var type = src.substr(-3) === 'css' ? 'link' : 'script';
var element = document.createElement(type);
var path = location.origin + basePath + '/demo/offline/';
Expand All @@ -74,24 +74,26 @@
} else {
boot();
}
function boot(){

function boot() {
// boot the demo page

function load(src){
// Simple script loader based on promises
var defer = $.Deferred();;

var defer = $.Deferred();
if (!$.support.leadingWhitespace) {
$.getScript(location.protocol + '//' + location.host + src)
.then(defer.resolve, defer.reject);
.then(defer.resolve, defer.reject)
;
} else {
$('<script>')
.appendTo('head')
// Get the origin compatible with IE8
.attr('src', location.protocol + '//' + location.host + src)
.on('load', defer.resolve)
.on('error', defer.reject);
.on('error', defer.reject)
;
}

return defer.promise();
Expand All @@ -100,11 +102,11 @@
window.load = load;

$.when(load(basePath + '/build/push-state-tree.js'))
.then(function(){
.then(function () {
return load(basePath + '/demo/main.js');
})
.done(function (){
$('#loading').on('hidden.bs.modal', function(){
.done(function () {
$('#loading').on('hidden.bs.modal', function() {
$('#main').toggleClass('in', true);
$('#version').text(pushStateTree.VERSION);
}).modal('hide');
Expand Down Expand Up @@ -132,7 +134,7 @@
<!--[if lt IE 9]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->

<div id="main" class="container fade">

<!-- Static navbar -->
Expand Down
47 changes: 21 additions & 26 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ const WATCH = argv.watch;
// so it's disabled by default, more info at https://webpack.github.io/docs/configuration.html#devtool
const devtool = argv['fast-build'] ? 'cheap-module-eval-source-map' : 'inline-source-map';


// For development server testing, it should not be a library, a devserver.js is including and assign the global
// PushStateTree for the logic in the Demo work
delete webpackConfig.output.library;
delete webpackConfig.output.libraryTarget;
delete webpackConfig.output.umdNamedDefine;

if (WATCH) {
let port = argv['dev-port'] || 8080;

Expand All @@ -47,21 +54,16 @@ if (WATCH) {

webpackDevConfig.output.pathinfo = true;
webpackDevConfig.resolve.alias = {
'push-state-tree': path.resolve(__dirname, webpackDevConfig.entry['push-state-tree'])
'push-state-tree': path.resolve(__dirname, webpackDevConfig.entry['push-state-tree'][0])
};

webpackDevConfig.entry['push-state-tree'] = [
// Add inline webpack-dev-server client
`webpack-dev-server/client?http://localhost:${port}/`,
// Keep default lib
'expose?PushStateTree!' + webpackDevConfig.entry['push-state-tree']
'expose?PushStateTree!' + webpackDevConfig.entry['push-state-tree'][0]
];

// For development server testing, it should not be a library, a devserver.js is including and assign the global
// PushStateTree for the logic in the Demo work
delete webpackDevConfig.output.library;
delete webpackDevConfig.output.libraryTarget;
delete webpackDevConfig.output.umdNamedDefine;
webpackDevConfig.module.preLoaders = [];

var compiler = webpack(webpackDevConfig);
Expand Down Expand Up @@ -98,11 +100,13 @@ module.exports = function (config) {

// list of files / patterns to load in the browser
files: [
'test/*.js'
'test/**/*.js'
],

// list of files to exclude
exclude: [],
exclude: [
'test/helper/**/*.js'
],

// test results reporter to use
reporters: ['progress', 'coverage'],
Expand Down Expand Up @@ -150,25 +154,16 @@ module.exports = function (config) {
exclude: /(node_modules)/,
loader: 'json'
}
]
],
// postLoaders: [
// {
// test: /\.js$/,
// exclude: /(test|node_modules|bower_components|\.shim\.js$|\.json$)/,
// loader: 'istanbul-instrumenter'
// }
// ]
};

if (WATCH) {
module.postLoaders = [
{
test: /\.js$/,
exclude: /(test|node_modules|bower_components|\.shim\.js$|\.json$)/,
loader: 'istanbul-instrumenter'
}
]
} else {
module.preLoaders.unshift({
test: /\.js$/,
exclude: /(test|node_modules|bower_components|\.shim\.js$|\.json$)/,
loader: 'istanbul-instrumenter'
});
}

return module;
}())),
plugins: webpackConfig.plugins,
Expand Down
Loading