Update Deps and add FS example
This commit is contained in:
		
						commit
						968a1714e7
					
				| @ -1 +1 @@ | |||||||
| chrome 77 | chrome 78 | ||||||
|  | |||||||
							
								
								
									
										161
									
								
								.eslintrc.js
									
									
									
									
									
								
							
							
						
						
									
										161
									
								
								.eslintrc.js
									
									
									
									
									
								
							| @ -21,167 +21,18 @@ module.exports = { | |||||||
|   }, |   }, | ||||||
|   plugins: [ |   plugins: [ | ||||||
|     'jest', |     'jest', | ||||||
|     // required to lint *.vue files
 |  | ||||||
|     'vue' |     'vue' | ||||||
|   ], |   ], | ||||||
|   extends: [ |   extends: [ | ||||||
|     'eslint:recommended', |     'eslint:recommended', | ||||||
|     'plugin:vue/recommended', |     'plugin:jest/recommended', | ||||||
|     'plugin:jest/recommended' |     'tjw-base', | ||||||
|  |     'tjw-vue' | ||||||
|   ], |   ], | ||||||
|   rules: { |   rules: { | ||||||
|     'arrow-parens': ['off'], |     'no-restricted-syntax': [ | ||||||
|     'brace-style': [ |  | ||||||
|       'error', |       'error', | ||||||
|       '1tbs', |       'Property[method="true"]' | ||||||
|       { |     ] | ||||||
|         'allowSingleLine': true |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     'comma-dangle': ['error', 'never'], |  | ||||||
|     'comma-spacing': [ |  | ||||||
|       'error', |  | ||||||
|       { |  | ||||||
|         'before': false, |  | ||||||
|         'after': true |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     'comma-style': ['error', 'last'], |  | ||||||
|     'curly': ['error'], |  | ||||||
|     // allow async-await
 |  | ||||||
|     'generator-star-spacing': ['off'], |  | ||||||
|     // 2 space indentation to match .editorconfig
 |  | ||||||
|     'indent': [ |  | ||||||
|       'error', |  | ||||||
|       2, |  | ||||||
|       { |  | ||||||
|         'SwitchCase': 1 |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     'keyword-spacing': [ |  | ||||||
|       'error', |  | ||||||
|       { |  | ||||||
|         'before': true, |  | ||||||
|         'after': true |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     // allow debugger during development
 |  | ||||||
|     'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', |  | ||||||
|     'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', |  | ||||||
|     'no-multi-spaces': ['error'], |  | ||||||
|     'no-restricted-syntax': ['error', 'Property[method="true"]'], |  | ||||||
|     'no-unused-vars': ['error'], |  | ||||||
|     'no-undef': ['error'], |  | ||||||
|     // Only allow let and const, no var
 |  | ||||||
|     'no-var': ['error'], |  | ||||||
|     'object-curly-spacing': ['error', 'always'], |  | ||||||
|     'one-var': ['error', 'never'], |  | ||||||
|     'quotes': ['error', 'single'], |  | ||||||
|     'semi': ['error', 'always'], |  | ||||||
|     'space-before-blocks': ['error', 'always'], |  | ||||||
|     'space-before-function-paren': ['error', 'always'], |  | ||||||
|     'space-in-parens': ['error', 'never'], |  | ||||||
|     'space-infix-ops': ['error'], |  | ||||||
|     'spaced-comment': ['error', 'always'], |  | ||||||
|     // Vue Linter Options
 |  | ||||||
|     'vue/attribute-hyphenation': ['error', 'never'], |  | ||||||
|     'vue/attributes-order': [ |  | ||||||
|       'error', |  | ||||||
|       { |  | ||||||
|         'order': [ |  | ||||||
|           // 'v-for item in items'
 |  | ||||||
|           'LIST_RENDERING', |  | ||||||
|           // 'v-if', 'v-else-if', 'v-else', 'v-show', 'v-cloak'
 |  | ||||||
|           'CONDITIONALS', |  | ||||||
|           // 'v-once', 'v-pre'
 |  | ||||||
|           'RENDER_MODIFIERS', |  | ||||||
|           // 'v-model', 'v-bind', ':property="foo"'
 |  | ||||||
|           'BINDING', |  | ||||||
|           // 'v-text', 'v-html'
 |  | ||||||
|           'CONTENT', |  | ||||||
|           // 'is'
 |  | ||||||
|           'DEFINITION', |  | ||||||
|           // 'id'
 |  | ||||||
|           'GLOBAL', |  | ||||||
|           // 'customProp="foo"', 'class', 'type', 'value' etc
 |  | ||||||
|           'OTHER_ATTR', |  | ||||||
|           // '@click="functionCall"', 'v-on="event"'
 |  | ||||||
|           'EVENTS', |  | ||||||
|           // 'slot', 'key', 'ref'
 |  | ||||||
|           'UNIQUE' |  | ||||||
|         ] |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     'vue/html-closing-bracket-newline': [ |  | ||||||
|       'error', |  | ||||||
|       { |  | ||||||
|         'singleline': 'never', |  | ||||||
|         'multiline': 'always' |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     'vue/html-closing-bracket-spacing': [ |  | ||||||
|       'error', |  | ||||||
|       { |  | ||||||
|         'startTag': 'never', |  | ||||||
|         'endTag': 'never', |  | ||||||
|         'selfClosingTag': 'always' |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     'vue/html-indent': [ |  | ||||||
|       'error', |  | ||||||
|       2, |  | ||||||
|       { |  | ||||||
|         'attribute': 1, |  | ||||||
|         'closeBracket': 0 |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     'vue/html-self-closing': [ |  | ||||||
|       'error', |  | ||||||
|       { |  | ||||||
|         'html': { |  | ||||||
|           'void': 'always', |  | ||||||
|           'normal': 'never', |  | ||||||
|           'component': 'always' |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     'vue/max-attributes-per-line': [ |  | ||||||
|       'error', |  | ||||||
|       { |  | ||||||
|         'singleline': 3, |  | ||||||
|         'multiline': { |  | ||||||
|           'max': 1, |  | ||||||
|           'allowFirstLine': false |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     'vue/name-property-casing': ['error', 'PascalCase'], |  | ||||||
|     'vue/order-in-components': [ |  | ||||||
|       'error', |  | ||||||
|       { |  | ||||||
|         'order': [ |  | ||||||
|           'el', |  | ||||||
|           'name', |  | ||||||
|           ['template', 'render'], |  | ||||||
|           'parent', |  | ||||||
|           'functional', |  | ||||||
|           ['delimiters', 'comments'], |  | ||||||
|           ['components', 'directives'], |  | ||||||
|           'extends', |  | ||||||
|           'mixins', |  | ||||||
|           'inheritAttrs', |  | ||||||
|           'model', |  | ||||||
|           ['props', 'propsData'], |  | ||||||
|           'data', |  | ||||||
|           'methods', |  | ||||||
|           'computed', |  | ||||||
|           'filters', |  | ||||||
|           'watch', |  | ||||||
|           'LIFECYCLE_HOOKS', |  | ||||||
|           'renderError' |  | ||||||
|         ] |  | ||||||
|       } |  | ||||||
|     ], |  | ||||||
|     'vue/prop-name-casing': ['error', 'camelCase'] |  | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  | |||||||
							
								
								
									
										9
									
								
								.travis.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								.travis.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | |||||||
|  | sudo: required | ||||||
|  | dist: trusty | ||||||
|  | language: node_js | ||||||
|  | node_js: | ||||||
|  |   - "10" | ||||||
|  | install: | ||||||
|  |     - npm install | ||||||
|  | script: | ||||||
|  |     - npm run validate | ||||||
| @ -1,13 +1,15 @@ | |||||||
| # nw-vue-cli-example | # nw-vue-cli-example | ||||||
| 
 | 
 | ||||||
| NW.js + Vue-CLI 3 example | [](https://travis-ci.org/nwutils/nw-vue-cli-example) | ||||||
|  | 
 | ||||||
|  | NW.js + Vue-CLI 4 example | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
| 
 | 
 | ||||||
| * NW.js | * NW.js | ||||||
| * Vue-CLI 3 | * Vue-CLI 4 | ||||||
| * Vue 2 | * Vue 2 | ||||||
| * Vue-DevTools | * Vue-DevTools (latest) | ||||||
| * Babel | * Babel | ||||||
| * ESLint | * ESLint | ||||||
| * Jest (100% test coverage) | * Jest (100% test coverage) | ||||||
|  | |||||||
							
								
								
									
										6781
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6781
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										38
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								package.json
									
									
									
									
									
								
							| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "nw-vue", |   "name": "nw-vue", | ||||||
|   "version": "1.0.0", |   "version": "1.1.0", | ||||||
|   "main": "http://localhost:8964", |   "main": "http://localhost:8964", | ||||||
|   "node-remote": "http://localhost:8964", |   "node-remote": "http://localhost:8964", | ||||||
|   "node-main": "", |   "node-main": "", | ||||||
| @ -21,26 +21,27 @@ | |||||||
|     "build:nw": "build --concurrent --tasks win-x86,linux-x86,linux-x64,mac-x64 --mirror https://dl.nwjs.io/ .", |     "build:nw": "build --concurrent --tasks win-x86,linux-x86,linux-x64,mac-x64 --mirror https://dl.nwjs.io/ .", | ||||||
|     "build:win": "npm run build:win:clean && npm run build:vue && build --tasks win-x86 --mirror https://dl.nwjs.io/ .", |     "build:win": "npm run build:win:clean && npm run build:vue && build --tasks win-x86 --mirror https://dl.nwjs.io/ .", | ||||||
|     "build:lin": "npm run build:lin:clean && npm run build:vue && build --tasks linux-x64 --mirror https://dl.nwjs.io/ .", |     "build:lin": "npm run build:lin:clean && npm run build:vue && build --tasks linux-x64 --mirror https://dl.nwjs.io/ .", | ||||||
|     "build:win:clean": "rimraf ./dist-vue ./dist/nw-vue-1.0.0-win-x86 ./dist/nw-vue-1.0.0-win-x86.zip ./dist/nw-vue-1.0.0-win-x86.7z ./dist/nw-vue-1.0.0-win-x86-Setup.exe", |     "build:win:clean": "rimraf ./dist-vue ./dist/nw-vue-1.1.0-win-x86 ./dist/nw-vue-1.1.0-win-x86.zip ./dist/nw-vue-1.1.0-win-x86.7z ./dist/nw-vue-1.1.0-win-x86-Setup.exe", | ||||||
|     "build:lin:clean": "rimraf ./dist-vue ./dist/nw-vue-1.0.0-linux-x64 ./dist/nw-vue-1.0.0-linux-x64.zip", |     "build:lin:clean": "rimraf ./dist-vue ./dist/nw-vue-1.1.0-linux-x64 ./dist/nw-vue-1.1.0-linux-x64.zip", | ||||||
|     "run:win": "dist\\nw-vue-1.0.0-win-x86\\nw-vue.exe", |     "run:win": "dist\\nw-vue-1.1.0-win-x86\\nw-vue.exe", | ||||||
|     "run:lin": "./dist/nw-vue-1.0.0-linux-x64/nw-vue", |     "run:lin": "./dist/nw-vue-1.1.0-linux-x64/nw-vue", | ||||||
|     "regression": "rd /s /q node_modules & rd /s /q node_modules & rd /s /q node_modules & npm install && npm run lint && npm test && npm run build:win && npm run run:win", |     "regression": "rd /s /q node_modules & rd /s /q node_modules & rd /s /q node_modules & npm install && npm run lint && npm test && npm run build:win && npm run run:win", | ||||||
|     "lint": "vue-cli-service lint --no-fix", |     "lint": "vue-cli-service lint --no-fix", | ||||||
|     "fix": "vue-cli-service lint --fix", |     "fix": "vue-cli-service lint --fix", | ||||||
|     "test": "npm run test:unit", |     "test": "npm run test:unit", | ||||||
|     "test:e2e": "vue-cli-service test:e2e", |     "test:e2e": "vue-cli-service test:e2e", | ||||||
|     "test:unit": "jest --config jest.config.js --coverage --runInBand" |     "test:unit": "jest --config jest.config.js --coverage --runInBand", | ||||||
|  |     "validate": "npm run lint && npm run test:unit && npm run build:vue" | ||||||
|   }, |   }, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "express": "^4.17.1" |     "express": "^4.17.1" | ||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "@vue/cli-plugin-babel": "^3.11.0", |     "@vue/cli-plugin-babel": "^4.0.5", | ||||||
|     "@vue/cli-plugin-e2e-nightwatch": "^3.11.0", |     "@vue/cli-plugin-e2e-nightwatch": "^4.0.5", | ||||||
|     "@vue/cli-plugin-eslint": "^3.11.0", |     "@vue/cli-plugin-eslint": "^4.0.5", | ||||||
|     "@vue/cli-plugin-unit-jest": "^3.11.0", |     "@vue/cli-plugin-unit-jest": "^4.0.5", | ||||||
|     "@vue/cli-service": "^3.11.0", |     "@vue/cli-service": "^4.0.5", | ||||||
|     "@vue/test-utils": "1.0.0-beta.29", |     "@vue/test-utils": "1.0.0-beta.29", | ||||||
|     "babel-core": "7.0.0-bridge.0", |     "babel-core": "7.0.0-bridge.0", | ||||||
|     "babel-eslint": "^10.0.3", |     "babel-eslint": "^10.0.3", | ||||||
| @ -50,15 +51,18 @@ | |||||||
|     "babel-preset-env": "^1.7.0", |     "babel-preset-env": "^1.7.0", | ||||||
|     "babel-preset-stage-2": "^6.24.1", |     "babel-preset-stage-2": "^6.24.1", | ||||||
|     "babel-preset-vue-app": "^2.0.0", |     "babel-preset-vue-app": "^2.0.0", | ||||||
|     "concurrently": "^4.1.2", |     "concurrently": "^5.0.0", | ||||||
|     "core-js": "^2.6.5", |     "core-js": "^3.3.5", | ||||||
|     "eslint": "^6.4.0", |     "eslint": "^6.6.0", | ||||||
|     "eslint-plugin-jest": "^22.17.0", |     "eslint-config-tjw-base": "^1.0.0", | ||||||
|  |     "eslint-config-tjw-vue": "^1.0.0", | ||||||
|  |     "eslint-plugin-jest": "^23.0.2", | ||||||
|     "eslint-plugin-vue": "^5.2.3", |     "eslint-plugin-vue": "^5.2.3", | ||||||
|     "jest": "^24.9.0", |     "jest": "^24.9.0", | ||||||
|  |     "jest-environment-jsdom": "^24.9.0", | ||||||
|     "jest-environment-jsdom-global": "^1.2.0", |     "jest-environment-jsdom-global": "^1.2.0", | ||||||
|     "jest-transform-stub": "^2.0.0", |     "jest-transform-stub": "^2.0.0", | ||||||
|     "nw": "0.41.1-sdk", |     "nw": "0.42.0-sdk", | ||||||
|     "nw-vue-devtools": "^1.3.0", |     "nw-vue-devtools": "^1.3.0", | ||||||
|     "nwjs-builder-phoenix": "^1.15.0", |     "nwjs-builder-phoenix": "^1.15.0", | ||||||
|     "nwjs-types": "^1.0.0", |     "nwjs-types": "^1.0.0", | ||||||
| @ -70,7 +74,7 @@ | |||||||
|   }, |   }, | ||||||
|   "chromium-args": "--load-extension='./node_modules/nw-vue-devtools/extension'", |   "chromium-args": "--load-extension='./node_modules/nw-vue-devtools/extension'", | ||||||
|   "build": { |   "build": { | ||||||
|     "nwVersion": "v0.41.1", |     "nwVersion": "v0.42.0", | ||||||
|     "nwFlavor": "normal", |     "nwFlavor": "normal", | ||||||
|     "targets": [ |     "targets": [ | ||||||
|       "zip", |       "zip", | ||||||
|  | |||||||
							
								
								
									
										85
									
								
								src/components/FsExample.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								src/components/FsExample.vue
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,85 @@ | |||||||
|  | <template> | ||||||
|  |   <div> | ||||||
|  |     <div v-if="error"> | ||||||
|  |       There was an error attempting to read from the file system. | ||||||
|  |     </div> | ||||||
|  | 
 | ||||||
|  |     <button | ||||||
|  |       data-test="fs-example-button" | ||||||
|  |       @click="getCurrentDirectory" | ||||||
|  |     > | ||||||
|  |       <template v-if="!error"> | ||||||
|  |         Click for File System example | ||||||
|  |       </template> | ||||||
|  |       <template v-else> | ||||||
|  |         Try again for File System example | ||||||
|  |       </template> | ||||||
|  |     </button> | ||||||
|  | 
 | ||||||
|  |     <template v-if="contents"> | ||||||
|  |       <p> | ||||||
|  |         The contents of the current working directory: | ||||||
|  |       </p> | ||||||
|  |       <div class="contents"> | ||||||
|  |         <div | ||||||
|  |           v-for="(file, fileIndex) in contents" | ||||||
|  |           class="file" | ||||||
|  |           :key="'file' + fileIndex" | ||||||
|  |         > | ||||||
|  |           {{ file }} | ||||||
|  |         </div> | ||||||
|  |       </div> | ||||||
|  |     </template> | ||||||
|  |   </div> | ||||||
|  | </template> | ||||||
|  | 
 | ||||||
|  | <script> | ||||||
|  | export default { | ||||||
|  |   name: 'FsExample', | ||||||
|  |   data: function () { | ||||||
|  |     return { | ||||||
|  |       contents: null, | ||||||
|  |       error: false | ||||||
|  |     }; | ||||||
|  |   }, | ||||||
|  |   methods: { | ||||||
|  |     getCurrentDirectory: function () { | ||||||
|  |       const fs = window.nw.require('fs'); | ||||||
|  |       try { | ||||||
|  |         this.contents = fs.readdirSync('.'); | ||||||
|  |         this.error = false; | ||||||
|  |       } catch (err) { | ||||||
|  |         this.error = true; | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   computed: {} | ||||||
|  | }; | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | <style scoped> | ||||||
|  | button { | ||||||
|  |   background: linear-gradient(0deg, #2EB277, #65E6AC); | ||||||
|  |   border-width: 3.4px; | ||||||
|  |   border-color: #35495E; | ||||||
|  |   border-radius: 8px; | ||||||
|  |   margin: 22px 0px 6px 0px; | ||||||
|  |   padding: 11px 17px; | ||||||
|  |   color: #050709; | ||||||
|  |   font-family: 'Trebuchet MS', Verdana, sans-serif; | ||||||
|  |   font-size: 16px; | ||||||
|  |   font-weight: bold; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .contents { | ||||||
|  |   display: flex; | ||||||
|  |   flex-flow: wrap; | ||||||
|  | } | ||||||
|  | .file { | ||||||
|  |   flex-grow: 1; | ||||||
|  |   min-width: 200px; | ||||||
|  |   background: #DDD; | ||||||
|  |   margin: 5px; | ||||||
|  |   padding: 11px; | ||||||
|  | } | ||||||
|  | </style> | ||||||
| @ -37,17 +37,23 @@ | |||||||
| 
 | 
 | ||||||
|     <h3>Ecosystem</h3> |     <h3>Ecosystem</h3> | ||||||
|     <LinkList :links="ecosystemLinks" /> |     <LinkList :links="ecosystemLinks" /> | ||||||
|  | 
 | ||||||
|  |     <hr /> | ||||||
|  | 
 | ||||||
|  |     <FsExample /> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
| <script> | <script> | ||||||
| import Vue from 'vue'; | import Vue from 'vue'; | ||||||
| 
 | 
 | ||||||
|  | import FsExample from '@/components/FsExample.vue'; | ||||||
| import LinkList from '@/components/LinkList.vue'; | import LinkList from '@/components/LinkList.vue'; | ||||||
| 
 | 
 | ||||||
| export default { | export default { | ||||||
|   name: 'HelloWorld', |   name: 'HelloWorld', | ||||||
|   components: { |   components: { | ||||||
|  |     FsExample, | ||||||
|     LinkList |     LinkList | ||||||
|   }, |   }, | ||||||
|   props: { |   props: { | ||||||
| @ -157,7 +163,7 @@ export default { | |||||||
|   }, |   }, | ||||||
|   computed: { |   computed: { | ||||||
|     devMode: function () { |     devMode: function () { | ||||||
|       return window.process.env.NODE_ENV === 'development'; |       return window.process.versions['nw-flavor'] === 'sdk'; | ||||||
|     }, |     }, | ||||||
|     versions: function () { |     versions: function () { | ||||||
|       return window.process.versions; |       return window.process.versions; | ||||||
|  | |||||||
							
								
								
									
										41
									
								
								tests/unit/components/FsExample.test.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								tests/unit/components/FsExample.test.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | |||||||
|  | import { shallowMount } from '@vue/test-utils'; | ||||||
|  | import FsExample from '@/components/FsExample.vue'; | ||||||
|  | 
 | ||||||
|  | describe('FsExample.vue', () => { | ||||||
|  |   test('Render default contents', () => { | ||||||
|  |     const wrapper = shallowMount(FsExample); | ||||||
|  | 
 | ||||||
|  |     expect(wrapper.html()) | ||||||
|  |       .toMatchSnapshot(); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   test('Click button', () => { | ||||||
|  |     const wrapper = shallowMount(FsExample); | ||||||
|  |     let domButton = wrapper.find('[data-test="fs-example-button"]'); | ||||||
|  |     domButton.trigger('click'); | ||||||
|  | 
 | ||||||
|  |     expect(window.nw.require) | ||||||
|  |       .toHaveBeenCalledWith('fs'); | ||||||
|  | 
 | ||||||
|  |     expect(wrapper.html()) | ||||||
|  |       .toMatchSnapshot(); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   test('Error state', () => { | ||||||
|  |     window.nw.require.mockImplementation((module) => { | ||||||
|  |       if (module === 'fs') { | ||||||
|  |         return new Error(); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     const wrapper = shallowMount(FsExample); | ||||||
|  |     let domButton = wrapper.find('[data-test="fs-example-button"]'); | ||||||
|  |     domButton.trigger('click'); | ||||||
|  | 
 | ||||||
|  |     expect(window.nw.require) | ||||||
|  |       .toHaveBeenCalledWith('fs'); | ||||||
|  | 
 | ||||||
|  |     expect(wrapper.html()) | ||||||
|  |       .toMatchSnapshot(); | ||||||
|  |   }); | ||||||
|  | }); | ||||||
							
								
								
									
										43
									
								
								tests/unit/components/__snapshots__/FsExample.test.js.snap
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								tests/unit/components/__snapshots__/FsExample.test.js.snap
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,43 @@ | |||||||
|  | // Jest Snapshot v1, https://goo.gl/fbAQLP | ||||||
|  | 
 | ||||||
|  | exports[`FsExample.vue Click button 1`] = ` | ||||||
|  | <div> | ||||||
|  |   <!----> | ||||||
|  |   <button> | ||||||
|  |     Click for File System example | ||||||
|  |   </button> | ||||||
|  |   <p> | ||||||
|  |     The contents of the current working directory: | ||||||
|  |   </p> | ||||||
|  |   <div class="contents"> | ||||||
|  |     <div class="file"> | ||||||
|  |       example-file-1.ext | ||||||
|  |     </div> | ||||||
|  |     <div class="file"> | ||||||
|  |       example-file-2.ext | ||||||
|  |     </div> | ||||||
|  |   </div> | ||||||
|  | </div> | ||||||
|  | `; | ||||||
|  | 
 | ||||||
|  | exports[`FsExample.vue Error state 1`] = ` | ||||||
|  | <div> | ||||||
|  |   <div> | ||||||
|  |     There was an error attempting to read from the file system. | ||||||
|  |   </div> | ||||||
|  |   <button> | ||||||
|  |     Try again for File System example | ||||||
|  |   </button> | ||||||
|  |   <!----> | ||||||
|  | </div> | ||||||
|  | `; | ||||||
|  | 
 | ||||||
|  | exports[`FsExample.vue Render default contents 1`] = ` | ||||||
|  | <div> | ||||||
|  |   <!----> | ||||||
|  |   <button> | ||||||
|  |     Click for File System example | ||||||
|  |   </button> | ||||||
|  |   <!----> | ||||||
|  | </div> | ||||||
|  | `; | ||||||
| @ -24,10 +24,10 @@ exports[`HelloWorld.vue Render default contents 1`] = ` | |||||||
|   <h3> |   <h3> | ||||||
|     You are using |     You are using | ||||||
|     Vue.js (v2.6.10), |     Vue.js (v2.6.10), | ||||||
|     NW.js (v0.41.1-sdk), |     NW.js (v0.42.0-sdk), | ||||||
|     Node.js (v12.9.1), |     Node.js (v12.12.0), | ||||||
|     and |     and | ||||||
|     Chromium (v77.0.3865.75). |     Chromium (v78.0.3904.70). | ||||||
|   </h3> |   </h3> | ||||||
|   <button> |   <button> | ||||||
|     Show |     Show | ||||||
| @ -141,5 +141,13 @@ exports[`HelloWorld.vue Render default contents 1`] = ` | |||||||
|       </a> |       </a> | ||||||
|     </li> |     </li> | ||||||
|   </ul> |   </ul> | ||||||
|  |   <hr> | ||||||
|  |   <div> | ||||||
|  |     <!----> | ||||||
|  |     <button> | ||||||
|  |       Click for File System example | ||||||
|  |     </button> | ||||||
|  |     <!----> | ||||||
|  |   </div> | ||||||
| </div> | </div> | ||||||
| `; | `; | ||||||
|  | |||||||
| @ -26,13 +26,22 @@ global.beforeEach(() => { | |||||||
|       NODE_ENV: 'development' |       NODE_ENV: 'development' | ||||||
|     }, |     }, | ||||||
|     versions: { |     versions: { | ||||||
|       chromium: '77.0.3865.75', |       chromium: '78.0.3904.70', | ||||||
|       nw: '0.41.1', |       nw: '0.42.0', | ||||||
|       'nw-flavor': 'sdk', |       'nw-flavor': 'sdk', | ||||||
|       node: '12.9.1' |       node: '12.12.0' | ||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
|   window.nw = { |   window.nw = { | ||||||
|  |     require: jest.fn((module) => { | ||||||
|  |       if (module === 'fs') { | ||||||
|  |         return { | ||||||
|  |           readdirSync: jest.fn(() => { | ||||||
|  |             return ['example-file-1.ext', 'example-file-2.ext']; | ||||||
|  |           }) | ||||||
|  |         }; | ||||||
|  |       } | ||||||
|  |     }), | ||||||
|     Shell: { |     Shell: { | ||||||
|       openExternal: jest.fn() |       openExternal: jest.fn() | ||||||
|     }, |     }, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user