Explorar o código

Simplify filter tests

Danilo Bargen %!s(int64=8) %!d(string=hai) anos
pai
achega
0b9de28574
Modificáronse 1 ficheiros con 11 adicións e 16 borrados
  1. 11 16
      tests/filters.js

+ 11 - 16
tests/filters.js

@@ -16,16 +16,18 @@ describe('Filters', function() {
 
     });
 
+    function testPatterns(filterName, cases) {
+        const filter = $filter(filterName);
+        for (let testcase of cases) {
+            const input = testcase[0];
+            const expected = testcase[1];
+            expect(filter(input)).toEqual(expected);
+        };
+    };
+
     describe('markify', function() {
 
-        this.testPatterns = (cases) => {
-            const filter = $filter('markify');
-            for (let testcase of cases) {
-                const input = testcase[0];
-                const expected = testcase[1];
-                expect(filter(input)).toEqual(expected);
-            };
-        };
+        this.testPatterns = (cases) => testPatterns('markify', cases);
 
         it('detects bold text', () => {
             this.testPatterns([
@@ -98,14 +100,7 @@ describe('Filters', function() {
 
     describe('htmlToAsciiMarkup', function() {
 
-        this.testPatterns = (cases) => {
-            const filter = $filter('htmlToAsciiMarkup');
-            for (let testcase of cases) {
-                const input = testcase[0];
-                const expected = testcase[1];
-                expect(filter(input)).toEqual(expected);
-            };
-        };
+        this.testPatterns = (cases) => testPatterns('htmlToAsciiMarkup', cases);
 
         it('converts bold text', () => {
             this.testPatterns([