From 8edc720c07ed830f8409143c8cc9cf04f8623f2b Mon Sep 17 00:00:00 2001 From: dreambo8563 Date: Thu, 21 Mar 2019 15:10:51 +0800 Subject: [PATCH 1/3] test(add test): base class --- jest.config.js | 7 ++++++- src/main.ts | 2 +- tests/unit/main.spec.ts | 20 +++++++++++++++++++- tsconfig.json | 4 ++-- types/main.d.ts | 1 - 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/jest.config.js b/jest.config.js index b113645..17a4b95 100644 --- a/jest.config.js +++ b/jest.config.js @@ -21,5 +21,10 @@ module.exports = { testMatch: [ "**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)" ], - testURL: "http://localhost/" + testURL: "http://localhost/", + globals: { + "ts-jest": { + diagnostics: false + } + } }; diff --git a/src/main.ts b/src/main.ts index a909e92..3e5ccd5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,7 +9,7 @@ export interface ILazyBase { stream(s?: LazyCalc): LazyStream; } export class LazyBase { - constructor() {} + // constructor() {} static lazy(init: number | object = 0): LazyCalc { return new LazyCalc(init); } diff --git a/tests/unit/main.spec.ts b/tests/unit/main.spec.ts index a44c4d7..3365cba 100644 --- a/tests/unit/main.spec.ts +++ b/tests/unit/main.spec.ts @@ -1,4 +1,7 @@ -import { LazyBase } from "../../src/main"; +/// +/// +import LazyPlugin, { LazyBase } from "../../src/main"; +import Vue from "vue"; describe("base class", () => { it("lazy with init value", () => { @@ -11,4 +14,19 @@ describe("base class", () => { const stream1 = LazyBase.stream(base1).add(base2); expect(stream1.value()).toBe(5); }); + it("stream without init value", () => { + const base1 = LazyBase.lazy(1); + const base2 = LazyBase.lazy(4); + const stream1 = LazyBase.stream() + .subtract(base1) + .add(base2); + expect(stream1.value()).toBe(3); + }); + it("Vue instantce", () => { + Vue.use(LazyPlugin); + const base1 = Vue.$lzCalc.lazy(1); + const base2 = Vue.$lzCalc.lazy(4); + const stream1 = Vue.$lzCalc.stream(base1).add(base2); + expect(stream1.value()).toBe(5); + }); }); diff --git a/tsconfig.json b/tsconfig.json index 39380eb..84cb439 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,7 @@ "baseUrl": ".", "types": ["jest", "webpack-env"], "declaration": true, - // "typeRoots": ["types"], + // "typeRoots": ["types", "node_modules/@types"], "outDir": "./types", "paths": { "@/*": ["src/*"] @@ -24,7 +24,7 @@ "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue" - // "tests/**/*.ts", + // "tests/**/*.ts" // "tests/**/*.tsx" ], "exclude": ["node_modules"] diff --git a/types/main.d.ts b/types/main.d.ts index 93232f1..d48fa82 100644 --- a/types/main.d.ts +++ b/types/main.d.ts @@ -8,7 +8,6 @@ export interface ILazyBase { stream(s?: LazyCalc): LazyStream; } export declare class LazyBase { - constructor(); static lazy(init?: number | object): LazyCalc; static stream(s?: LazyCalc): LazyStream; } From d7d5d741693e3e30a7aa7692e6df7939fc25cf7a Mon Sep 17 00:00:00 2001 From: dreambo8563 Date: Thu, 21 Mar 2019 15:11:02 +0800 Subject: [PATCH 2/3] 1.1.6 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index fd53571..cf6ae66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vue-lazy-calc", - "version": "1.1.5", + "version": "1.1.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 942d85f..e19b080 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-lazy-calc", - "version": "1.1.5", + "version": "1.1.6", "private": false, "author": "dreambo8563", "main": "dist/vue-lazy-calc.umd.min.js", From 56c87ef0174c33f4d0f51ea343995b8556b5bc3c Mon Sep 17 00:00:00 2001 From: dreambo8563 Date: Thu, 21 Mar 2019 15:11:20 +0800 Subject: [PATCH 3/3] docs(1.1.6): base test --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6345bf0..70d1c4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ + +## [1.1.6](https://github.com/dreambo8563/vue-lazy-calc/compare/v1.1.5...v1.1.6) (2019-03-21) + + + ## [1.1.5](https://github.com/dreambo8563/vue-lazy-calc/compare/v1.1.4...v1.1.5) (2019-03-21)