Kaynağa Gözat

Adding tests around styling spreadsheet cells

main
Rocketsoup 1 yıl önce
ebeveyn
işleme
14f8ed112d

+ 53
- 0
jstest/spreadsheet/SpreadsheetMarkdownIntegrationTests.js Dosyayı Görüntüle

@@ -59,4 +59,57 @@ class SpreadsheetMarkdownIntegrationTests extends BaseTest {
59 59
 		const actual = this.md(markdown);
60 60
 		this.assertEqual(expected, actual);
61 61
 	}
62
+
63
+	test_styledValue() {
64
+		const markdown = "| A | B | C |\n| --- | --- | --- |\n| **3** | _4_ | =A*B |";
65
+		const expected = '<table><thead>' +
66
+			'<tr><th>A</th><th>B</th><th>C</th></tr>' +
67
+			'</thead><tbody><tr>' +
68
+			'<td class="spreadsheet-type-number" data-numeric-value="3" data-string-value="3"><strong>3</strong></td>' +
69
+			'<td class="spreadsheet-type-number" data-numeric-value="4" data-string-value="4"><em>4</em></td>' +
70
+			'<td class="calculated spreadsheet-type-number" data-numeric-value="12" data-string-value="12">12</td>' +
71
+			'</tr></tbody></table>';
72
+		const actual = this.md(markdown);
73
+		this.assertEqual(expected, actual);
74
+	}
75
+
76
+	test_styledFormula() {
77
+		const markdown = "| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | **=A*B** |";
78
+		const expected = '<table><thead>' +
79
+			'<tr><th>A</th><th>B</th><th>C</th></tr>' +
80
+			'</thead><tbody><tr>' +
81
+			'<td class="spreadsheet-type-number" data-numeric-value="3" data-string-value="3">3</td>' +
82
+			'<td class="spreadsheet-type-number" data-numeric-value="4" data-string-value="4">4</td>' +
83
+			'<td class="calculated spreadsheet-type-number" data-numeric-value="12" data-string-value="12"><strong>12</strong></td>' +
84
+			'</tr></tbody></table>';
85
+		const actual = this.md(markdown);
86
+		this.assertEqual(expected, actual);
87
+	}
88
+
89
+	test_styledFormula_multiple() {
90
+		const markdown = "| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | ~~**=A*B**~~ |";
91
+		const expected = '<table><thead>' +
92
+			'<tr><th>A</th><th>B</th><th>C</th></tr>' +
93
+			'</thead><tbody><tr>' +
94
+			'<td class="spreadsheet-type-number" data-numeric-value="3" data-string-value="3">3</td>' +
95
+			'<td class="spreadsheet-type-number" data-numeric-value="4" data-string-value="4">4</td>' +
96
+			'<td class="calculated spreadsheet-type-number" data-numeric-value="12" data-string-value="12"><s><strong>12</strong></s></td>' +
97
+			'</tr></tbody></table>';
98
+		const actual = this.md(markdown);
99
+		this.assertEqual(expected, actual);
100
+	}
101
+
102
+	test_preservedOperators() {
103
+		// Regular markdown will want to convert *B* into emphasized B
104
+		const markdown = "| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | =A*B*4 |";
105
+		const expected = '<table><thead>' +
106
+			'<tr><th>A</th><th>B</th><th>C</th></tr>' +
107
+			'</thead><tbody><tr>' +
108
+			'<td class="spreadsheet-type-number" data-numeric-value="3" data-string-value="3">3</td>' +
109
+			'<td class="spreadsheet-type-number" data-numeric-value="4" data-string-value="4">4</td>' +
110
+			'<td class="calculated spreadsheet-type-number" data-numeric-value="48" data-string-value="48">48</td>' +
111
+			'</tr></tbody></table>';
112
+		const actual = this.md(markdown);
113
+		this.assertEqual(expected, actual);
114
+	}
62 115
 }

+ 53
- 0
phptest/spreadsheet/SpreadsheetMarkdownIntegrationTests.php Dosyayı Görüntüle

@@ -73,5 +73,58 @@ final class SpreadsheetMarkdownIntegrationTests extends TestCase {
73 73
 		$actual = $this->md($markdown);
74 74
 		$this->assertSame($expected, $actual);
75 75
 	}
76
+
77
+	public function test_styledValue() {
78
+		$markdown = "| A | B | C |\n| --- | --- | --- |\n| **3** | _4_ | =A*B |";
79
+		$expected = '<table><thead>' .
80
+			'<tr><th>A</th><th>B</th><th>C</th></tr>' .
81
+			'</thead><tbody><tr>' .
82
+			'<td class="spreadsheet-type-number" data-numeric-value="3" data-string-value="3"><strong>3</strong></td>' .
83
+			'<td class="spreadsheet-type-number" data-numeric-value="4" data-string-value="4"><em>4</em></td>' .
84
+			'<td class="calculated spreadsheet-type-number" data-numeric-value="12" data-string-value="12">12</td>' .
85
+			'</tr></tbody></table>';
86
+		$actual = $this->md($markdown);
87
+		$this->assertSame($expected, $actual);
88
+	}
89
+
90
+	public function test_styledFormula() {
91
+		$markdown = "| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | **=A*B** |";
92
+		$expected = '<table><thead>' .
93
+			'<tr><th>A</th><th>B</th><th>C</th></tr>' .
94
+			'</thead><tbody><tr>' .
95
+			'<td class="spreadsheet-type-number" data-numeric-value="3" data-string-value="3">3</td>' .
96
+			'<td class="spreadsheet-type-number" data-numeric-value="4" data-string-value="4">4</td>' .
97
+			'<td class="calculated spreadsheet-type-number" data-numeric-value="12" data-string-value="12"><strong>12</strong></td>' .
98
+			'</tr></tbody></table>';
99
+		$actual = $this->md($markdown);
100
+		$this->assertSame($expected, $actual);
101
+	}
102
+
103
+	public function test_styledFormula_multiple() {
104
+		$markdown = "| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | ~~**=A*B**~~ |";
105
+		$expected = '<table><thead>' .
106
+			'<tr><th>A</th><th>B</th><th>C</th></tr>' .
107
+			'</thead><tbody><tr>' .
108
+			'<td class="spreadsheet-type-number" data-numeric-value="3" data-string-value="3">3</td>' .
109
+			'<td class="spreadsheet-type-number" data-numeric-value="4" data-string-value="4">4</td>' .
110
+			'<td class="calculated spreadsheet-type-number" data-numeric-value="12" data-string-value="12"><s><strong>12</strong></s></td>' .
111
+			'</tr></tbody></table>';
112
+		$actual = $this->md($markdown);
113
+		$this->assertSame($expected, $actual);
114
+	}
115
+
116
+	public function test_preservedOperators() {
117
+		// Regular markdown will want to convert *B* into emphasized B
118
+		$markdown = "| A | B | C |\n| --- | --- | --- |\n| 3 | 4 | =A*B*4 |";
119
+		$expected = '<table><thead>' .
120
+			'<tr><th>A</th><th>B</th><th>C</th></tr>' .
121
+			'</thead><tbody><tr>' .
122
+			'<td class="spreadsheet-type-number" data-numeric-value="3" data-string-value="3">3</td>' .
123
+			'<td class="spreadsheet-type-number" data-numeric-value="4" data-string-value="4">4</td>' .
124
+			'<td class="calculated spreadsheet-type-number" data-numeric-value="48" data-string-value="48">48</td>' .
125
+			'</tr></tbody></table>';
126
+		$actual = $this->md($markdown);
127
+		$this->assertSame($expected, $actual);
128
+	}
76 129
 }
77 130
 ?>

Loading…
İptal
Kaydet