├── static
└── .gitkeep
├── .eslintignore
├── config
├── prod.env.js
├── test.env.js
├── dev.env.js
└── index.js
├── src
├── assets
│ └── logo.png
├── main.js
├── router
│ └── index.js
├── components
│ ├── NoteListItem.vue
│ ├── NoteList.vue
│ ├── Note.vue
│ └── CreateNote.vue
└── App.vue
├── test
├── unit
│ ├── .eslintrc
│ ├── specs
│ │ └── Hello.spec.js
│ ├── index.js
│ └── karma.conf.js
└── e2e
│ ├── specs
│ └── test.js
│ ├── custom-assertions
│ └── elementCount.js
│ ├── runner.js
│ └── nightwatch.conf.js
├── .editorconfig
├── .postcssrc.js
├── index.html
├── .babelrc
├── README.md
├── .gitignore
├── .eslintrc.js
├── LICENSE
└── package.json
/static/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | build/*.js
2 | config/*.js
3 |
--------------------------------------------------------------------------------
/config/prod.env.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | NODE_ENV: '"production"'
3 | }
4 |
--------------------------------------------------------------------------------
/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/afropolymath/notes-app/HEAD/src/assets/logo.png
--------------------------------------------------------------------------------
/test/unit/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "mocha": true
4 | },
5 | "globals": {
6 | "expect": true,
7 | "sinon": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/config/test.env.js:
--------------------------------------------------------------------------------
1 | var merge = require('webpack-merge')
2 | var devEnv = require('./dev.env')
3 |
4 | module.exports = merge(devEnv, {
5 | NODE_ENV: '"testing"'
6 | })
7 |
--------------------------------------------------------------------------------
/config/dev.env.js:
--------------------------------------------------------------------------------
1 | var merge = require('webpack-merge')
2 | var prodEnv = require('./prod.env')
3 |
4 | module.exports = merge(prodEnv, {
5 | NODE_ENV: '"development"'
6 | })
7 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/.postcssrc.js:
--------------------------------------------------------------------------------
1 | // https://github.com/michael-ciniawsky/postcss-load-config
2 |
3 | module.exports = {
4 | "plugins": {
5 | // to edit target browsers: use "browserlist" field in package.json
6 | "autoprefixer": {}
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | notes-app
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["env", { "modules": false }],
4 | "stage-2"
5 | ],
6 | "plugins": ["transform-runtime"],
7 | "comments": false,
8 | "env": {
9 | "test": {
10 | "presets": ["env", "stage-2"],
11 | "plugins": [ "istanbul" ]
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/test/unit/specs/Hello.spec.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Hello from '@/components/Hello';
3 |
4 | describe('Hello.vue', () => {
5 | it('should render correct contents', () => {
6 | const Constructor = Vue.extend(Hello);
7 | const vm = new Constructor().$mount();
8 | expect(vm.$el.querySelector('.hello h1').textContent)
9 | .to.equal('Welcome to Your Vue.js App');
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | // The Vue build version to load with the `import` command
2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3 | import Vue from 'vue';
4 | import App from './App';
5 | import router from './router';
6 |
7 | Vue.config.productionTip = false;
8 |
9 | /* eslint-disable no-new */
10 | new Vue({
11 | el: '#app',
12 | router,
13 | template: '',
14 | localStorage: {
15 | notes: {
16 | type: Array,
17 | default: [],
18 | },
19 | },
20 | components: { App },
21 | });
22 |
--------------------------------------------------------------------------------
/test/e2e/specs/test.js:
--------------------------------------------------------------------------------
1 | // For authoring Nightwatch tests, see
2 | // http://nightwatchjs.org/guide#usage
3 |
4 | module.exports = {
5 | 'default e2e tests': function test(browser) {
6 | // automatically uses dev Server port from /config.index.js
7 | // default: http://localhost:8080
8 | // see nightwatch.conf.js
9 | const devServer = browser.globals.devServerURL;
10 |
11 | browser
12 | .url(devServer)
13 | .waitForElementVisible('#app', 5000)
14 | .assert.elementPresent('.hello')
15 | .assert.containsText('h1', 'Welcome to Your Vue.js App')
16 | .assert.elementCount('img', 1)
17 | .end();
18 | },
19 | };
20 |
--------------------------------------------------------------------------------
/test/unit/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | Vue.config.productionTip = false;
3 |
4 | // Polyfill fn.bind() for PhantomJS
5 | /* eslint-disable no-extend-native */
6 | Function.prototype.bind = require('function-bind');
7 |
8 | // require all test files (files that ends with .spec.js)
9 | const testsContext = require.context('./specs', true, /\.spec$/);
10 | testsContext.keys().forEach(testsContext);
11 |
12 | // require all src files except main.js for coverage.
13 | // you can also change this to match only the subset of files that
14 | // you want coverage for.
15 | const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/);
16 | srcContext.keys().forEach(srcContext);
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # notes-app
2 |
3 | > Vue.js sample notes application
4 |
5 | ## Build Setup
6 |
7 | ``` bash
8 | # install dependencies
9 | npm install
10 |
11 | # serve with hot reload at localhost:8080
12 | npm run dev
13 |
14 | # build for production with minification
15 | npm run build
16 |
17 | # build for production and view the bundle analyzer report
18 | npm run build --report
19 |
20 | # run unit tests
21 | npm run unit
22 |
23 | # run e2e tests
24 | npm run e2e
25 |
26 | # run all tests
27 | npm test
28 | ```
29 |
30 | For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
31 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | # Logs
4 | logs
5 | *.log
6 | npm-debug.log*
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 |
13 | # Directory for instrumented libs generated by jscoverage/JSCover
14 | lib-cov
15 |
16 | # Coverage directory used by tools like istanbul
17 | coverage
18 |
19 | # nyc test coverage
20 | .nyc_output
21 |
22 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
23 | .grunt
24 |
25 | # node-waf configuration
26 | .lock-wscript
27 |
28 | # Compiled binary addons (http://nodejs.org/api/addons.html)
29 | build/Release
30 |
31 | # Dependency directories
32 | node_modules
33 | jspm_packages
34 |
35 | # Optional npm cache directory
36 | .npm
37 |
38 | # Optional REPL history
39 | .node_repl_history
40 |
41 | # Vue-CLI related
42 | dist/
43 | yarn-error.log
44 | test/unit/coverage
45 | test/e2e/reports
46 | selenium-debug.log
47 |
--------------------------------------------------------------------------------
/test/e2e/custom-assertions/elementCount.js:
--------------------------------------------------------------------------------
1 | // A custom Nightwatch assertion.
2 | // the name of the method is the filename.
3 | // can be used in tests like this:
4 | //
5 | // browser.assert.elementCount(selector, count)
6 | //
7 | // for how to write custom assertions see
8 | // http://nightwatchjs.org/guide#writing-custom-assertions
9 | exports.assertion = function (selector, count) {
10 | this.message = 'Testing if element <' + selector + '> has count: ' + count;
11 | this.expected = count;
12 | this.pass = function (val) {
13 | return val === this.expected;
14 | }
15 | this.value = function (res) {
16 | return res.value;
17 | }
18 | this.command = function (cb) {
19 | var self = this;
20 | return this.api.execute(function (selector) {
21 | return document.querySelectorAll(selector).length;
22 | }, [selector], function (res) {
23 | cb.call(self, res);
24 | });
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/router/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Router from 'vue-router';
3 | import ElementUI from 'element-ui';
4 | import VueLocalStorage from 'vue-localstorage';
5 | import 'element-ui/lib/theme-default/index.css';
6 | import NoteList from '@/components/NoteList';
7 | import Note from '@/components/Note';
8 | import CreateNote from '@/components/CreateNote';
9 |
10 | Vue.use(Router);
11 | Vue.use(ElementUI);
12 | Vue.use(VueLocalStorage);
13 |
14 | export default new Router({
15 | routes: [
16 | {
17 | path: '/',
18 | name: 'All Notes',
19 | component: NoteList,
20 | },
21 | {
22 | path: '/view/:id',
23 | name: 'View Note',
24 | component: Note,
25 | props: true,
26 | },
27 | {
28 | path: '/new',
29 | name: 'Create Note',
30 | component: CreateNote,
31 | },
32 | {
33 | path: '/edit/:id',
34 | name: 'Edit Note',
35 | component: CreateNote,
36 | props: true,
37 | },
38 | ],
39 | });
40 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // http://eslint.org/docs/user-guide/configuring
2 |
3 | module.exports = {
4 | root: true,
5 | parser: 'babel-eslint',
6 | parserOptions: {
7 | sourceType: 'module'
8 | },
9 | env: {
10 | browser: true,
11 | },
12 | extends: 'airbnb-base',
13 | // required to lint *.vue files
14 | plugins: [
15 | 'html'
16 | ],
17 | // check if imports actually resolve
18 | 'settings': {
19 | 'import/resolver': {
20 | 'webpack': {
21 | 'config': 'build/webpack.base.conf.js'
22 | }
23 | }
24 | },
25 | // add your custom rules here
26 | 'rules': {
27 | // don't require .vue extension when importing
28 | 'import/extensions': ['error', 'always', {
29 | 'js': 'never',
30 | 'vue': 'never'
31 | }],
32 | // allow optionalDependencies
33 | 'import/no-extraneous-dependencies': ['error', {
34 | 'optionalDependencies': ['test/unit/index.js']
35 | }],
36 | // allow debugger during development
37 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/test/unit/karma.conf.js:
--------------------------------------------------------------------------------
1 | // This is a karma config file. For more details see
2 | // http://karma-runner.github.io/0.13/config/configuration-file.html
3 | // we are also using it with karma-webpack
4 | // https://github.com/webpack/karma-webpack
5 |
6 | var webpackConfig = require('../../build/webpack.test.conf');
7 |
8 | module.exports = function (config) {
9 | config.set({
10 | // to run in additional browsers:
11 | // 1. install corresponding karma launcher
12 | // http://karma-runner.github.io/0.13/config/browsers.html
13 | // 2. add it to the `browsers` array below.
14 | browsers: ['PhantomJS'],
15 | frameworks: ['mocha', 'sinon-chai'],
16 | reporters: ['spec', 'coverage'],
17 | files: ['./index.js'],
18 | preprocessors: {
19 | './index.js': ['webpack', 'sourcemap']
20 | },
21 | webpack: webpackConfig,
22 | webpackMiddleware: {
23 | noInfo: true,
24 | },
25 | coverageReporter: {
26 | dir: './coverage',
27 | reporters: [
28 | { type: 'lcov', subdir: '.' },
29 | { type: 'text-summary' },
30 | ]
31 | },
32 | });
33 | };
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Chidiebere Nnadi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/e2e/runner.js:
--------------------------------------------------------------------------------
1 | // 1. start the dev server using production config
2 | process.env.NODE_ENV = 'testing';
3 | var server = require('../../build/dev-server.js');
4 |
5 | // 2. run the nightwatch test suite against it
6 | // to run in additional browsers:
7 | // 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings"
8 | // 2. add it to the --env flag below
9 | // or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
10 | // For more information on Nightwatch's config file, see
11 | // http://nightwatchjs.org/guide#settings-file
12 | var opts = process.argv.slice(2);
13 | if (opts.indexOf('--config') === -1) {
14 | opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js']);
15 | }
16 | if (opts.indexOf('--env') === -1) {
17 | opts = opts.concat(['--env', 'chrome']);
18 | }
19 |
20 | var spawn = require('cross-spawn');
21 | var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' });
22 |
23 | runner.on('exit', function (code) {
24 | server.close();
25 | process.exit(code);
26 | });
27 |
28 | runner.on('error', function (err) {
29 | server.close();
30 | throw err;
31 | });
32 |
--------------------------------------------------------------------------------
/test/e2e/nightwatch.conf.js:
--------------------------------------------------------------------------------
1 | require('babel-register')
2 | var config = require('../../config')
3 |
4 | // http://nightwatchjs.org/getingstarted#settings-file
5 | module.exports = {
6 | src_folders: ['test/e2e/specs'],
7 | output_folder: 'test/e2e/reports',
8 | custom_assertions_path: ['test/e2e/custom-assertions'],
9 |
10 | selenium: {
11 | start_process: true,
12 | server_path: require('selenium-server').path,
13 | host: '127.0.0.1',
14 | port: 4444,
15 | cli_args: {
16 | 'webdriver.chrome.driver': require('chromedriver').path
17 | }
18 | },
19 |
20 | test_settings: {
21 | default: {
22 | selenium_port: 4444,
23 | selenium_host: 'localhost',
24 | silent: true,
25 | globals: {
26 | devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port)
27 | }
28 | },
29 |
30 | chrome: {
31 | desiredCapabilities: {
32 | browserName: 'chrome',
33 | javascriptEnabled: true,
34 | acceptSslCerts: true
35 | }
36 | },
37 |
38 | firefox: {
39 | desiredCapabilities: {
40 | browserName: 'firefox',
41 | javascriptEnabled: true,
42 | acceptSslCerts: true
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/components/NoteListItem.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{ note.text }}
6 | {{ parseTimestamp(note.timestamp) }}
7 |
8 |
9 |
10 |
11 |
23 |
24 |
60 |
--------------------------------------------------------------------------------
/src/components/NoteList.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 | Add Note
12 |
13 |
14 |
15 |
16 |
17 |
45 |
46 |
57 |
--------------------------------------------------------------------------------
/config/index.js:
--------------------------------------------------------------------------------
1 | // see http://vuejs-templates.github.io/webpack for documentation.
2 | var path = require('path')
3 |
4 | module.exports = {
5 | build: {
6 | env: require('./prod.env'),
7 | index: path.resolve(__dirname, '../dist/index.html'),
8 | assetsRoot: path.resolve(__dirname, '../dist'),
9 | assetsSubDirectory: 'static',
10 | assetsPublicPath: '/',
11 | productionSourceMap: true,
12 | // Gzip off by default as many popular static hosts such as
13 | // Surge or Netlify already gzip all static assets for you.
14 | // Before setting to `true`, make sure to:
15 | // npm install --save-dev compression-webpack-plugin
16 | productionGzip: false,
17 | productionGzipExtensions: ['js', 'css'],
18 | // Run the build command with an extra argument to
19 | // View the bundle analyzer report after build finishes:
20 | // `npm run build --report`
21 | // Set to `true` or `false` to always turn it on or off
22 | bundleAnalyzerReport: process.env.npm_config_report
23 | },
24 | dev: {
25 | env: require('./dev.env'),
26 | port: 8080,
27 | autoOpenBrowser: true,
28 | assetsSubDirectory: 'static',
29 | assetsPublicPath: '/',
30 | proxyTable: {},
31 | // CSS Sourcemaps off by default because relative paths are "buggy"
32 | // with this option, according to the CSS-Loader README
33 | // (https://github.com/webpack/css-loader#sourcemaps)
34 | // In our experience, they generally work as expected,
35 | // just be aware of this issue when enabling this option.
36 | cssSourceMap: false
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
89 |
--------------------------------------------------------------------------------
/src/components/Note.vue:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
56 |
57 |
64 |
--------------------------------------------------------------------------------
/src/components/CreateNote.vue:
--------------------------------------------------------------------------------
1 |
2 |
25 |
26 |
27 |
77 |
78 |
87 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "notes-app",
3 | "version": "1.0.0",
4 | "description": "A Vue.js project",
5 | "author": "Chidiebere Nnadi ",
6 | "private": true,
7 | "scripts": {
8 | "dev": "node build/dev-server.js",
9 | "build": "node build/build.js",
10 | "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
11 | "e2e": "node test/e2e/runner.js",
12 | "test": "npm run unit && npm run e2e",
13 | "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
14 | },
15 | "dependencies": {
16 | "element-ui": "^1.2.4",
17 | "moment": "^2.17.1",
18 | "uuid": "^3.0.1",
19 | "vue": "^2.2.2",
20 | "vue-localstorage": "^0.1.3",
21 | "vue-router": "^2.2.0"
22 | },
23 | "devDependencies": {
24 | "autoprefixer": "^6.7.2",
25 | "babel-core": "^6.22.1",
26 | "babel-eslint": "^7.1.1",
27 | "babel-loader": "^6.2.10",
28 | "babel-plugin-transform-runtime": "^6.22.0",
29 | "babel-preset-env": "^1.2.1",
30 | "babel-preset-stage-2": "^6.22.0",
31 | "babel-register": "^6.22.0",
32 | "chalk": "^1.1.3",
33 | "connect-history-api-fallback": "^1.3.0",
34 | "copy-webpack-plugin": "^4.0.1",
35 | "css-loader": "^0.26.1",
36 | "eslint": "^3.14.1",
37 | "eslint-friendly-formatter": "^2.0.7",
38 | "eslint-loader": "^1.6.1",
39 | "eslint-plugin-html": "^2.0.0",
40 | "eslint-config-airbnb-base": "^11.0.1",
41 | "eslint-import-resolver-webpack": "^0.8.1",
42 | "eslint-plugin-import": "^2.2.0",
43 | "eventsource-polyfill": "^0.9.6",
44 | "express": "^4.14.1",
45 | "extract-text-webpack-plugin": "^2.0.0",
46 | "file-loader": "^0.10.0",
47 | "friendly-errors-webpack-plugin": "^1.1.3",
48 | "function-bind": "^1.1.0",
49 | "html-webpack-plugin": "^2.28.0",
50 | "http-proxy-middleware": "^0.17.3",
51 | "webpack-bundle-analyzer": "^2.2.1",
52 | "cross-env": "^3.1.4",
53 | "karma": "^1.4.1",
54 | "karma-coverage": "^1.1.1",
55 | "karma-mocha": "^1.3.0",
56 | "karma-phantomjs-launcher": "^1.0.2",
57 | "karma-sinon-chai": "^1.2.4",
58 | "karma-sourcemap-loader": "^0.3.7",
59 | "karma-spec-reporter": "0.0.26",
60 | "karma-webpack": "^2.0.2",
61 | "lolex": "^1.5.2",
62 | "mocha": "^3.2.0",
63 | "chai": "^3.5.0",
64 | "sinon": "^1.17.7",
65 | "sinon-chai": "^2.8.0",
66 | "inject-loader": "^2.0.1",
67 | "babel-plugin-istanbul": "^3.1.2",
68 | "phantomjs-prebuilt": "^2.1.14",
69 | "chromedriver": "^2.27.2",
70 | "cross-spawn": "^5.0.1",
71 | "nightwatch": "^0.9.12",
72 | "selenium-server": "^3.0.1",
73 | "semver": "^5.3.0",
74 | "opn": "^4.0.2",
75 | "optimize-css-assets-webpack-plugin": "^1.3.0",
76 | "ora": "^1.1.0",
77 | "rimraf": "^2.6.0",
78 | "url-loader": "^0.5.7",
79 | "vue-loader": "^11.1.4",
80 | "vue-style-loader": "^2.0.0",
81 | "vue-template-compiler": "^2.2.1",
82 | "webpack": "^2.2.1",
83 | "webpack-dev-middleware": "^1.10.0",
84 | "webpack-hot-middleware": "^2.16.1",
85 | "webpack-merge": "^2.6.1"
86 | },
87 | "engines": {
88 | "node": ">= 4.0.0",
89 | "npm": ">= 3.0.0"
90 | },
91 | "browserslist": [
92 | "> 1%",
93 | "last 2 versions",
94 | "not ie <= 8"
95 | ]
96 | }
97 |
--------------------------------------------------------------------------------