| 447 | } |
| 448 | |
| 449 | func TestCSS2(t *testing.T) { |
| 450 | tests := []struct { |
| 451 | css string |
| 452 | expected string |
| 453 | }{ |
| 454 | {`margin:5000`, `margin:5000`}, |
| 455 | {`margin:5000%`, `margin:5000%`}, |
| 456 | {`margin:5000em`, `margin:5000em`}, |
| 457 | {`color:transparent`, `color:transparent`}, |
| 458 | {`background-color:transparent`, `background-color:transparent`}, |
| 459 | //{`background-color:black!important`, `background-color:#000!important`}, // TODO: fails! may make result bigger |
| 460 | {`background-color:black !important`, `background-color:#000 !important`}, |
| 461 | } |
| 462 | |
| 463 | m := minify.New() |
| 464 | params := map[string]string{"inline": "1"} |
| 465 | cssMinifier := &Minifier{Version: 2} |
| 466 | for _, tt := range tests { |
| 467 | t.Run(tt.css, func(t *testing.T) { |
| 468 | r := bytes.NewBufferString(tt.css) |
| 469 | w := &bytes.Buffer{} |
| 470 | err := cssMinifier.Minify(m, w, r, params) |
| 471 | test.Minify(t, tt.css, err, w.String(), tt.expected) |
| 472 | }) |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | func TestReaderErrors(t *testing.T) { |
| 477 | r := test.NewErrorReader(0) |