Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
Signed-off-by: Nassim Zen <[email protected]>
  • Loading branch information
hironichu committed Mar 25, 2022
1 parent 4ed83f1 commit bba3803
Show file tree
Hide file tree
Showing 88 changed files with 8,620 additions and 4 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
tests

out
css

*.css
*.scss

.DS_Store
108 changes: 108 additions & 0 deletions tests/basic_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import sass from "../mod.ts";

Deno.test("variable_test", () => {
const from_files = sass(
`
$color: red;
$size: 10px;
body {
color : $color;
>.inner {
font-size: $size;
}
}`,
{
load_paths: [],
quiet: true,
style: "compressed",
},
);
assertEquals(
from_files.to_string(),
"body{color:red}body>.inner{font-size:10px}",
);
});

Deno.test("variable_test_2", () => {
const from_files = sass(
`
$var1: "hello";
$var2: "world";
.text {
content: $var1 + " " + $var2;
}
`,
{
load_paths: [],
quiet: true,
style: "compressed",
},
);
assertEquals(from_files.to_string(), '.text{content:"hello world"}');
});

Deno.test("sass_function_test", () => {
const from_files = sass(
`
@function my-function($arg1, $arg2) {
@return $arg1 + $arg2;
}
.text {
content: my-function(1, 2);
}
`,
{
load_paths: [],
quiet: true,
style: "compressed",
},
);
assertEquals(from_files.to_string(), ".text{content:3}");
});

Deno.test("sass_function_test_2", () => {
const from_files = sass(
`
@function my-function($arg1, $arg2) {
@return $arg1 + $arg2;
}
.text {
content: my-function(1, 2);
}
`,
{
load_paths: [],
quiet: true,
style: "expanded",
},
);
assertEquals(
from_files.to_string(),
`.text {
content: 3;
}
`,
);
});

//Test Mixins
Deno.test("mixin_test", () => {
const from_files = sass(
`
@mixin my-mixin($arg1, $arg2) {
color: $arg1;
font-size: $arg2;
}
.text {
@include my-mixin(red, 10px);
}
`,
{
load_paths: [],
quiet: true,
style: "compressed",
},
);
assertEquals(from_files.to_string(), ".text{color:red;font-size:10px}");
});
1 change: 1 addition & 0 deletions tests/bootstrap.css

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions tests/browser/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>

<body>
<script type="module">
import { str } from 'http://127.0.0.1:5500/src/api.js';
console.log(str(`
body {
background-color: #f0f0f0;
>p{
color: #000;
&:hover{
color: #f00;
}
}
}`
, {
load_paths: [],
style: "compressed",
quiet: true
}))
</script>
</body>

</html>
19 changes: 19 additions & 0 deletions tests/lib/anotherlib/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import "namelib";
@import "superlib";
$content: "Content";
.anothertestdiv {

>.superelem {
color: red;
}
}

#body, p {
>&.super {
color: blue;
&::after {
content: $content;
color:red;
}
}
}
9 changes: 9 additions & 0 deletions tests/lib/bootstrap/_bootstrap-compass.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@function twbs-font-path($path) {
@return font-url($path, true);
}

@function twbs-image-path($path) {
@return image-url($path, true);
}

$bootstrap-sass-asset-helper: true;
19 changes: 19 additions & 0 deletions tests/lib/bootstrap/_bootstrap-mincer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Mincer asset helper functions
//
// This must be imported into a .css.ejs.scss file.
// Then, <% %>-interpolations will be parsed as strings by Sass, and evaluated by EJS after Sass compilation.


@function twbs-font-path($path) {
// do something like following
// from "path/to/font.ext#suffix" to "<%- asset_path(path/to/font.ext)) + #suffix %>"
// from "path/to/font.ext?#suffix" to "<%- asset_path(path/to/font.ext)) + ?#suffix %>"
// or from "path/to/font.ext" just "<%- asset_path(path/to/font.ext)) %>"
@return "<%- asset_path("#{$path}".replace(/[#?].*$/, '')) + "#{$path}".replace(/(^[^#?]*)([#?]?.*$)/, '$2') %>";
}

@function twbs-image-path($file) {
@return "<%- asset_path("#{$file}") %>";
}

$bootstrap-sass-asset-helper: true;
9 changes: 9 additions & 0 deletions tests/lib/bootstrap/_bootstrap-sprockets.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@function twbs-font-path($path) {
@return font-path($path);
}

@function twbs-image-path($path) {
@return image-path($path);
}

$bootstrap-sass-asset-helper: true;
56 changes: 56 additions & 0 deletions tests/lib/bootstrap/_bootstrap.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*!
* Bootstrap v3.4.1 (https://getbootstrap.com/)
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/

// Core variables and mixins
@import "bootstrap/variables";
@import "bootstrap/mixins";

// Reset and dependencies
@import "bootstrap/normalize";
@import "bootstrap/print";
@import "bootstrap/glyphicons";

// Core CSS
@import "bootstrap/scaffolding";
@import "bootstrap/type";
@import "bootstrap/code";
@import "bootstrap/grid";
@import "bootstrap/tables";
@import "bootstrap/forms";
@import "bootstrap/buttons";

// Components
@import "bootstrap/component-animations";
@import "bootstrap/dropdowns";
@import "bootstrap/button-groups";
@import "bootstrap/input-groups";
@import "bootstrap/navs";
@import "bootstrap/navbar";
@import "bootstrap/breadcrumbs";
@import "bootstrap/pagination";
@import "bootstrap/pager";
@import "bootstrap/labels";
@import "bootstrap/badges";
@import "bootstrap/jumbotron";
@import "bootstrap/thumbnails";
@import "bootstrap/alerts";
@import "bootstrap/progress-bars";
@import "bootstrap/media";
@import "bootstrap/list-group";
@import "bootstrap/panels";
@import "bootstrap/responsive-embed";
@import "bootstrap/wells";
@import "bootstrap/close";

// Components w/ JavaScript
@import "bootstrap/modals";
@import "bootstrap/tooltip";
@import "bootstrap/popovers";
@import "bootstrap/carousel";

// Utility classes
@import "bootstrap/utilities";
@import "bootstrap/responsive-utilities";
73 changes: 73 additions & 0 deletions tests/lib/bootstrap/bootstrap/_alerts.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// Alerts
// --------------------------------------------------


// Base styles
// -------------------------

.alert {
padding: $alert-padding;
margin-bottom: $line-height-computed;
border: 1px solid transparent;
border-radius: $alert-border-radius;

// Headings for larger alerts
h4 {
margin-top: 0;
color: inherit; // Specified for the h4 to prevent conflicts of changing $headings-color
}

// Provide class for links that match alerts
.alert-link {
font-weight: $alert-link-font-weight;
}

// Improve alignment and spacing of inner content
> p,
> ul {
margin-bottom: 0;
}

> p + p {
margin-top: 5px;
}
}

// Dismissible alerts
//
// Expand the right padding and account for the close button's positioning.

// The misspelled .alert-dismissable was deprecated in 3.2.0.
.alert-dismissable,
.alert-dismissible {
padding-right: ($alert-padding + 20);

// Adjust close link position
.close {
position: relative;
top: -2px;
right: -21px;
color: inherit;
}
}

// Alternate styles
//
// Generate contextual modifier classes for colorizing the alert.

.alert-success {
@include alert-variant($alert-success-bg, $alert-success-border, $alert-success-text);
}

.alert-info {
@include alert-variant($alert-info-bg, $alert-info-border, $alert-info-text);
}

.alert-warning {
@include alert-variant($alert-warning-bg, $alert-warning-border, $alert-warning-text);
}

.alert-danger {
@include alert-variant($alert-danger-bg, $alert-danger-border, $alert-danger-text);
}
Loading

0 comments on commit bba3803

Please sign in to comment.