2015-12-14 19:14:35 +03:00
|
|
|
'use strict';
|
|
|
|
|
2017-08-17 10:27:19 +03:00
|
|
|
import {KeysPipe, MarkedPipe} from '../../lib/utils/pipes';
|
2015-12-14 19:14:35 +03:00
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
describe('Pipes', () => {
|
2016-10-31 22:09:55 +03:00
|
|
|
describe('KeysPipe', () => {
|
2015-12-19 20:36:28 +03:00
|
|
|
let obj;
|
2016-10-31 22:09:55 +03:00
|
|
|
var keysPipe;
|
2015-12-19 20:36:28 +03:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
obj = {
|
|
|
|
a: 1,
|
|
|
|
b: 2,
|
|
|
|
c: 3
|
|
|
|
};
|
|
|
|
keysPipe = new KeysPipe();
|
2015-12-14 19:14:35 +03:00
|
|
|
});
|
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
describe('KeysPipe transform', () => {
|
|
|
|
it('should return keys', () => {
|
|
|
|
var val = keysPipe.transform(obj);
|
|
|
|
val.should.be.deepEqual(['a', 'b', 'c']);
|
|
|
|
});
|
2015-12-14 19:31:17 +03:00
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
it('should not support other objects', () => {
|
|
|
|
(() => keysPipe.transform(45)).should.throw();
|
|
|
|
(() => keysPipe.transform('45')).should.throw();
|
|
|
|
});
|
2015-12-14 19:14:35 +03:00
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
it('should not throw on blank input', () => {
|
|
|
|
(() => keysPipe.transform()).should.not.throw();
|
|
|
|
});
|
2015-12-14 19:14:35 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
describe('MarkedPipe', () => {
|
|
|
|
let unmarked;
|
|
|
|
let marked;
|
|
|
|
var pipe;
|
2015-12-14 19:14:35 +03:00
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
beforeEach(() => {
|
|
|
|
unmarked = 'test\n';
|
2016-01-23 17:00:38 +03:00
|
|
|
marked = '<span class="redoc-markdown-block"><p>test</p>\n</span>';
|
2015-12-19 20:36:28 +03:00
|
|
|
pipe = new MarkedPipe();
|
2015-12-14 19:14:35 +03:00
|
|
|
});
|
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
describe('MarkedPipe transform', () => {
|
2016-01-23 17:00:38 +03:00
|
|
|
it('should wrap in markdown span', () => {
|
2015-12-19 20:36:28 +03:00
|
|
|
var val = pipe.transform(unmarked);
|
|
|
|
val.should.be.equal(marked);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not support other objects', () => {
|
|
|
|
(() => pipe.transform(45)).should.throw();
|
|
|
|
(() => pipe.transform({})).should.throw();
|
|
|
|
});
|
2015-12-14 19:31:17 +03:00
|
|
|
|
2015-12-19 20:36:28 +03:00
|
|
|
it('should not throw on blank input', () => {
|
|
|
|
(() => pipe.transform()).should.not.throw();
|
|
|
|
});
|
2015-12-14 19:31:17 +03:00
|
|
|
});
|
2015-12-14 19:14:35 +03:00
|
|
|
});
|
|
|
|
});
|