Skip to content

Commit

Permalink
test(ALL): migrate test cases into mocha-chai assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Mar 29, 2016
1 parent 25d20b3 commit a1687c3
Show file tree
Hide file tree
Showing 106 changed files with 2,527 additions and 2,439 deletions.
77 changes: 39 additions & 38 deletions spec/Notification-spec.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
import {expect} from 'chai';
import * as Rx from '../dist/cjs/Rx';
declare const expectObservable;

declare const expectObservable;
const Notification = Rx.Notification;

/** @test {Notification} */
describe('Notification', () => {
it('should exist', () => {
expect(Notification).toBeDefined();
expect(typeof Notification).toBe('function');
expect(Notification).exist;
expect(Notification).to.be.a('function');
});

describe('createNext', () => {
it('should return a Notification', () => {
const n = Notification.createNext('test');
expect(n instanceof Notification).toBe(true);
expect(n.value).toBe('test');
expect(n.kind).toBe('N');
expect(typeof n.exception).toBe('undefined');
expect(n.hasValue).toBe(true);
expect(n instanceof Notification).to.be.true;
expect(n.value).to.equal('test');
expect(n.kind).to.equal('N');
expect(n.exception).to.be.a('undefined');
expect(n.hasValue).to.be.true;
});
});

describe('createError', () => {
it('should return a Notification', () => {
const n = Notification.createError('test');
expect(n instanceof Notification).toBe(true);
expect(typeof n.value).toBe('undefined');
expect(n.kind).toBe('E');
expect(n.exception).toBe('test');
expect(n.hasValue).toBe(false);
expect(n instanceof Notification).to.be.true;
expect(n.value).to.be.a('undefined');
expect(n.kind).to.equal('E');
expect(n.exception).to.equal('test');
expect(n.hasValue).to.be.false;
});
});

describe('createComplete', () => {
it('should return a Notification', () => {
const n = Notification.createComplete();
expect(n instanceof Notification).toBe(true);
expect(typeof n.value).toBe('undefined');
expect(n.kind).toBe('C');
expect(typeof n.exception).toBe('undefined');
expect(n.hasValue).toBe(false);
expect(n instanceof Notification).to.be.true;
expect(n.value).to.be.a('undefined');
expect(n.kind).to.equal('C');
expect(n.exception).to.be.a('undefined');
expect(n.hasValue).to.be.false;
});
});

Expand Down Expand Up @@ -67,28 +68,28 @@ describe('Notification', () => {
const first = Notification.createNext(value);
const second = Notification.createNext(value);

expect(first).not.toBe(second);
expect(first).not.to.equal(second);
});

it('should create new error Notification', () => {
const first = Notification.createError();
const second = Notification.createError();

expect(first).not.toBe(second);
expect(first).not.to.equal(second);
});

it('should return static next Notification reference without value', () => {
const first = Notification.createNext(undefined);
const second = Notification.createNext(undefined);

expect(first).toBe(second);
expect(first).to.equal(second);
});

it('should return static complete Notification reference', () => {
const first = Notification.createComplete();
const second = Notification.createComplete();

expect(first).toBe(second);
expect(first).to.equal(second);
});
});

Expand All @@ -104,7 +105,7 @@ describe('Notification', () => {
throw 'should not be called';
});

expect(invoked).toBe(true);
expect(invoked).to.be.true;
});

it('should invoke on error', () => {
Expand All @@ -118,7 +119,7 @@ describe('Notification', () => {
throw 'should not be called';
});

expect(invoked).toBe(true);
expect(invoked).to.be.true;
});

it('should invoke on complete', () => {
Expand All @@ -132,7 +133,7 @@ describe('Notification', () => {
invoked = true;
});

expect(invoked).toBe(true);
expect(invoked).to.be.true;
});
});

Expand All @@ -142,7 +143,7 @@ describe('Notification', () => {
let observed = false;
const n = Notification.createNext(value);
const observer = Rx.Subscriber.create((x: string) => {
expect(x).toBe(value);
expect(x).to.equal(value);
observed = true;
}, (err: any) => {
throw 'should not be called';
Expand All @@ -151,7 +152,7 @@ describe('Notification', () => {
});

n.accept(observer);
expect(observed).toBe(true);
expect(observed).to.be.true;
});

it('should accept observer for error Notification', () => {
Expand All @@ -166,7 +167,7 @@ describe('Notification', () => {
});

n.accept(observer);
expect(observed).toBe(true);
expect(observed).to.be.true;
});

it('should accept observer for complete Notification', () => {
Expand All @@ -181,7 +182,7 @@ describe('Notification', () => {
});

n.accept(observer);
expect(observed).toBe(true);
expect(observed).to.be.true;
});

it('should accept function for next Notification', () => {
Expand All @@ -190,14 +191,14 @@ describe('Notification', () => {
const n = Notification.createNext(value);

n.accept((x: string) => {
expect(x).toBe(value);
expect(x).to.equal(value);
observed = true;
}, (err: any) => {
throw 'should not be called';
}, () => {
throw 'should not be called';
});
expect(observed).toBe(true);
expect(observed).to.be.true;
});

it('should accept function for error Notification', () => {
Expand All @@ -208,12 +209,12 @@ describe('Notification', () => {
n.accept((x: any) => {
throw 'should not be called';
}, (err: any) => {
expect(err).toBe(error);
expect(err).to.equal(error);
observed = true;
}, () => {
throw 'should not be called';
});
expect(observed).toBe(true);
expect(observed).to.be.true;
});

it('should accept function for complete Notification', () => {
Expand All @@ -227,7 +228,7 @@ describe('Notification', () => {
}, () => {
observed = true;
});
expect(observed).toBe(true);
expect(observed).to.be.true;
});
});

Expand All @@ -237,7 +238,7 @@ describe('Notification', () => {
let observed = false;
const n = Notification.createNext(value);
const observer = Rx.Subscriber.create((x: string) => {
expect(x).toBe(value);
expect(x).to.equal(value);
observed = true;
}, (err: any) => {
throw 'should not be called';
Expand All @@ -246,7 +247,7 @@ describe('Notification', () => {
});

n.observe(observer);
expect(observed).toBe(true);
expect(observed).to.be.true;
});

it('should observe for error Notification', () => {
Expand All @@ -261,7 +262,7 @@ describe('Notification', () => {
});

n.observe(observer);
expect(observed).toBe(true);
expect(observed).to.be.true;
});

it('should observe for complete Notification', () => {
Expand All @@ -276,7 +277,7 @@ describe('Notification', () => {
});

n.observe(observer);
expect(observed).toBe(true);
expect(observed).to.be.true;
});
});
});
Loading

0 comments on commit a1687c3

Please sign in to comment.