Skip to content

Commit

Permalink
test and coverage support
Browse files Browse the repository at this point in the history
  • Loading branch information
kerrishotts committed May 11, 2017
1 parent 93b85a6 commit 40426d8
Show file tree
Hide file tree
Showing 23 changed files with 396 additions and 222 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ platforms/
plugins/
typings/
www/*
!www/.gitkeep
!www/.gitkeep
.tmp
coverage
.nyc_output
12 changes: 12 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extension": [
".js", ".jsx", ".ts", ".tsx"
],
"reporter": [
"html",
"text-summary"
],
"cache": true,
"sourceMap": false,
"instrument": false
}
34 changes: 17 additions & 17 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,6 @@
<platform name="ios">
<preference name="Orientation" value="all" />
</platform>
<plugin name="cordova-plugin-device" spec="1.1.0" />
<plugin name="cordova-plugin-network-information" spec="1.1.0" />
<plugin name="cordova-plugin-globalization" spec="1.0.2" />
<plugin name="cordova-plugin-whitelist" spec="1.2.0" />
<plugin name="phonegap-plugin-mobile-accessibility" spec="1.0.5" />
<plugin name="ionic-plugin-keyboard" spec="1.0.8" />
<plugin name="cordova-sqlite-ext" spec="0.8.0" />
<plugin name="cordova-plugin-splashscreen" spec="2.1.0" />
<plugin name="cordova-plugin-statusbar" spec="1.0.1" />
<plugin name="cordova-plugin-inappbrowser" spec="1.1.1" />
<plugin name="cordova-plugin-safariviewcontroller" spec="1.2.0" />
<icon height="60" platform="ios" src="res/icon/ios/icon-60.png" width="60" />
<icon height="120" platform="ios" src="res/icon/ios/[email protected]" width="120" />
<icon height="180" platform="ios" src="res/icon/ios/[email protected]" width="180" />
Expand Down Expand Up @@ -105,13 +94,24 @@
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="ios" spec="~4.3.1" />
<engine name="android" spec="~6.1.2" />
<plugin name="cordova-plugin-wkwebview-engine" spec="~1.1.2" />
<preference name="AlternateContentSrc" value="undefined" />
<plugin name="cordova-labs-local-webserver" spec="git://github.com/apache/cordova-plugins#local-webserver" />
<plugin name="cordova-plugin-webpack-transpiler" spec="~0.2.3">
<engine name="android" spec="~6.1.2" />
<engine name="browser" spec="~4.1.0" />
<engine name="ios" spec="~4.3.1" />
<plugin name="cordova-labs-local-webserver" spec="git://github.com/apache/cordova-plugins.git#local-webserver" />
<plugin name="cordova-plugin-device" spec="1.1.0" />
<plugin name="cordova-plugin-globalization" spec="1.0.2" />
<plugin name="cordova-plugin-inappbrowser" spec="1.1.1" />
<plugin name="cordova-plugin-network-information" spec="1.1.0" />
<plugin name="cordova-plugin-safariviewcontroller" spec="1.2.0" />
<plugin name="cordova-plugin-splashscreen" spec="2.1.0" />
<plugin name="cordova-plugin-statusbar" spec="1.0.1" />
<plugin name="cordova-plugin-webpack-transpiler" spec="~0.3.1">
<variable name="CONFIG" value="typescript" />
</plugin>
<engine name="browser" spec="~4.1.0" />
<plugin name="cordova-plugin-whitelist" spec="1.2.0" />
<plugin name="cordova-plugin-wkwebview-engine" spec="~1.1.2" />
<plugin name="cordova-sqlite-ext" spec="0.8.0" />
<plugin name="ionic-plugin-keyboard" spec="1.0.8" />
<plugin name="phonegap-plugin-mobile-accessibility" spec="1.0.5" />
</widget>
4 changes: 4 additions & 0 deletions mocha-webpack.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--webpack-config ./webpack.config-test.js
--require source-map-support/register
--full-trace
test/*.js
64 changes: 61 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,68 @@
"colors": "^1.1.2",
"copy-webpack-plugin": "^4.0.1",
"core-js": "^2.4.1",
"css-loader": "^0.27.1",
"cross-env": "^4.0.0",
"css-loader": "^0.27.3",
"dom-storage": "^2.0.1",
"eslint": "^3.17.1",
"eslint-plugin-async-await": "0.0.0",
"extract-text-webpack-plugin": "^2.0.0-rc.3",
"extract-text-webpack-plugin": "^2.1.0",
"fake-indexeddb": "^1.0.3",
"file-loader": "^0.10.1",
"html-webpack-plugin": "^2.28.0",
"imports-loader": "^0.7.1",
"istanbul-instrumenter-loader": "^2.0.0",
"json5": "^0.4.0",
"json5-loader": "^1.0.1",
"mocha": "^3.3.0",
"mocha-loader": "^1.1.1",
"mocha-webpack": "^0.7.0",
"node-sass": "^4.5.0",
"nyc": "^10.3.2",
"opendatabase": "^0.2.1",
"raw-loader": "^0.5.1",
"resolve-url-loader": "^2.0.2",
"sass-loader": "^6.0.3",
"source-map-support": "^0.4.15",
"style-loader": "^0.13.2",
"ts-loader": "^2.0.1",
"typescript": "^2.2.1",
"typescript": "^2.3.2",
"wd": "^0.3.12",
"webpack": "^2.2.1",
"webpack-node-externals": "^1.6.0",
"worker-loader": "^0.8.0"
},
"dependencies": {
"babel-polyfill": "^6.23.0",
"cldr-data": "^27.0.10",
"cocoon-cordova-labs-local-webserver": "^2.4.1",
"cordova-android": "~6.1.2",
"cordova-browser": "~4.1.0",
"cordova-ios": "~4.3.1",
"cordova-labs-local-webserver": "git://github.com/apache/cordova-plugins.git#local-webserver",
"cordova-plugin-device": "1.1.0",
"cordova-plugin-globalization": "1.0.2",
"cordova-plugin-inappbrowser": "1.1.1",
"cordova-plugin-network-information": "1.1.0",
"cordova-plugin-safariviewcontroller": "1.2.0",
"cordova-plugin-splashscreen": "2.1.0",
"cordova-plugin-statusbar": "1.0.1",
"cordova-plugin-webpack-transpiler": "~0.3.1",
"cordova-plugin-whitelist": "1.2.0",
"cordova-plugin-wkwebview-engine": "~1.1.2",
"cordova-sqlite-ext": "0.8.0",
"debounce": "^1.0.0",
"globalize": "^1.2.2",
"hammerjs": "^2.0.4",
"ionic-plugin-keyboard": "1.0.8",
"keypather": "^1.10.1",
"matches-selector": "^1.0.0",
"merge": "^1.2.0",
"morphdom": "^1.3.0",
"node-reset-scss": "^1.0.1",
"once": "^1.3.2",
"open-iconic": "git://github.com/iconic/open-iconic.git",
"phonegap-plugin-mobile-accessibility": "1.0.5",
"prefix-property": "^1.0.23",
"svg-injector": "^1.1.3",
"treo": "^0.5.1",
Expand All @@ -81,5 +108,36 @@
"$MODELS": "src/www/js/app/models",
"$VIEWS": "src/www/js/app/views",
"$CONTROLLERS": "src/www/js/app/controllers"
},
"cordova": {
"platforms": [
"android",
"browser",
"ios"
],
"plugins": {
"cordova-labs-local-webserver": {},
"cordova-plugin-device": {},
"cordova-plugin-globalization": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-network-information": {},
"cordova-plugin-safariviewcontroller": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-webpack-transpiler": {
"CONFIG": "typescript"
},
"cordova-plugin-whitelist": {},
"cordova-plugin-wkwebview-engine": {},
"cordova-sqlite-ext": {},
"ionic-plugin-keyboard": {},
"phonegap-plugin-mobile-accessibility": {}
}
},
"scripts": {
"webpack": "webpack",
"test": "rimraf ./.tmp && mocha-webpack",
"cover": "rimraf ./.tmp && cross-env NODE_ENV=cover nyc npm test && open coverage/index.html",
"lint": "eslint www.src/es/**/*.js"
}
}
16 changes: 8 additions & 8 deletions test/DefinitionModel.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* Logology testing suite
*
*
* This suite tests the basic features of Logology. Don't assume that this test suite
* is in any way complete; as bugs are discovered, new tests will be added.
*
* Author: Kerri Shotts <[email protected]>
*
* Author: Kerri Shotts <[email protected]>
* http://www.photokandy.com/books/mastering-phonegap
*
* MIT LICENSED
*
*
* Copyright (c) 2016 Packt Publishing
* Portions Copyright (c) 2016 Kerri Shotts (photoKandy Studios LLC)
* Portions Copyright various third parties where noted.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights to use, copy, modify,
Expand All @@ -32,18 +32,18 @@
"use strict";

let should = require("./helpers/setup").should;
import Definition from "../src/www/js/app/models/Definition";
import Definition from "../www.src/es/app/models/Definition";

describe("Definition Tests", () => {
it("should be able to create a new definition", () => {
let d = new Definition({wordNetRef:1,
let d = new Definition({wordNetRef:1,
lemmas: ["apple"],
partOfSpeech: "n",
gloss: "A tasty fruit"});
return d.should.exist;
})
it("should be able to create a new noun", () => {
let d = new Definition({wordNetRef:1,
let d = new Definition({wordNetRef:1,
lemmas: ["apple"],
partOfSpeech: "n",
gloss: "A tasty fruit"});
Expand Down
18 changes: 9 additions & 9 deletions test/DictionaryModel.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* Logology testing suite
*
*
* This suite tests the basic features of Logology. Don't assume that this test suite
* is in any way complete; as bugs are discovered, new tests will be added.
*
* Author: Kerri Shotts <[email protected]>
*
* Author: Kerri Shotts <[email protected]>
* http://www.photokandy.com/books/mastering-phonegap
*
* MIT LICENSED
*
*
* Copyright (c) 2016 Packt Publishing
* Portions Copyright (c) 2016 Kerri Shotts (photoKandy Studios LLC)
* Portions Copyright various third parties where noted.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights to use, copy, modify,
Expand All @@ -33,8 +33,8 @@
"use strict";

let should = require("./helpers/setup").should;
import Dictionary from "../src/www/js/app/models/Dictionary";
import Definition from "../src/www/js/app/models/Definition";
import Dictionary from "../www.src/es/app/models/Dictionary";
import Definition from "../www.src/es/app/models/Definition";

describe("Dictionary Tests", () => {

Expand All @@ -45,14 +45,14 @@ describe("Dictionary Tests", () => {
return dictionary.should.exist;
});
});

describe ("#Loaded", () => {
it("should be able to set itself as loaded", () => {
dictionary.loaded();
return dictionary.isLoaded.should.be.true;
})
})

describe ("#Empty", () => {
it("should return an empty sorted index", () => {
return dictionary.sortedIndex.should.have.lengthOf(0);
Expand Down
18 changes: 10 additions & 8 deletions test/FavoritesModel.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* Logology testing suite
*
*
* This suite tests the basic features of Logology. Don't assume that this test suite
* is in any way complete; as bugs are discovered, new tests will be added.
*
* Author: Kerri Shotts <[email protected]>
*
* Author: Kerri Shotts <[email protected]>
* http://www.photokandy.com/books/mastering-phonegap
*
* MIT LICENSED
*
*
* Copyright (c) 2016 Packt Publishing
* Portions Copyright (c) 2016 Kerri Shotts (photoKandy Studios LLC)
* Portions Copyright various third parties where noted.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights to use, copy, modify,
Expand All @@ -31,21 +31,23 @@

"use strict";
let should = require("./helpers/setup").should;
import Favorites from "../src/www/js/app/models/Favorites";
import Favorites from "../www.src/es/app/models/Favorites";
import {createIndexedDBKVStore} from "../www.src/es/app/lib/IndexedDBKVStore";
let indexedDB = require("fake-indexeddb");

describe("Favorites", () => {

describe("#Create", () => {
it("should be able to create a new Favorites object", () => {
let favorites = new Favorites();
let favorites = new Favorites({adapter:createIndexedDBKVStore({indexedDB})});
return favorites.should.exist;
});
});

describe("#Manage", () => {
let favorites = {};
it ("should report a new word as not a favorite", () => {
favorites = new Favorites();
favorites = new Favorites({adapter:createIndexedDBKVStore({indexedDB})});
favorites.isWordAFavorite("mumble").should.become(false);
});
it ("should save a word as a favorite", () => {
Expand Down
20 changes: 10 additions & 10 deletions test/KVStore.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* Logology testing suite
*
*
* This suite tests the basic features of Logology. Don't assume that this test suite
* is in any way complete; as bugs are discovered, new tests will be added.
*
* Author: Kerri Shotts <[email protected]>
*
* Author: Kerri Shotts <[email protected]>
* http://www.photokandy.com/books/mastering-phonegap
*
* MIT LICENSED
*
*
* Copyright (c) 2016 Packt Publishing
* Portions Copyright (c) 2016 Kerri Shotts (photoKandy Studios LLC)
* Portions Copyright various third parties where noted.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights to use, copy, modify,
Expand Down Expand Up @@ -51,15 +51,15 @@ else {
}
let should = require("./helpers/setup").should;

import {createKVStore} from "../src/www/js/app/lib/KVStore";
import {createLocalStorageKVStore} from "../src/www/js/app/lib/LocalStorageKVStore";
import {createIndexedDBKVStore} from "../src/www/js/app/lib/IndexedDBKVStore";
import {createWebSQLKVStore} from "../src/www/js/app/lib/WebSQLKVStore";
import {createKVStore} from "../www.src/es/app/lib/KVStore";
import {createLocalStorageKVStore} from "../www.src/es/app/lib/LocalStorageKVStore";
import {createIndexedDBKVStore} from "../www.src/es/app/lib/IndexedDBKVStore";
import {createWebSQLKVStore} from "../www.src/es/app/lib/WebSQLKVStore";

describe ("KVStore", () => {
[["localStorage", createLocalStorageKVStore, "localStorage", localStorage],
["IndexedDB", createIndexedDBKVStore, "indexedDB", indexedDB],
["WebSQL", createWebSQLKVStore, "openDatabase", openDatabase]
//["WebSQL", createWebSQLKVStore, "openDatabase", openDatabase]
].forEach( ([adapterName, adapterFn, mockProperty, mock]) => {
describe ("Using " + adapterName, () => {
if (mock) {
Expand Down
Loading

0 comments on commit 40426d8

Please sign in to comment.