ngx-print 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +13 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +31 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.nvmrc +1 -0
- package/.travis.yml +40 -0
- package/CHANGELOG.md +10 -0
- package/README.md +23 -0
- package/_config.yml +1 -0
- package/angular.json +48 -0
- package/karma.conf.js +47 -0
- package/ng-package.json +8 -0
- package/package.json +47 -71
- package/src/lib/ngx-print.directive.spec.ts +112 -0
- package/src/lib/ngx-print.directive.ts +193 -0
- package/src/lib/ngx-print.module.ts +10 -0
- package/{public_api.d.ts → src/public_api.ts} +4 -0
- package/tsconfig.json +29 -0
- package/tsconfig.lib.json +14 -0
- package/tsconfig.spec.json +17 -0
- package/tslint.json +17 -0
- package/bundles/ngx-print.umd.js +0 -349
- package/bundles/ngx-print.umd.js.map +0 -1
- package/bundles/ngx-print.umd.min.js +0 -2
- package/bundles/ngx-print.umd.min.js.map +0 -1
- package/esm2015/lib/ngx-print.directive.js +0 -247
- package/esm2015/lib/ngx-print.module.js +0 -16
- package/esm2015/ngx-print.js +0 -9
- package/esm2015/public_api.js +0 -10
- package/esm5/lib/ngx-print.directive.js +0 -321
- package/esm5/lib/ngx-print.module.js +0 -20
- package/esm5/ngx-print.js +0 -9
- package/esm5/public_api.js +0 -10
- package/fesm2015/ngx-print.js +0 -233
- package/fesm2015/ngx-print.js.map +0 -1
- package/fesm5/ngx-print.js +0 -309
- package/fesm5/ngx-print.js.map +0 -1
- package/lib/ngx-print.directive.d.ts +0 -85
- package/lib/ngx-print.module.d.ts +0 -2
- package/ngx-print.d.ts +0 -4
- package/ngx-print.metadata.json +0 -1
package/.editorconfig
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Editor configuration, see https://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
indent_style = space
|
|
7
|
+
indent_size = 2
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
|
|
11
|
+
[*.md]
|
|
12
|
+
max_line_length = off
|
|
13
|
+
trim_trailing_whitespace = false
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the behavior.
|
|
15
|
+
|
|
16
|
+
**Expected behavior**
|
|
17
|
+
A clear and concise description of what you expected to happen.
|
|
18
|
+
|
|
19
|
+
**Screenshots**
|
|
20
|
+
If applicable, add screenshots to help explain your problem.
|
|
21
|
+
|
|
22
|
+
**Ngx-Print Version**
|
|
23
|
+
Include the current affected version.
|
|
24
|
+
|
|
25
|
+
**Desktop (please complete the following information):**
|
|
26
|
+
- OS: [e.g. iOS]
|
|
27
|
+
- Browser [e.g. chrome, safari]
|
|
28
|
+
- Version [e.g. 22]
|
|
29
|
+
|
|
30
|
+
**Additional context**
|
|
31
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
+
|
|
13
|
+
**Describe the solution you'd like**
|
|
14
|
+
A clear and concise description of what you want to happen.
|
|
15
|
+
|
|
16
|
+
**Describe alternatives you've considered**
|
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
+
|
|
19
|
+
**Additional context**
|
|
20
|
+
Add any other context or screenshots about the feature request here.
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
10.14.2
|
package/.travis.yml
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
language: node_js
|
|
2
|
+
sudo: false
|
|
3
|
+
dist: trusty
|
|
4
|
+
node_js:
|
|
5
|
+
- '10.14.2'
|
|
6
|
+
|
|
7
|
+
addons:
|
|
8
|
+
packages:
|
|
9
|
+
- unzip
|
|
10
|
+
- google-chrome-stable
|
|
11
|
+
|
|
12
|
+
cache:
|
|
13
|
+
yarn: true
|
|
14
|
+
directories:
|
|
15
|
+
- node_modules
|
|
16
|
+
|
|
17
|
+
before_install:
|
|
18
|
+
- sudo apt-get clean
|
|
19
|
+
- sudo apt-get update
|
|
20
|
+
- sudo apt-get install dpkg
|
|
21
|
+
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
22
|
+
- sudo dpkg -i google-chrome*.deb
|
|
23
|
+
- export CHROME_BIN=/usr/bin/google-chrome
|
|
24
|
+
- export DISPLAY=:99.0
|
|
25
|
+
- sh -e /etc/init.d/xvfb start
|
|
26
|
+
|
|
27
|
+
before_script:
|
|
28
|
+
- yarn install
|
|
29
|
+
|
|
30
|
+
after_failure:
|
|
31
|
+
- cat /home/travis/build/selemxmn/ngx-print/yarn-error.log
|
|
32
|
+
|
|
33
|
+
after_success:
|
|
34
|
+
- cat ./dist/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
|
|
35
|
+
|
|
36
|
+
notifications:
|
|
37
|
+
email: false
|
|
38
|
+
|
|
39
|
+
script:
|
|
40
|
+
- yarn run test && yarn run build
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# 1.3.0 (2022-12-20)
|
|
2
|
+
### New features
|
|
3
|
+
* Supports previewOnly tag, allowing for the print preview to show without the print dialog
|
|
4
|
+
### Dependency Updates
|
|
5
|
+
* Angular Ivy support with Angular 15
|
|
6
|
+
|
|
7
|
+
# 1.1.0 (2018-12-04)
|
|
8
|
+
### New features
|
|
9
|
+
* Support styles (CSS) ([#5](https://github.com/selemxmn/ngx-print/issues/5)) ([71cefdf](https://github.com/selemxmn/ngx-print/commit/71cefdf))
|
|
10
|
+
* Permit a dynamic title of printing window instead of the old static `Print tab` ([2098f3e](https://github.com/selemxmn/ngx-print/commit/2098f3e))
|
package/README.md
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
# ngx-print : *plug n' play Angular (2++) directive to print your stuff*
|
|
4
4
|
This directive makes printing your HTML sections smooth and easy in your Angular application. It is inspired from the old [AngularJS ngPrint](https://github.com/gilf/ngPrint) directive, thus it is intendend to be used with the new Angular -2/4/5/6/7-... ***Enjoy ! contributions are so welcomed :)***
|
|
5
5
|
|
|
6
|
+
## Dependencies
|
|
7
|
+
| ngx-print | Angular |
|
|
8
|
+
| ------------ | ------------ |
|
|
9
|
+
| 1.2.1 | 7.0.0 - 14.1.0 |
|
|
10
|
+
| 1.3.x | 15.0.0 |
|
|
6
11
|
## Setup
|
|
7
12
|
|
|
8
13
|
**1-** In your root application folder run:
|
|
@@ -127,6 +132,24 @@ Here some simple styles were added to every `h1` & `h2` tags within the `div` wh
|
|
|
127
132
|
printSectionId="print-section"
|
|
128
133
|
ngxPrint>print</button>
|
|
129
134
|
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
- If you would like to show a preview without a print dialog use
|
|
138
|
+
`previewOnly`:
|
|
139
|
+
|
|
140
|
+
```html
|
|
141
|
+
|
|
142
|
+
<div id="print-section">
|
|
143
|
+
|
|
144
|
+
<!-- ... -->
|
|
145
|
+
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<button
|
|
149
|
+
[previewOnly]="true"
|
|
150
|
+
printSectionId="print-section"
|
|
151
|
+
ngxPrint>print</button>
|
|
152
|
+
|
|
130
153
|
```
|
|
131
154
|
## Contributors :1st_place_medal:
|
|
132
155
|
|
package/_config.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
theme: jekyll-theme-cayman
|
package/angular.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"newProjectRoot": "projects",
|
|
5
|
+
"projects": {
|
|
6
|
+
"ngx-print": {
|
|
7
|
+
"root": "",
|
|
8
|
+
"sourceRoot": "src",
|
|
9
|
+
"projectType": "library",
|
|
10
|
+
"prefix": "lib",
|
|
11
|
+
"architect": {
|
|
12
|
+
"build": {
|
|
13
|
+
"builder": "@angular-devkit/build-angular:ng-packagr",
|
|
14
|
+
"options": {
|
|
15
|
+
"tsConfig": "tsconfig.lib.json",
|
|
16
|
+
"project": "ng-package.json"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"test": {
|
|
20
|
+
"builder": "@angular-devkit/build-angular:karma",
|
|
21
|
+
"options": {
|
|
22
|
+
"polyfills": [
|
|
23
|
+
"zone.js",
|
|
24
|
+
"zone.js/testing"
|
|
25
|
+
],
|
|
26
|
+
"tsConfig": "tsconfig.spec.json",
|
|
27
|
+
"karmaConfig": "karma.conf.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"lint": {
|
|
31
|
+
"builder": "@angular-devkit/build-angular:tslint",
|
|
32
|
+
"options": {
|
|
33
|
+
"tsConfig": [
|
|
34
|
+
"tsconfig.lib.json",
|
|
35
|
+
"tsconfig.spec.json"
|
|
36
|
+
],
|
|
37
|
+
"exclude": [
|
|
38
|
+
"**/node_modules/**"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"cli": {
|
|
46
|
+
"analytics": false
|
|
47
|
+
}
|
|
48
|
+
}
|
package/karma.conf.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Karma configuration file, see link for more information
|
|
2
|
+
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
|
3
|
+
|
|
4
|
+
module.exports = function (config) {
|
|
5
|
+
config.set({
|
|
6
|
+
basePath: '',
|
|
7
|
+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
|
8
|
+
plugins: [
|
|
9
|
+
require('karma-jasmine'),
|
|
10
|
+
require('karma-chrome-launcher'),
|
|
11
|
+
require('karma-jasmine-html-reporter'),
|
|
12
|
+
require('karma-coverage'),
|
|
13
|
+
require('@angular-devkit/build-angular/plugins/karma')
|
|
14
|
+
],
|
|
15
|
+
client: {
|
|
16
|
+
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
17
|
+
},
|
|
18
|
+
ccoverageReporter: {
|
|
19
|
+
dir: require('path').join(__dirname, './coverage/<project-name>'),
|
|
20
|
+
subdir: '.',
|
|
21
|
+
reporters: [
|
|
22
|
+
{ type: 'html' },
|
|
23
|
+
{ type: 'text-summary' }
|
|
24
|
+
],
|
|
25
|
+
check: {
|
|
26
|
+
global: {
|
|
27
|
+
statements: 80,
|
|
28
|
+
branches: 80,
|
|
29
|
+
functions: 80,
|
|
30
|
+
lines: 80
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
port: 9876,
|
|
35
|
+
colors: true,
|
|
36
|
+
logLevel: config.LOG_INFO,
|
|
37
|
+
autoWatch: true,
|
|
38
|
+
browsers: ['Chrome'],
|
|
39
|
+
customLaunchers: {
|
|
40
|
+
ChromeHeadlessCI: {
|
|
41
|
+
base: 'ChromeHeadless',
|
|
42
|
+
flags: ['--no-sandbox']
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
singleRun: true
|
|
46
|
+
});
|
|
47
|
+
};
|
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,71 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ngx-print",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Plug n' Play Angular (2++) directive to print your stuff",
|
|
5
|
-
"author": "https://github.com/selemxmn/ngx-print/graphs/contributors",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/selemxmn/ngx-print.git"
|
|
9
|
-
},
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/selemxmn/ngx-print/issues"
|
|
13
|
-
},
|
|
14
|
-
"homepage": "https://github.com/selemxmn/ngx-print#readme",
|
|
15
|
-
"keywords": [
|
|
16
|
-
"print",
|
|
17
|
-
"angular",
|
|
18
|
-
"library",
|
|
19
|
-
"ng-print",
|
|
20
|
-
"ngx-print",
|
|
21
|
-
"directive",
|
|
22
|
-
"dependency",
|
|
23
|
-
"angular-print"
|
|
24
|
-
],
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"@angular/
|
|
35
|
-
"@angular/
|
|
36
|
-
"@angular/
|
|
37
|
-
"@
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"jasmine
|
|
43
|
-
"jasmine-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"karma-jasmine-html-reporter": "^1.4.0",
|
|
49
|
-
"ng-packagr": "^4.4.0",
|
|
50
|
-
"nyc": "^14.1.1",
|
|
51
|
-
"rxjs": "^6.3.3",
|
|
52
|
-
"ts-node": "^7.0.1",
|
|
53
|
-
"tsickle": "^0.34.0",
|
|
54
|
-
"typescript": "3.2.4",
|
|
55
|
-
"zone.js": "^0.8.26"
|
|
56
|
-
},
|
|
57
|
-
"peerDependencies": {
|
|
58
|
-
"@angular/common": "*",
|
|
59
|
-
"@angular/core": "*"
|
|
60
|
-
},
|
|
61
|
-
"main": "bundles/ngx-print.umd.js",
|
|
62
|
-
"module": "fesm5/ngx-print.js",
|
|
63
|
-
"es2015": "fesm2015/ngx-print.js",
|
|
64
|
-
"esm5": "esm5/ngx-print.js",
|
|
65
|
-
"esm2015": "esm2015/ngx-print.js",
|
|
66
|
-
"fesm5": "fesm5/ngx-print.js",
|
|
67
|
-
"fesm2015": "fesm2015/ngx-print.js",
|
|
68
|
-
"typings": "ngx-print.d.ts",
|
|
69
|
-
"metadata": "ngx-print.metadata.json",
|
|
70
|
-
"sideEffects": false
|
|
71
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ngx-print",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Plug n' Play Angular (2++) directive to print your stuff",
|
|
5
|
+
"author": "https://github.com/selemxmn/ngx-print/graphs/contributors",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/selemxmn/ngx-print.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/selemxmn/ngx-print/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/selemxmn/ngx-print#readme",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"print",
|
|
17
|
+
"angular",
|
|
18
|
+
"library",
|
|
19
|
+
"ng-print",
|
|
20
|
+
"ngx-print",
|
|
21
|
+
"directive",
|
|
22
|
+
"dependency",
|
|
23
|
+
"angular-print"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"ng": "ng",
|
|
27
|
+
"build": "ng build",
|
|
28
|
+
"test": "ng test --no-watch --code-coverage --no-progress --browsers=ChromeHeadlessCI"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"tslib": "^2.3.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@angular-devkit/build-angular": "^15.0.4",
|
|
35
|
+
"@angular/cli": "~15.0.4",
|
|
36
|
+
"@angular/compiler-cli": "^15.0.0",
|
|
37
|
+
"@types/jasmine": "~4.3.0",
|
|
38
|
+
"jasmine-core": "~4.5.0",
|
|
39
|
+
"karma": "~6.4.0",
|
|
40
|
+
"karma-chrome-launcher": "~3.1.0",
|
|
41
|
+
"karma-coverage": "~2.2.0",
|
|
42
|
+
"karma-jasmine": "~5.1.0",
|
|
43
|
+
"karma-jasmine-html-reporter": "~2.0.0",
|
|
44
|
+
"ng-packagr": "^15.0.0",
|
|
45
|
+
"typescript": "~4.8.2"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {Component, DebugElement} from "@angular/core";
|
|
2
|
+
import {TestBed, ComponentFixture} from '@angular/core/testing';
|
|
3
|
+
import {By} from "@angular/platform-browser";
|
|
4
|
+
|
|
5
|
+
import { NgxPrintDirective } from './ngx-print.directive';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
template: `
|
|
9
|
+
<div id="print-section">
|
|
10
|
+
<h1>
|
|
11
|
+
Welcome to ngx-print
|
|
12
|
+
</h1>
|
|
13
|
+
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
|
|
14
|
+
<h2>Here are some links to help you start: </h2>
|
|
15
|
+
<ul >
|
|
16
|
+
<li>
|
|
17
|
+
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
|
|
18
|
+
</li>
|
|
19
|
+
<li>
|
|
20
|
+
<h2><a target="_blank" rel="noopener" href="https://github.com/angular/angular-cli/wiki">CLI Documentation</a></h2>
|
|
21
|
+
</li>
|
|
22
|
+
<li>
|
|
23
|
+
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
|
|
24
|
+
</li>
|
|
25
|
+
</ul>
|
|
26
|
+
<table border = "1">
|
|
27
|
+
<tr>
|
|
28
|
+
<td>Row 1, Column 1</td>
|
|
29
|
+
<td>Row 1, Column 2</td>
|
|
30
|
+
</tr>
|
|
31
|
+
<tr>
|
|
32
|
+
<td>Row 2, Column 1</td>
|
|
33
|
+
<td>Row 2, Column 2</td>
|
|
34
|
+
</tr>
|
|
35
|
+
</table>
|
|
36
|
+
</div>
|
|
37
|
+
<button printSectionId="print-section" ngxPrint></button>
|
|
38
|
+
`
|
|
39
|
+
})
|
|
40
|
+
class TestNgxPrintComponent {
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe('NgxPrintDirective', () => {
|
|
44
|
+
|
|
45
|
+
let buttonEl: DebugElement;
|
|
46
|
+
let component: TestNgxPrintComponent;
|
|
47
|
+
let fixture: ComponentFixture<TestNgxPrintComponent>;
|
|
48
|
+
|
|
49
|
+
// To change this later, so it'll depend on TestNgxPrintComponent
|
|
50
|
+
let styleSheet: {[key: string]: {[key: string]: string}}
|
|
51
|
+
= {
|
|
52
|
+
'h2' : {'border': 'solid 1px'},
|
|
53
|
+
'h1' : {'color': 'red', 'border': '1px solid'}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
beforeEach(() => {
|
|
57
|
+
|
|
58
|
+
// Configure a NgModule-like decorator metadata
|
|
59
|
+
TestBed.configureTestingModule({
|
|
60
|
+
declarations: [TestNgxPrintComponent, NgxPrintDirective]
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Create a fixture object (that is going to allows us to create an instance of that component)
|
|
64
|
+
fixture = TestBed.createComponent(TestNgxPrintComponent);
|
|
65
|
+
|
|
66
|
+
// Create a component instance ( ~ new Component)
|
|
67
|
+
component = fixture.componentInstance;
|
|
68
|
+
|
|
69
|
+
// Get the button element (on which we tag the directive) to simulate clicks on it
|
|
70
|
+
buttonEl = fixture.debugElement.query(By.directive(NgxPrintDirective));
|
|
71
|
+
|
|
72
|
+
fixture.detectChanges();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should create an instance', () => {
|
|
76
|
+
const directive = new NgxPrintDirective();
|
|
77
|
+
expect(directive).toBeTruthy();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// it('should test the @Input printStyle', () => {
|
|
81
|
+
// const directive = new NgxPrintDirective();
|
|
82
|
+
// directive.printStyle = styleSheet;
|
|
83
|
+
// for (var key in directive.printStyle) {
|
|
84
|
+
// if (directive.printStyle.hasOwnProperty(key)) {
|
|
85
|
+
// directive._printStyle.push((key + JSON.stringify(directive.printStyle[key])).replace(/['"]+/g, ''));
|
|
86
|
+
// }
|
|
87
|
+
// }
|
|
88
|
+
// directive.returnStyleValues();
|
|
89
|
+
|
|
90
|
+
// expect(directive.returnStyleValues).toHaveBeenCalled();
|
|
91
|
+
// });
|
|
92
|
+
|
|
93
|
+
// it('should returns a string from array of objects', () => {
|
|
94
|
+
// const directive = new NgxPrintDirective();
|
|
95
|
+
// directive._printStyle = [
|
|
96
|
+
// "h2{border:solid 1px}",
|
|
97
|
+
// "h1{color:red,border:1px solid}"
|
|
98
|
+
// ];
|
|
99
|
+
// // let returnedString = directive.returnStyleValues();
|
|
100
|
+
|
|
101
|
+
// // immediately invoked arrow function, else you can uncomment `returnedString` and use it instead
|
|
102
|
+
// expect((() => {return directive.returnStyleValues()})()).toEqual('h2{border:solid 1px} h1{color:red,border:1px solid}');
|
|
103
|
+
// });
|
|
104
|
+
|
|
105
|
+
it(`should popup a new window`, ()=> {
|
|
106
|
+
spyOn(window, 'open');
|
|
107
|
+
// simulate click
|
|
108
|
+
buttonEl.triggerEventHandler('click', {});
|
|
109
|
+
expect(window.open).toHaveBeenCalled();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
});
|