Skip to content

Commit

Permalink
chore(*): Prep for release 1.1.0 -- compatible with ui-router-core 3.x
Browse files Browse the repository at this point in the history
chore(*): lint
  • Loading branch information
christopherthielen committed Mar 5, 2017
1 parent b61a22b commit dfeb2de
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 31 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "ui-router-sticky-states",
"description": "UI-Router Sticky States: Keep states and their components alive while a different state is activated",
"version": "1.0.0",
"version": "1.1.0",
"scripts": {
"clean": "shx rm -rf lib lib-esm",
"build": "npm run clean && tsc && tsc -m es6 -outDir lib-esm",
"test": "karma start",
"watch": "run-p watch:*",
"watch:buildjs": "tsc -w",
"watch:test": "karma start --singleRun=false --autoWatch=true --autoWatchInterval=1",
"prepublish": "npm run build && npm run test",
"debug": "karma start --singleRun=false --autoWatch=true --autoWatchInterval=1 --browsers=ChromeCanary --beep"
},
"homepage": "https://ui-router.github.io",
Expand Down Expand Up @@ -39,7 +40,7 @@
"typings": "lib/index.d.ts",
"license": "MIT",
"peerDependencies": {
"ui-router-core": ">=3.0.0"
"ui-router-core": "^3.0.0"
},
"devDependencies": {
"@types/angular": "^1.5.20",
Expand Down Expand Up @@ -71,7 +72,7 @@
"ts-loader": "^2.0.0",
"tslint": "=2.5.0",
"typescript": "^2.1.1",
"ui-router-core": ">=2.0.0",
"ui-router-core": "3.0.0",
"webpack": "^1.13.3",
"webpack-beep-plugin": "0.0.1"
}
Expand Down
2 changes: 1 addition & 1 deletion src/stickyStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class StickyStatesPlugin extends UIRouterPluginBase {
this._addDefaultTransitionOption();
}

inactives(): StateDeclaration {
inactives(): StateDeclaration[] {
return this._inactives.map(node => node.state.self);
}

Expand Down
46 changes: 23 additions & 23 deletions test/stickySpec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { getTestGoFn, addCallbacks, resetTransitionLog, pathFrom, equalityTester, tlog } from "./util";
import {
UIRouter, StateService, StateRegistry, StateDeclaration, ViewService, TransitionService, PathNode, _ViewDeclaration,
isObject, ViewConfigFactory, ViewConfig, servicesPlugin, memoryLocationPlugin
isObject, ViewConfigFactory, ViewConfig
} from "ui-router-core";
import "../src/stickyStates";
import { StickyStatesPlugin } from "../src/stickyStates";
import { memoryLocationPlugin, servicesPlugin } from 'ui-router-core/lib/vanilla';

let router: UIRouter;
let $state: StateService;
Expand Down Expand Up @@ -38,12 +39,12 @@ describe('stickyState', function () {
if (isObject(state.views)) {
return Object.keys(state.views).map(key => (
{ $name: key, $uiViewName: key, $uiViewContextAnchor: state.name, $type: "core", $context: state }
), [])
), []);
}

return [
{ $name: "$default", $uiViewName: "$default", $uiViewContextAnchor: state.name, $type: "core", $context: state }
]
];
});

// ui-router-core doesn't have a default ViewConfigFactory
Expand All @@ -60,7 +61,7 @@ describe('stickyState', function () {
testGo = getTestGoFn(router);
});

var controllerInvokeCount = 0, resolveCount = 0, Xvalue = undefined;
let controllerInvokeCount = 0, resolveCount = 0, Xvalue = undefined;
function resetXResolve() {
controllerInvokeCount = resolveCount = 0; Xvalue = undefined;
}
Expand Down Expand Up @@ -124,11 +125,10 @@ describe('stickyState', function () {
});

it('$stickyState.$inactives should be an array', function() {
expect(Array.isArray($stickyState.inactives())).toBeTruthy()
expect(Array.isArray($stickyState.inactives())).toBeTruthy();
});

it('$stickyState.inactives() should hold inactive State Declarations', async function(done) {
let root = $registry.root();
await testGo("A._1", { entered: [ "A", "A._1" ]});
await testGo("A._2", { inactivated: "A._1", entered: "A._2" });

Expand Down Expand Up @@ -240,8 +240,8 @@ describe('stickyState', function () {
});

it('should allow empty transitionTo options', function() {
expect(() => $state.transitionTo('A')).not.toThrow()
})
expect(() => $state.transitionTo('A')).not.toThrow();
});
});

describe('resolve/controller function', function () {
Expand Down Expand Up @@ -331,14 +331,14 @@ describe('stickyState', function () {

// Test 2 for issue #239
it('should reactivate properly with equivalent json', async function (done) {
var objparam = { foo: "bar" };
let objparam = { foo: "bar" };
await testGo('typedparam2', undefined, { params: { jsonparam: objparam } });
await testGo('A');
expect(router.urlService.url()).toBe("/typedparam2/%7B%22foo%22%3A%22bar%22%7D");
resetTransitionLog();
await testGo('typedparam2', {inactivated: 'A', reactivated: 'typedparam2'}, { params: { jsonparam: { foo: "bar" } } });

done()
done();
});
});

Expand All @@ -359,7 +359,7 @@ describe('stickyState', function () {
it("should reload when params change", async function(done) {
await testGo('main', { entered: 'main' });

var options = { params: { 'product_id': 12345 } };
let options = { params: { 'product_id': 12345 } };
await testGo('main.product.something', { entered: pathFrom('main.product', 'main.product.something') }, options);
await testGo('main.other', { entered: 'main.other', inactivated: [ 'main.product', 'main.product.something' ] });
await testGo('main.product.something', { reactivated: ['main.product', 'main.product.something'], inactivated: 'main.other' }, options);
Expand Down Expand Up @@ -430,7 +430,7 @@ describe('stickyState', function () {
await testGo('A._1.__1.B', { exited: 'A._1.__1.B.___1' });

done();
})
});
});

describe("directly to a parent of an inactive sticky state", function() {
Expand All @@ -441,8 +441,8 @@ describe('stickyState', function () {
await testGo('A._1.__1.B', { exited: 'A._1.__1.B.___1', inactivated: 'A._2', reactivated: ['A._1', 'A._1.__1', 'A._1.__1.B'] });

done();
})
})
});
});
});

describe('nested .go() transitions with parent attributes', function () {
Expand Down Expand Up @@ -473,11 +473,11 @@ describe('stickyState', function () {
}

it('should have states attributes correctly set', function() {
var A = $state.get('A');
var A_1 = $state.get('A._1');
var A_1__1 = $state.get('A._1.__1');
var A_2 = $state.get('_2');
var A_2__2 = $state.get('__2');
let A = $state.get('A');
let A_1 = $state.get('A._1');
let A_1__1 = $state.get('A._1.__1');
let A_2 = $state.get('_2');
let A_2__2 = $state.get('__2');

// Check includes
expect(A.$$state().includes).toEqual({'' : true, 'A': true});
Expand Down Expand Up @@ -535,14 +535,14 @@ describe('stickyState', function () {
});

describe('ui-router option reload: [state ref]', function() {
var bStates: StateDeclaration[] = [
let bStates: StateDeclaration[] = [
{ name: 'B', sticky: true },
{ name: 'B._1', sticky: true },
{ name: 'B._1.__1', sticky: true }
];

beforeEach(function() {
var simpleStates = getSimpleStates();
let simpleStates = getSimpleStates();
ssReset(bStates.concat(simpleStates));
});

Expand Down Expand Up @@ -608,14 +608,14 @@ describe('stickyState', function () {
expect(() => $stickyState.exitSticky("A.DOESNTEXIST"))
.toThrow(Error("State not found: A.DOESNTEXIST"));
expect($stickyState.inactives().length).toBe(1);
expect($stickyState.inactives()[0].name).toBe('A._1')
expect($stickyState.inactives()[0].name).toBe('A._1');
});

it("should throw if an non-inactive state is passed", () => {
expect(() => $stickyState.exitSticky("A._2"))
.toThrow(Error("State not inactive: A._2"));
expect($stickyState.inactives().length).toBe(1);
expect($stickyState.inactives()[0].name).toBe('A._1')
expect($stickyState.inactives()[0].name).toBe('A._1');
});

it("should reset all inactive states if passed no arguments", async (done) => {
Expand Down
2 changes: 1 addition & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"no-require-imports": true,
"no-string-literal": false,
"no-switch-case-fall-through": true,
"no-trailing-comma": true,
"no-trailing-comma": false,
"no-trailing-whitespace": false,
"no-unreachable": true,
"no-unused-expression": true,
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2901,9 +2901,9 @@ uglify-to-browserify@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"

ui-router-core@>=2.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/ui-router-core/-/ui-router-core-3.1.1.tgz#9fccf9631bdf61d4641e333c74c3d1cc347dca18"
ui-router-core@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ui-router-core/-/ui-router-core-3.0.0.tgz#945e7e43bc3b98956104c204b2b38147ec4670c3"

uid-number@~0.0.6:
version "0.0.6"
Expand Down

0 comments on commit dfeb2de

Please sign in to comment.