Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 [email protected] 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
Expand Down
56 changes: 56 additions & 0 deletions dangerfile.js
Original file line number Diff line number Diff line change
@@ -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.');
}
8 changes: 7 additions & 1 deletion spec/operators/filter-spec.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion spec/operators/sample-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '^ ! ';
Expand Down
2 changes: 1 addition & 1 deletion spec/operators/scan-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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--|';
Expand Down