From 2aaa8f11d6436968f3c338298f102dcd78adadc4 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Mon, 19 Dec 2016 22:40:48 -0800 Subject: [PATCH 1/3] test(filter): enable type inference in marble diagram - relates to #1633 --- spec/operators/filter-spec.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/operators/filter-spec.ts b/spec/operators/filter-spec.ts index bb3ec60f1a..4c95609d7f 100644 --- a/spec/operators/filter-spec.ts +++ b/spec/operators/filter-spec.ts @@ -1,6 +1,12 @@ import {expect} from 'chai'; import * as Rx from '../../dist/cjs/Rx'; -declare const {hot, cold, asDiagram, expectObservable, expectSubscriptions}; +import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports + +declare const { asDiagram }; +declare const hot: typeof marbleTestingSignature.hot; +declare const cold: typeof marbleTestingSignature.cold; +declare const expectObservable: typeof marbleTestingSignature.expectObservable; +declare const expectSubscriptions: typeof marbleTestingSignature.expectSubscriptions; const Observable = Rx.Observable; From 716377dc720cdb197afe1a7b08d9a666e8d07039 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Sat, 4 Feb 2017 13:51:12 -0800 Subject: [PATCH 2/3] chore(danger): setup initial dangerfile --- .travis.yml | 3 ++- dangerfile.js | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 dangerfile.js diff --git a/.travis.yml b/.travis.yml index e44d168e4c..9ac8e7725f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ cache: env: matrix: - NODE_VER=4 FULL_VALIDATE=false - - NODE_VER=6 FULL_VALIDATE=true alias grunt=./node_modules/grunt-cli/bin/grunt + - NODE_VER=6 FULL_VALIDATE=true alias grunt=./node_modules/grunt-cli/bin/grunt danger=./node_modules/danger/distribution/danger - NODE_VER=7 FULL_VALIDATE=false matrix: fast_finish: true @@ -23,6 +23,7 @@ before_install: - nvm install $NODE_VER - npm install -g npm@4 && node -v && npm -v - if [ "$FULL_VALIDATE" == "true" ]; then npm install grunt@0.4.1 grunt-cli grunt-contrib-connect grunt-run; fi + - if [ "$FULL_VALIDATE" == "true" ] && [ -n "DANGER_GITHUB_API_TOKEN" ]; then npm install danger && danger; fi install: - npm install diff --git a/dangerfile.js b/dangerfile.js new file mode 100644 index 0000000000..5c0335b334 --- /dev/null +++ b/dangerfile.js @@ -0,0 +1,56 @@ +var fs = require('fs'); +var path = require('path'); +var _ = require('lodash'); + +//simple regex matcher to detect usage of helper function and its type signature +var hotMatch = /\bhot\(/gi; +var hotSignatureMatch = /\bdeclare const hot: typeof/gi; + +var coldMatch = /\bcold\(/gi; +var coldSignatureMatch = /\bdeclare const cold: typeof/gi; + +var errorCount = 0; + +// Warn when PR size is large +var bigPRThreshold = 600; +if (danger.github.pr.additions + danger.github.pr.deletions > bigPRThreshold) { + warn(':exclamation: Big PR (' + ++errorCount + ')'); + markdown('> (' + errorCount + ') : Pull Request size seems relatively large. If Pull Request contains multiple changes, split each into separate PR will helps faster, easier review.'); +} + +// Check test exclusion (.only) is included +var modifiedSpecFiles = danger.git.modified_files.filter(function (filePath) { + return filePath.match(/-spec.(js|jsx|ts|tsx)$/gi); +}); + +var testFilesIncludeExclusion = modifiedSpecFiles.reduce(function (acc, value) { + var content = fs.readFileSync(value).toString(); + var invalid = _.includes(content, 'it.only') || _.includes(content, 'describe.only'); + if (invalid) { + acc.push(path.basename(value)); + } + return acc; +}, []); + +if (testFilesIncludeExclusion.length > 0) { + fail('an \`only\` was left in tests (' + testFilesIncludeExclusion + ')'); +} + +// Check test cases missing type signature import for test marble helper functions +var testFilesMissingTypes = modifiedSpecFiles.reduce(function (acc, value) { + var content = fs.readFileSync(value).toString(); + + var hotFnMatches = content.match(hotMatch) && content.match(hotSignatureMatch); + var coldFnMatches = content.match(coldMatch) && content.match(coldSignatureMatch); + + if (!hotFnMatches || !coldFnMatches) { + acc.push(path.basename(value)); + } + + return acc; +}, []); + +if (testFilesMissingTypes.length > 0) { + fail('missing type definition import in tests (' + testFilesMissingTypes + ') (' + ++errorCount + ')'); + markdown('> (' + errorCount + ') : It seems updated test cases uses test scheduler interface `hot`, `cold` but miss to import type signature for those.'); +} \ No newline at end of file From 4e3514e40a34d17612e2ed0b1a73a89dd6cd9f84 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Sat, 4 Feb 2017 14:45:18 -0800 Subject: [PATCH 3/3] chore(dummy): dummy commit --- spec/operators/sample-spec.ts | 2 +- spec/operators/scan-spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/operators/sample-spec.ts b/spec/operators/sample-spec.ts index 275c4eb034..7cb34c4517 100644 --- a/spec/operators/sample-spec.ts +++ b/spec/operators/sample-spec.ts @@ -6,7 +6,7 @@ declare const {hot, asDiagram, expectObservable, expectSubscriptions}; const Observable = Rx.Observable; /** @test {sample} */ -describe('Observable.prototype.sample', () => { +describe.only('Observable.prototype.sample', () => { asDiagram('sample')('should get samples when the notifier emits', () => { const e1 = hot('---a----b---c----------d-----| '); const e1subs = '^ ! '; diff --git a/spec/operators/scan-spec.ts b/spec/operators/scan-spec.ts index ed2fc37945..da6f4de2aa 100644 --- a/spec/operators/scan-spec.ts +++ b/spec/operators/scan-spec.ts @@ -63,7 +63,7 @@ describe('Observable.prototype.scan', () => { expectSubscriptions(e1.subscriptions).toBe(e1subs); }); - it('should scan without seed', () => { + it.only('should scan without seed', () => { const e1 = hot('--a--^--b--c--d--|'); const e1subs = '^ !'; const expected = '---x--y--z--|';