From 3524b703a4e64602557d23ef1306cd99d60e0278 Mon Sep 17 00:00:00 2001 From: MrFrankel Date: Fri, 22 Jun 2018 14:17:19 +0300 Subject: [PATCH] fix tests --- README.md | 17 ++++- example/tsconfig.json | 13 ++-- example/webpack.config.js | 10 +-- package.json | 6 +- src/index.ts | 2 +- src/popper-content.ts | 8 ++- src/popper-directive.ts | 4 +- src/{popper.model.ts => popper-model.ts} | 0 src/popper.module.ts | 2 +- test/app/app.component.html | 2 +- test/tsconfig.json | 14 ++-- ...bpack.test.config.js => webpack.config.js} | 16 ++--- tsconfig.json | 2 +- webpack.test.config.js | 67 ------------------- yarn.lock | 10 +-- 15 files changed, 52 insertions(+), 121 deletions(-) rename src/{popper.model.ts => popper-model.ts} (100%) rename test/{webpack.test.config.js => webpack.config.js} (81%) delete mode 100644 webpack.test.config.js diff --git a/README.md b/README.md index 7523072..91dcf1d 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,22 @@ [![npm](https://img.shields.io/npm/v/ngx-popper.svg?style=flat-square)](https://www.npmjs.com/package/ngx-popper) [![npm](https://img.shields.io/npm/dm/ngx-popper.svg?style=flat-square)](https://www.npmjs.com/package/ngx-popper) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/MrFrankel/ngx-popper/blob/master/LICENSE) - Stable Release Size - Stable Release Size + Stable Release Size + Stable Release Size ngx-popper is an angular wrapper for the [Popper.js](https://popper.js.org/) library. +## Changes + +As of version 4.0.0 ngx-popper now use innerHTML binding for string popper i.e: +```HTML +
+``` + +This should make no difference but you should be aware. + +As of version 4.0.0 popper.model is now popper-model, due to some angular-cli issues, if you are referencing this please update your references. + ### Installation node and npm are required to run this package. @@ -15,12 +26,14 @@ node and npm are required to run this package. 1. Use npm/yarn to install the package: ```terminal + $ npm install popper.js --save $ npm install ngx-popper --save ``` Or ```terminal + $ yarn add popper.js --save $ yarn add ngx-popper --save ``` diff --git a/example/tsconfig.json b/example/tsconfig.json index 093c06b..b42d626 100644 --- a/example/tsconfig.json +++ b/example/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "outDir": "./dist-tsc", "module": "commonjs", "target": "es5", "sourceMap": true, @@ -18,8 +19,8 @@ ] }, "typeRoots": [ - "./node_modules/@types", - "./node_modules" + "../node_modules/@types", + "../node_modules" ], "types": [ "node" @@ -28,11 +29,9 @@ "." ], "exclude": [ - "node_modules", - "dist", - "dist-tsc", - "test", - "example-cli" + "../dist", + "../dist-tsc", + "../test" ], "angularCompilerOptions": { "preserveWhiteSpace": false diff --git a/example/webpack.config.js b/example/webpack.config.js index 71e79b6..72794c3 100644 --- a/example/webpack.config.js +++ b/example/webpack.config.js @@ -21,7 +21,7 @@ module.exports = { rules: [ { test: /\.ts?$/, - use: ['awesome-typescript-loader', 'angular2-template-loader'], + use: ['awesome-typescript-loader?configFileName="./tsconfig.json"', 'angular2-template-loader'], exclude: ['node_modules', 'dist', 'dist-tsc', 'test', 'public_api'] }, { @@ -33,15 +33,9 @@ module.exports = { }, plugins: [ new CheckerPlugin(), - new AngularCompilerPlugin({ - tsConfigPath: './example/tsconfig.json', - entryModule: 'example/app/app.module#AppModule', - sourceMap: true - }), - new HtmlWebpackPlugin({ inject: true, - template: 'example/index.html' + template: './example/index.html' }), new ProgressBarPlugin({ format: ' build [' + chalk.blue.bold(':bar') + ']' + chalk.green.bold(':percent') + ' (:elapsed seconds) => :msg... ', diff --git a/package.json b/package.json index 9f92b07..9c013b4 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "ngx-popper", - "version": "3.0.1", + "version": "4.0.1", "description": "ngx-popper is an angular wrapper for popper.js", "directories": { "test": "test" }, "scripts": { "test-server": "http-server test_dist -p 8888", - "create_test_server": "rm -rf test_dist && webpack --config ./test/webpack.test.config.js && npm run test-server", + "create_test_server": "rm -rf test_dist && webpack --config ./test/webpack.config.js && npm run test-server", "test": "jest", "start_test": "start-server-and-test create_test_server http://localhost:8888 test", "build": "ng-packagr -p ng-package.json", @@ -58,7 +58,7 @@ "install": "^0.11.0", "jest": "^23.0.0", "jest-puppeteer": "^3.0.1", - "ng-packagr": "^3.0.1", + "ng-packagr": "^3.0.3", "ng2draggable": "^1.3.2", "open-browser-webpack-plugin": "^0.0.5", "progress-bar-webpack-plugin": "^1.10.0", diff --git a/src/index.ts b/src/index.ts index 359e61d..03541f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ +export * from './popper-model'; export * from './popper-directive'; -export * from './popper.model'; export * from './popper-content'; export * from './popper.module'; \ No newline at end of file diff --git a/src/popper-content.ts b/src/popper-content.ts index 382cfc9..194c613 100644 --- a/src/popper-content.ts +++ b/src/popper-content.ts @@ -8,7 +8,7 @@ import { HostListener, Renderer2, } from "@angular/core"; import Popper from 'popper.js'; -import {Placements, Triggers, PopperContentOptions} from './popper.model'; +import {Placements, Triggers, PopperContentOptions} from './popper-model'; @Component({ selector: "popper-content", @@ -24,9 +24,11 @@ import {Placements, Triggers, PopperContentOptions} from './popper.model'; attr.aria-hidden="{{ariaHidden}}" [attr.aria-describedby]="popperOptions.ariaDescribe || null" attr.role="{{popperOptions.ariaRole}}"> -
+
+ +
+
- {{ text }}
diff --git a/src/popper-directive.ts b/src/popper-directive.ts index 9a5186b..4f2c4f5 100644 --- a/src/popper-directive.ts +++ b/src/popper-directive.ts @@ -9,8 +9,8 @@ import { Output, EventEmitter, OnInit, Renderer2, ChangeDetectorRef, Inject, ElementRef } from '@angular/core'; +import {Placement, Placements, PopperContentOptions, Trigger, Triggers} from './popper-model'; import {PopperContent} from './popper-content'; -import {Placement, Placements, PopperContentOptions, Trigger, Triggers} from './popper.model'; @Directive({ selector: '[popper]', @@ -338,7 +338,7 @@ export class PopperController implements OnInit, OnChanges { this.globalEventListeners.forEach(evt => { evt && typeof evt === 'function' && evt(); }); - this.eventListeners.length = 0; + this.globalEventListeners.length = 0; } private overrideShowTimeout() { diff --git a/src/popper.model.ts b/src/popper-model.ts similarity index 100% rename from src/popper.model.ts rename to src/popper-model.ts diff --git a/src/popper.module.ts b/src/popper.module.ts index 53ad371..8ad3ac6 100644 --- a/src/popper.module.ts +++ b/src/popper.module.ts @@ -1,8 +1,8 @@ import {CommonModule} from "@angular/common"; import {ModuleWithProviders, NgModule} from "@angular/core"; +import {PopperContentOptions} from './popper-model'; import {PopperController} from './popper-directive'; import {PopperContent} from './popper-content'; -import {PopperContentOptions} from './popper.model'; @NgModule({ imports: [ diff --git a/test/app/app.component.html b/test/app/app.component.html index 057de3d..16c13a9 100644 --- a/test/app/app.component.html +++ b/test/app/app.component.html @@ -25,5 +25,5 @@ testing
-
click
+
click
\ No newline at end of file diff --git a/test/tsconfig.json b/test/tsconfig.json index 566db6f..810953a 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -18,8 +18,8 @@ ] }, "typeRoots": [ - "./node_modules/@types", - "./node_modules" + "../node_modules/@types", + "../node_modules" ], "types": [ "node" @@ -28,11 +28,11 @@ "." ], "exclude": [ - "node_modules", - "dist", - "dist-tsc", - "example", - "example-cli" + "../node_modules", + "../dist", + "../dist-tsc", + "../example", + "../example-cli" ], "angularCompilerOptions": { "preserveWhiteSpace": false diff --git a/test/webpack.test.config.js b/test/webpack.config.js similarity index 81% rename from test/webpack.test.config.js rename to test/webpack.config.js index 03b94b0..ae2de96 100644 --- a/test/webpack.test.config.js +++ b/test/webpack.config.js @@ -21,7 +21,7 @@ module.exports = { rules: [ { test: /\.ts?$/, - use: ['awesome-typescript-loader', 'angular2-template-loader'], + use: ['awesome-typescript-loader?configFileName="./tsconfig.json"', 'angular2-template-loader'], exclude: ['node_modules', /__tests__/, 'example', 'dist', 'dist_tsc'] }, { @@ -33,15 +33,9 @@ module.exports = { }, plugins: [ new CheckerPlugin(), - new AngularCompilerPlugin({ - tsConfigPath: './test/tsconfig.json', - entryModule: 'test/app/app.module#AppModule', - sourceMap: true - }), - new HtmlWebpackPlugin({ inject: true, - template: 'test/index.html' + template: './test/index.html' }), new ProgressBarPlugin({ format: ' build [' + chalk.blue.bold(':bar') + ']' + chalk.green.bold(':percent') + ' (:elapsed seconds) => :msg... ', @@ -49,12 +43,12 @@ module.exports = { }), new OpenBrowserPlugin({ url: `http://localhost:8888` - }), - new webpack.HotModuleReplacementPlugin() + }) + ], devServer: { // https: true, - hot: true, + //hot: true, stats: 'errors-only', port: 8888, inline: true, diff --git a/tsconfig.json b/tsconfig.json index bfee88d..c12f719 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,7 +26,7 @@ "node" ], "include": [ - "example" + "src" ], "exclude": [ "node_modules", diff --git a/webpack.test.config.js b/webpack.test.config.js deleted file mode 100644 index 8a013ce..0000000 --- a/webpack.test.config.js +++ /dev/null @@ -1,67 +0,0 @@ -const path = require('path'); -const {CheckerPlugin} = require('awesome-typescript-loader'); -const webpack = require('webpack'); -const OpenBrowserPlugin = require('open-browser-webpack-plugin'); -const chalk = require('chalk'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const ProgressBarPlugin = require('progress-bar-webpack-plugin'); -const AngularCompilerPlugin = require('@ngtools/webpack').AngularCompilerPlugin; -const WebpackShellPlugin = require('webpack-shell-plugin'); - -module.exports = { - entry: './test/app/index.ts', - output: { - filename: '[name].js', - path: path.resolve(__dirname, 'test_dist') - }, - resolve: { - extensions: ['.ts', '.tsx', '.js', '.jsx', '.html', '.css'] - }, - devtool: 'source-map', - module: { - rules: [ - { - test: /\.ts?$/, - use: ['awesome-typescript-loader', 'angular2-template-loader'], - exclude: ['node_modules', /__tests__/] - }, - { - test: /\.(html|css)$/, - use: 'raw-loader', - exclude: ['node_modules', /__tests__/] - } - ] - }, - plugins: [ - new CheckerPlugin(), - new AngularCompilerPlugin({ - tsConfigPath: './tsconfig.json', - entryModule: 'test/app/app.module#AppModule', - sourceMap: true - }), - - new HtmlWebpackPlugin({ - inject: true, - template: 'test/index.html' - }), - new ProgressBarPlugin({ - format: ' build [' + chalk.blue.bold(':bar') + ']' + chalk.green.bold(':percent') + ' (:elapsed seconds) => :msg... ', - clear: false - }), - new OpenBrowserPlugin({ - url: `http://localhost:8888` - }), - new webpack.HotModuleReplacementPlugin() - ], - devServer: { - // https: true, - hot: true, - stats: 'errors-only', - port: 8888, - inline: true, - historyApiFallback: { - index: './test/' - }, - open: false - } -}; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index e0f8c03..a251ddd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5070,9 +5070,9 @@ negotiator@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" -ng-packagr@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/ng-packagr/-/ng-packagr-3.0.1.tgz#16f8c108d06f8dfcfb6c90c250c7b8a46889468c" +ng-packagr@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/ng-packagr/-/ng-packagr-3.0.3.tgz#389d72ddc76fd67bb8e8965852d2025b76efa048" dependencies: "@ngtools/json-schema" "^1.1.0" autoprefixer "^8.0.0" @@ -5701,10 +5701,6 @@ pn@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb" -popper.js@^1.14.3: - version "1.14.3" - resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.14.3.tgz#1438f98d046acf7b4d78cd502bf418ac64d4f095" - portfinder@^1.0.13, portfinder@^1.0.9, portfinder@~1.0.12: version "1.0.13" resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.13.tgz#bb32ecd87c27104ae6ee44b5a3ccbf0ebb1aede9"