Add pipe mechanism
Change-Id: I4207b33b1e4bab06ee632fd17be68542891caee3
diff --git a/dev/js/spec/pipeSpec.js b/dev/js/spec/pipeSpec.js
new file mode 100644
index 0000000..46cd5b9
--- /dev/null
+++ b/dev/js/spec/pipeSpec.js
@@ -0,0 +1,92 @@
+define(['pipe'], function (pipeClass) {
+
+ describe('KorAP.Pipe', function () {
+ it('should be initializable', function () {
+ let p = pipeClass.create();
+ expect(p.size()).toEqual(0);
+ });
+
+ it('should be appendable', function () {
+ let p = pipeClass.create();
+ expect(p.size()).toEqual(0);
+ expect(p.toString()).toEqual('');
+ p.append('service1');
+ expect(p.size()).toEqual(1);
+ expect(p.toString()).toEqual('service1');
+ p.append('service2');
+ expect(p.size()).toEqual(2);
+ expect(p.toString()).toEqual('service1,service2');
+
+ p.append('');
+ expect(p.size()).toEqual(2);
+ expect(p.toString()).toEqual('service1,service2');
+ });
+
+ it('should be prependable', function () {
+ let p = pipeClass.create();
+ expect(p.size()).toEqual(0);
+ expect(p.toString()).toEqual('');
+ p.prepend('service1');
+ expect(p.size()).toEqual(1);
+ expect(p.toString()).toEqual('service1');
+ p.prepend('service2');
+ expect(p.size()).toEqual(2);
+ expect(p.toString()).toEqual('service2,service1');
+
+ p.prepend('');
+ expect(p.size()).toEqual(2);
+ expect(p.toString()).toEqual('service2,service1');
+ });
+
+ it('should be trimmed', function () {
+ let p = pipeClass.create();
+ expect(p.size()).toEqual(0);
+ expect(p.toString()).toEqual('');
+ p.prepend(' service1 ');
+ expect(p.size()).toEqual(1);
+ expect(p.toString()).toEqual('service1');
+
+ p.prepend("\t service2 \t");
+ expect(p.size()).toEqual(2);
+ expect(p.toString()).toEqual('service2,service1');
+
+ p.append(' ');
+ expect(p.size()).toEqual(2);
+ expect(p.toString()).toEqual('service2,service1');
+ });
+
+ it('should be deletable', function () {
+ let p = pipeClass.create();
+ p.append('service1');
+ p.append('service2');
+ p.append('service3');
+ expect(p.toString()).toEqual('service1,service2,service3');
+ p.remove('service2')
+ expect(p.toString()).toEqual('service1,service3');
+
+ p = pipeClass.create();
+ p.append('service1');
+ p.append('service2');
+ p.append('service3');
+ expect(p.toString()).toEqual('service1,service2,service3');
+ p.remove('service1')
+ expect(p.toString()).toEqual('service2,service3');
+
+ p = pipeClass.create();
+ p.append('service1');
+ p.append('service2');
+ p.append('service3');
+ expect(p.toString()).toEqual('service1,service2,service3');
+ p.remove('service3')
+ expect(p.toString()).toEqual('service1,service2');
+
+ p = pipeClass.create();
+ p.append('service1');
+ p.append('service2');
+ p.append('service3');
+ expect(p.toString()).toEqual('service1,service2,service3');
+ p.remove('service0')
+ expect(p.toString()).toEqual('service1,service2,service3');
+ });
+ });
+});